Skip to content

Commit 15bff92

Browse files
author
Gilberto Alvarado
authored
test: Fixing e2e regression tests (#1765) (#1783) (#1821)
1 parent 331657d commit 15bff92

23 files changed

+150
-339
lines changed

ci-scripts/e2e-cypress.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
set -e
33
set -o pipefail
44

5+
SUITE=$1
6+
57
yarn
68
(cd projects/storefrontapp-e2e-cypress && yarn)
79

@@ -10,5 +12,10 @@ echo 'Building Spartacus libraries'
1012
yarn build:core:lib
1113

1214
echo '-----'
13-
echo 'Running Cypress end to end tests'
14-
yarn e2e:cy:start-run-ci
15+
echo "Running Cypress end to end tests $SUITE"
16+
if [ $SUITE == 'regression' ]; then
17+
yarn e2e:cy:start-run-regression-ci
18+
yarn e2e:cy:start-run-mobile-ci
19+
else
20+
yarn e2e:cy:start-run-ci
21+
fi

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,15 @@
1515
"e2e:cy:open": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:open",
1616
"e2e:cy:run": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run",
1717
"e2e:cy:run:ci": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run --record --key $CYPRESS_KEY",
18+
"e2e:cy:run:mobile": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run:mobile",
19+
"e2e:cy:run:mobile:ci": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run:mobile --record --key $CYPRESS_KEY",
1820
"e2e:cy:run:regression": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run:regression",
1921
"e2e:cy:run:regression:ci": "yarn --cwd ./projects/storefrontapp-e2e-cypress run cy:run:regression --record --key $CYPRESS_KEY",
2022
"e2e:cy:start-open": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:open",
2123
"e2e:cy:start-run": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run",
2224
"e2e:cy:start-run-ci": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run:ci",
25+
"e2e:cy:start-run-mobile": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run:mobile",
26+
"e2e:cy:start-run-mobile-ci": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run:mobile:ci",
2327
"e2e:cy:start-run-regression": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run:regression",
2428
"e2e:cy:start-run-regression-ci": "start-server-and-test start:ci http-get://localhost:4200 e2e:cy:run:regression:ci",
2529
"generate:changelog": "ts-node ./scripts/changelog.ts",

projects/storefrontapp-e2e-cypress/cypress.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"defaultCommandTimeout": 10000,
33
"baseUrl": "http://localhost:4200",
44
"projectId": "k3nmep",
5+
"requestTimeout": 10000,
56
"env": {
67
"CLIENT_ID": "mobile_android",
78
"CLIENT_SECRET": "secret",

projects/storefrontapp-e2e-cypress/cypress/helpers/checkout-as-persistent-user.ts

-52
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,6 @@ export function loginSuccessfully() {
44
cy.get('.cx-login-greet').should('contain', 'Test User');
55
}
66

7-
export function addShippingAddress() {
8-
cy.request({
9-
method: 'POST',
10-
url: `${Cypress.env(
11-
'API_URL'
12-
)}/rest/v2/electronics-spa/users/test-user-cypress@ydev.hybris.com/addresses?lang=en&curr=USD`,
13-
headers: {
14-
Authorization: `bearer ${
15-
JSON.parse(sessionStorage.getItem('auth')).userToken.token[
16-
'access_token'
17-
]
18-
}`,
19-
},
20-
body: {
21-
defaultAddress: false,
22-
titleCode: 'mr',
23-
firstName: 'Test',
24-
lastName: 'User',
25-
line1: '999 de Maisonneuve',
26-
line2: '',
27-
town: 'Montreal',
28-
region: { isocode: 'US-AK' },
29-
country: { isocode: 'US' },
30-
postalCode: 'H4B3L4',
31-
phone: '',
32-
},
33-
}).then(response => {
34-
expect(response.status).to.eq(201);
35-
});
36-
}
37-
387
export function changePageFromProductToCategory() {
398
// click big banner
409
cy.get('.Section1 cx-responsive-banner')
@@ -163,24 +132,3 @@ export function displaySummaryPage() {
163132
cy.get('cx-cart-item .cx-code').should('contain', product.code);
164133
cy.get('cx-order-summary .cx-summary-amount').should('not.be.empty');
165134
}
166-
167-
export function deleteShippingAddress() {
168-
cy.visit('/my-account/address-book');
169-
cy.getByText('delete')
170-
.first()
171-
.click();
172-
cy.get('.cx-address-card--delete-mode button.btn-primary').click();
173-
cy.get('cx-global-message').contains('Address deleted successfully!');
174-
}
175-
176-
export function deletePaymentMethod() {
177-
cy.visit('/my-account/payment-details');
178-
cy.getByText('Delete')
179-
.first()
180-
.click();
181-
cy.get('.btn-primary').should('contain', 'delete');
182-
cy.get('.btn-primary').click();
183-
cy.get('.cx-payment .cx-body').then(() => {
184-
cy.get('cx-card').should('not.exist');
185-
});
186-
}

projects/storefrontapp-e2e-cypress/cypress/helpers/product-search-pricing-flow.ts

+18-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import { PRODUCT_LISTING } from './data-configuration';
22

33
export function productPricingFlow() {
4+
cy.server();
5+
cy.route('GET', '/rest/v2/electronics-spa/products/search*').as('query');
6+
cy.route(
7+
'GET',
8+
'/rest/v2/electronics-spa/products/search?fields=*&sort=price-asc*'
9+
).as('query_price_asc');
10+
411
// Click on a Category
512
cy.get('header').within(() => {
613
cy.get('.nav-link')
@@ -23,26 +30,29 @@ export function productPricingFlow() {
2330

2431
cy.get('cx-product-list-item')
2532
.first()
26-
.should('contain', 'DSC-S930');
33+
.should('contain', 'DSC-WX1');
2734

2835
// Navigate to next page
2936
cy.get('.page-item:last-of-type .page-link:first').click();
3037
cy.get('.page-item.active > .page-link').should('contain', '2');
3138

39+
cy.wait('@query');
40+
3241
cy.get('cx-product-list-item:nth-child(1)').should(
3342
'contain',
34-
'Cyber-shot W55'
43+
'PowerShot A480'
3544
);
3645

3746
// Sort by price low to high
3847
cy.get('cx-sorting .ng-select:first').ngSelect(
3948
PRODUCT_LISTING.SORTING_TYPES.BY_PRICE_ASC
4049
);
41-
cy.get('.page-item.active > .page-link').should('contain', '2');
42-
cy.get('cx-product-list-item').should('contain', 'DSC-W180');
4350

44-
// Add product to cart from search listing page
45-
cy.get('cx-add-to-cart:first button').click({ force: true });
46-
cy.get('.cx-dialog-header .close').click();
47-
cy.get('cx-mini-cart .count').should('contain', '1');
51+
cy.wait('@query_price_asc');
52+
53+
cy.get('.page-item.active > .page-link').should('contain', '2');
54+
cy.get('cx-product-list-item:first .cx-product-name').should(
55+
'contain',
56+
'DSC-W180'
57+
);
4858
}

0 commit comments

Comments
 (0)