Skip to content

Commit

Permalink
chore: update cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Apr 8, 2022
1 parent e6ff060 commit 87d7f0c
Show file tree
Hide file tree
Showing 5 changed files with 397 additions and 787 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -105,7 +105,6 @@
"@angular/platform-browser-dynamic": "13.0.0",
"@angular/platform-server": "13.0.0",
"@angular/router": "13.0.0",
"@applitools/eyes-cypress": "^3.4.12",
"@nrwl/angular": "13.10.0",
"core-js": "^2.5.4",
"opencollective": "^1.0.3",
Expand Down Expand Up @@ -162,7 +161,7 @@
"conventional-changelog-cli": "^1.3.21",
"coveralls": "^2.13.0",
"cpy-cli": "^1.0.1",
"cypress": "4.1.0",
"cypress": "9.5.3",
"deep-freeze": "^0.0.1",
"eslint": "8.12.0",
"eslint-config-prettier": "8.5.0",
Expand Down
35 changes: 3 additions & 32 deletions projects/example-app-e2e/src/integration/round-trip.spec.ts
@@ -1,26 +1,15 @@
context('Full round trip', () => {
before(() => {
// TODO: uncomment once Applitools work properly
// (cy as any).eyesOpen({
// appName: 'books_app',
// testName: 'round-trip',
// browser: { width: 800, height: 600 },
// });
window.localStorage.removeItem('books_app');
cy.visit('/');
});

beforeEach(() => {
(cy as any).restoreLocalStorage();
cy.restoreLocalStorage();
});

afterEach(() => {
(cy as any).saveLocalStorage();
});

after(() => {
// TODO: uncomment once Applitools work properly
// (cy as any).eyesClose();
cy.saveLocalStorage();
});

it('shows a message when the credentials are wrong', () => {
Expand All @@ -29,10 +18,6 @@ context('Full round trip', () => {
.type('wronguser');
cy.findByLabelText(/password/i).type('supersafepassword');
cy.findByRole('button', { name: /login/i }).click();
// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow(
// 'show a message when the credentials are wrong'
// );
cy.contains('Invalid username or password').should('be.visible');
});

Expand All @@ -46,9 +31,6 @@ context('Full round trip', () => {
cy.contains('My Collection');
cy.findByRole('button', { name: /menu/i }).click();
cy.findByText(/browse books/i).click();

// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow('is possible to search for books');
cy.findByRole('textbox', { name: /search for a book/i }).type(
'The Alchemist'
);
Expand All @@ -59,8 +41,6 @@ context('Full round trip', () => {
cy.get('bc-book-preview').eq(2).click();

cy.findByRole('button', { name: /add book to collection/i }).click();
// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow('is possible to add books');
cy.findByRole('button', { name: /add book to collection/i }).should(
'not.exist'
);
Expand All @@ -73,9 +53,6 @@ context('Full round trip', () => {

cy.findByRole('button', { name: /add book to collection/i }).click();
cy.findByRole('button', { name: /remove book from collection/i }).click();

// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow('is possible to remove books');
cy.findByRole('button', { name: /remove book from collection/i }).should(
'not.exist'
);
Expand All @@ -84,19 +61,13 @@ context('Full round trip', () => {
it('is possible to show the collection', () => {
cy.findByRole('button', { name: /menu/i }).click();
cy.findByText(/my collection/i).click();

// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow('is possible to show the collection');
cy.get('bc-book-preview').its('length').should('be', 1);
cy.get('bc-book-preview').its('length').should('eq', 1);
});

it('is possible to sign out', () => {
cy.findByRole('button', { name: /menu/i }).click();
cy.findByText(/sign out/i).click();
cy.findByRole('button', { name: /ok/i }).click();

// TODO: uncomment once Applitools work properly
// (cy as any).eyesCheckWindow('is possible to sign out');
cy.findByRole('textbox', { name: /username/i }).should('exist');
cy.findByLabelText(/password/i).should('exist');
});
Expand Down
15 changes: 0 additions & 15 deletions projects/example-app-e2e/src/support/commands.ts
Expand Up @@ -10,21 +10,6 @@

import '@testing-library/cypress/add-commands';

//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

// TODO: uncomment once Applitools work properly
// import '@applitools/eyes-cypress/commands';

const LOCAL_STORAGE_MEMORY: any = {};

Cypress.Commands.add('saveLocalStorage', () => {
Expand Down
9 changes: 9 additions & 0 deletions projects/example-app-e2e/src/support/index.ts
Expand Up @@ -15,3 +15,12 @@

// Import commands.js using ES2015 syntax:
import './commands';

declare global {
namespace Cypress {
interface Chainable {
saveLocalStorage(): Chainable<void>;
restoreLocalStorage(): Chainable<void>;
}
}
}

0 comments on commit 87d7f0c

Please sign in to comment.