|
1 | 1 | describe('IonTabs', () => { |
| 2 | + /** |
| 3 | + * Verifies that tabs with similar route prefixes (e.g., /home, /home2, /home3) |
| 4 | + * correctly select the matching tab instead of the first prefix match. |
| 5 | + */ |
| 6 | + describe('Similar Route Prefixes', () => { |
| 7 | + it('should select the correct tab when routes have similar prefixes', () => { |
| 8 | + cy.visit('/tabs-similar-prefixes/home2'); |
| 9 | + |
| 10 | + cy.get('[data-testid="home2-content"]').should('be.visible'); |
| 11 | + cy.get('[data-testid="home2-tab"]').should('have.class', 'tab-selected'); |
| 12 | + cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should select the correct tab when navigating via tab buttons', () => { |
| 16 | + cy.visit('/tabs-similar-prefixes/home'); |
| 17 | + |
| 18 | + cy.get('[data-testid="home-tab"]').should('have.class', 'tab-selected'); |
| 19 | + cy.get('[data-testid="home2-tab"]').should('not.have.class', 'tab-selected'); |
| 20 | + |
| 21 | + cy.get('[data-testid="home2-tab"]').click(); |
| 22 | + cy.get('[data-testid="home2-tab"]').should('have.class', 'tab-selected'); |
| 23 | + cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected'); |
| 24 | + |
| 25 | + cy.get('[data-testid="home3-tab"]').click(); |
| 26 | + cy.get('[data-testid="home3-tab"]').should('have.class', 'tab-selected'); |
| 27 | + cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected'); |
| 28 | + cy.get('[data-testid="home2-tab"]').should('not.have.class', 'tab-selected'); |
| 29 | + }); |
| 30 | + |
| 31 | + it('should select the correct tab when directly navigating to home3', () => { |
| 32 | + cy.visit('/tabs-similar-prefixes/home3'); |
| 33 | + |
| 34 | + cy.get('[data-testid="home3-content"]').should('be.visible'); |
| 35 | + cy.get('[data-testid="home3-tab"]').should('have.class', 'tab-selected'); |
| 36 | + cy.get('[data-testid="home-tab"]').should('not.have.class', 'tab-selected'); |
| 37 | + cy.get('[data-testid="home2-tab"]').should('not.have.class', 'tab-selected'); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
2 | 41 | describe('With IonRouterOutlet', () => { |
3 | 42 | beforeEach(() => { |
4 | 43 | cy.visit('/tabs/tab1'); |
|
0 commit comments