streamlit

Форк
0
/
st_caption.spec.js 
68 строк · 2.2 Кб
1
/**
2
 * Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
describe("st.caption", () => {
18
  before(() => {
19
    cy.loadApp("http://localhost:3000/");
20
  });
21

22
  it("displays correct number of elements", () => {
23
    cy.get(
24
      ".element-container .stMarkdown [data-testid='stCaptionContainer']"
25
    ).should("have.length", 6);
26
  });
27

28
  it("matches snapshots", () => {
29
    cy.get(
30
      ".element-container .stMarkdown [data-testid='stCaptionContainer']"
31
    ).then(els => {
32
      cy.wrap(els.slice(1)).each((el, i) => {
33
        return cy.wrap(el).matchThemedSnapshots(`caption-${i}`);
34
      });
35
    });
36
  });
37

38
  it("displays correct content inside caption", () => {
39
    cy.get(
40
      ".element-container .stMarkdown [data-testid='stCaptionContainer']"
41
    ).then(els => {
42
      expect(els[1].textContent).to.eq("This is a caption!");
43
      expect(els[2].textContent).to.eq(
44
        "This is a caption that contains markdown inside it!"
45
      );
46
      cy.wrap(els[2])
47
        .get("em")
48
        .should("have.text", "caption");
49
      cy.wrap(els[2])
50
        .get("strong")
51
        .should("have.text", "markdown inside it");
52
      // html should be escaped when unsafe_allow_html=False
53
      expect(els[3].textContent).to.eq(
54
        "This is a caption that contains <div>html</div> inside it!"
55
      );
56
      // html should render when unsafe_allow_html=True
57
      expect(els[4].textContent).to.eq(
58
        "This is a caption that contains html inside it!"
59
      );
60
    });
61
  });
62

63
  it("matches snapshot in sidebar", () => {
64
    cy.get("[data-testid='stSidebar'] .stMarkdown").matchThemedSnapshots(
65
      `caption-in-sidebar`
66
    );
67
  });
68
});
69

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.