Skip to content

Commit

Permalink
deps: cypress to version 12.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisie96 committed Jan 20, 2023
1 parent 8a22f3c commit 9be2e8a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 37 deletions.
1 change: 1 addition & 0 deletions e2e/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export default defineConfig({
},
baseUrl: 'http://localhost:4200',
specPattern: 'cypress/e2e/**/*.e2e-spec.ts',
testIsolation: false,
},
});
4 changes: 3 additions & 1 deletion e2e/cypress/e2e/framework/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Interception } from 'cypress/types/net-stubbing';

interface Page {
tag: string;
}
Expand Down Expand Up @@ -57,7 +59,7 @@ export function fillFormField(parent: string, key: string, value: number | strin

export function performAddToCart(
button: () => Cypress.Chainable<JQuery<HTMLElement>>
): Cypress.Chainable<Cypress.WaitXHR> {
): Cypress.Chainable<Interception> {
waitLoadingEnd(1000);
cy.intercept('POST', '**/baskets/*/items').as('basket');
cy.intercept('GET', '**/baskets/*').as('basketCurrent');
Expand Down
4 changes: 3 additions & 1 deletion e2e/cypress/e2e/pages/shopping/product-detail.page.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Interception } from 'cypress/types/net-stubbing';

import { performAddToCart, waitLoadingEnd } from '../../framework';
import { AddToOrderTemplateModule } from '../account/add-to-order-template.module';
import { AddToWishlistModule } from '../account/add-to-wishlist.module';
Expand Down Expand Up @@ -68,7 +70,7 @@ export class ProductDetailPage {
this.addToOrderTemplateButton().click();
}

addProductToCart(): Cypress.Chainable<Cypress.WaitXHR> {
addProductToCart(): Cypress.Chainable<Interception> {
return performAddToCart(this.addToCartButton);
}

Expand Down
37 changes: 12 additions & 25 deletions e2e/cypress/e2e/specs/system/retain-authentication.b2c.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ const _ = {
} as Registration,
};

function checkApiTokenCookie(type: string) {
cy.getCookie('apiToken').then(cookie => {
expect(cookie).to.not.be.empty;
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', type);
});
}

describe('Returning User', () => {
describe('when logged in', () => {
before(() => LoginPage.navigateTo());
Expand All @@ -26,52 +33,32 @@ describe('Returning User', () => {
at(MyAccountPage, page =>
page.header.myAccountLink.should('have.text', `${_.user.firstName} ${_.user.lastName}`)
);
cy.getCookie('apiToken')
.should('not.be.empty')
.should(cookie => {
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', 'user');
});
checkApiTokenCookie('user');
});

it('should stay logged in when refreshing page once', () => {
MyAccountPage.navigateTo();
at(MyAccountPage);
cy.getCookie('apiToken')
.should('not.be.empty')
.should(cookie => {
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', 'user');
});
checkApiTokenCookie('user');
});

it('should stay logged in when refreshing page twice', () => {
MyAccountPage.navigateTo();
at(MyAccountPage);
cy.getCookie('apiToken')
.should('not.be.empty')
.should(cookie => {
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', 'user');
});
checkApiTokenCookie('user');
});

it('should stay logged in when refreshing page thrice', () => {
MyAccountPage.navigateTo();
at(MyAccountPage);
cy.getCookie('apiToken')
.should('not.be.empty')
.should(cookie => {
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', 'user');
});
checkApiTokenCookie('user');
});

it('should log out and get the anonymous token', () => {
at(MyAccountPage, page => page.header.logout());
at(HomePage);
// eslint-disable-next-line unicorn/no-null
cy.getCookie('apiToken')
.should('not.be.empty')
.should(cookie => {
cy.wrap(JSON.parse(decodeURIComponent(cookie.value))).should('have.property', 'type', 'anonymous');
});
checkApiTokenCookie('anonymous');
});
});

Expand Down
5 changes: 0 additions & 5 deletions e2e/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ beforeEach(() => {

// Cypress.Cookies.debug(true);

// keep certain cookies
Cypress.Cookies.defaults({
preserve: ['apiToken'],
});

Cypress.on('uncaught:exception', (err, runnable) => {
console.error(err);

Expand Down
10 changes: 5 additions & 5 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"author": "",
"license": "MIT",
"dependencies": {
"cypress": "^10.3.1",
"cypress-failed-log": "^2.9.2",
"cypress": "^12.3.0",
"cypress-failed-log": "^2.10.0",
"cypress-log-to-output": "^1.1.2",
"har-validator": "^5.1.5",
"lodash": "^4.17.21",
"typescript": "^4.5.5"
"typescript": "^4.9.4"
},
"devDependencies": {
"@types/lodash": "^4.14.182",
"@types/node": "^18.6.1"
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.1"
}
}

0 comments on commit 9be2e8a

Please sign in to comment.