Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/angular/test/base/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,21 @@ Cypress.Commands.add('ionSwipeToGoBack', (complete = false, selector = 'ion-rout
cy.wait(150);
});

/**
* getStack is a query because it has automatic
* retries built in which will let us account for
* async routing without having to use
* arbitrary cy.wait calls.
*/
Cypress.Commands.addQuery('getStack', (selector) => {
return () => {
const el = cy.$$(selector);
return Array.from(el.children()).map((el) => el.tagName.toLowerCase());
}
});

Cypress.Commands.add('testStack', (selector, expected) => {
cy.document().then((doc) => {
const children = Array.from(doc.querySelector(selector).children).map((el) => el.tagName.toLowerCase());
expect(children).to.deep.equal(expected);
});
cy.getStack(selector).should('deep.equal', expected);
});

Cypress.Commands.add('testLifeCycle', (selector, expected) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
describe('Navigation', () => {
beforeEach(() => {
cy.visit('/lazy/navigation');
cy.visit('/lazy/navigation/page1?ionic:_testing=true');
})

it('should navigate correctly', () => {
cy.visit('/lazy/navigation/page1');
cy.wait(2000);
cy.testStack('ion-router-outlet', ['app-navigation-page2', 'app-navigation-page1']);

cy.get('app-navigation-page2').should('have.attr', 'aria-hidden').and('equal', 'true');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Nested Outlet', () => {
beforeEach(() => {
cy.visit('/lazy/nested-outlet/page');
cy.visit('/lazy/nested-outlet/page?ionic:_testing=true');
})

it('should navigate correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe('Router Link', () => {
beforeEach(() => {
cy.visit('/lazy/router-link');
cy.visit('/lazy/router-link?ionic:_testing=true');
});

describe('router-link params and fragments', () => {
Expand All @@ -9,7 +9,6 @@ describe('Router Link', () => {
const id = 'MyPageID==';

it('should go to a page with properly encoded values', () => {
cy.visit('/lazy/router-link?ionic:_testing=true');
cy.get('#queryParamsFragment').click();

const expectedPath = `${encodeURIComponent(id)}`;
Expand All @@ -24,7 +23,6 @@ describe('Router Link', () => {
});

it('should return to a page with preserved query param and fragment', () => {
cy.visit('/lazy/router-link?ionic:_testing=true');
cy.get('#queryParamsFragment').click();
cy.get('#goToPage3').click();

Expand Down Expand Up @@ -148,7 +146,6 @@ function testForward() {
}

function testRoot() {
cy.wait(200);
cy.testStack('ion-router-outlet', ['app-router-link-page']);
cy.testLifeCycle('app-router-link-page', {
ionViewWillEnter: 1,
Expand All @@ -159,7 +156,6 @@ function testRoot() {
cy.get('app-router-link-page #canGoBack').should('have.text', 'false');

cy.go('back');
cy.wait(100);
cy.testStack('ion-router-outlet', ['app-router-link']);
cy.testLifeCycle('app-router-link', {
ionViewWillEnter: 1,
Expand All @@ -170,7 +166,6 @@ function testRoot() {
}

function testBack() {
cy.wait(500);
cy.testStack('ion-router-outlet', ['app-router-link-page']);
cy.testLifeCycle('app-router-link-page', {
ionViewWillEnter: 1,
Expand All @@ -181,7 +176,6 @@ function testBack() {
cy.get('app-router-link-page #canGoBack').should('have.text', 'false');

cy.go('back');
cy.wait(100);
cy.testStack('ion-router-outlet', ['app-router-link']);
cy.testLifeCycle('app-router-link', {
ionViewWillEnter: 1,
Expand Down