|
| 1 | +const port = 3000; |
| 2 | + |
| 3 | +/** |
| 4 | + * Tests that IonBackButton works correctly after navigating with |
| 5 | + * routerDirection="none". The back button should use history to |
| 6 | + * determine the previous page, not fall back to defaultHref. |
| 7 | + * |
| 8 | + * @see https://github.com/ionic-team/ionic-framework/issues/24074 |
| 9 | + */ |
| 10 | +describe('routerDirection="none" Back Button', () => { |
| 11 | + |
| 12 | + it('back button should return to Page A after navigating with direction "forward"', () => { |
| 13 | + cy.visit(`http://localhost:${port}/direction-none-back/a`); |
| 14 | + cy.ionPageVisible('direction-none-page-a'); |
| 15 | + |
| 16 | + // Navigate A -> B with default forward direction |
| 17 | + cy.ionNav('ion-button#go-forward', 'Go to B (forward)'); |
| 18 | + cy.ionPageVisible('direction-none-page-b'); |
| 19 | + |
| 20 | + // Back button should go back to Page A (not to defaultHref fallback) |
| 21 | + cy.ionBackClick('direction-none-page-b'); |
| 22 | + cy.ionPageDoesNotExist('direction-none-fallback'); |
| 23 | + cy.ionPageVisible('direction-none-page-a'); |
| 24 | + cy.url().should('include', '/direction-none-back/a'); |
| 25 | + }); |
| 26 | + |
| 27 | + it('back button should return to Page A after navigating with direction "none"', () => { |
| 28 | + cy.visit(`http://localhost:${port}/direction-none-back/a`); |
| 29 | + cy.ionPageVisible('direction-none-page-a'); |
| 30 | + |
| 31 | + // Navigate A -> B with routerDirection="none" |
| 32 | + cy.ionNav('ion-button#go-none', 'Go to B (none)'); |
| 33 | + cy.ionPageVisible('direction-none-page-b'); |
| 34 | + |
| 35 | + // Back button should go back to Page A (not to defaultHref fallback) |
| 36 | + cy.ionBackClick('direction-none-page-b'); |
| 37 | + cy.ionPageDoesNotExist('direction-none-fallback'); |
| 38 | + cy.ionPageVisible('direction-none-page-a'); |
| 39 | + cy.url().should('include', '/direction-none-back/a'); |
| 40 | + }); |
| 41 | + |
| 42 | +}); |
0 commit comments