streamlit
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
17describe("st.tabs", () => {18beforeEach(() => {19cy.loadApp("http://localhost:3000/");20
21cy.prepForElementSnapshots();22});23
24it("displays correctly", () => {25cy.get(".stTabs").should("have.length", 3);26
27cy.get(".stTabs").each((el, idx) => {28return cy.wrap(el).matchThemedSnapshots("tabs" + idx);29});30});31
32it("displays correctly in sidebar", () => {33cy.get("[data-testid='stSidebar'] .stTabs [data-baseweb='tab']").should(34"have.length",35236);37
38cy.get("[data-testid='stSidebar'] .stTabs").first()39.within(() => {40cy.get(".stMarkdown").first().should("have.text", "I am in the sidebar");41});42
43// text from every tab should be here because renderAll property is set to true44cy.get("[data-testid='stSidebar'] .stTabs")45.first()46.within(() => {47cy.get(".stMarkdown").should("have.text", "I am in the sidebarI'm also in the sidebar");48});49});50
51it("changes rendered content on tab selection", () => {52cy.getIndexed(".main .stTabs", 0).within(() => {53let tab_2_button = cy.getIndexed("[data-baseweb='tab']", 1);54tab_2_button.should("exist");55tab_2_button.click();56
57cy.get("[data-baseweb='tab-panel'] .stNumberInput").should(58"have.length",59160);61});62});63
64it("contains all tabs when overflowing", () => {65cy.get("[data-testid='stExpander'] .stTabs [data-baseweb='tab']").should(66"have.length",672568);69});70});71