Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests #163

Merged
merged 32 commits into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
28fe73a
Improve e2e tests for many components to avoid flaky tets
zeina-idris Oct 15, 2019
b74b353
add timeout to few buttons
zeina-idris Oct 15, 2019
df1ae42
Remove skip from update customer info test
zeina-idris Oct 15, 2019
1218f46
Unskip test
zeina-idris Oct 15, 2019
9e8c940
Decrease set time out in order list
zeina-idris Oct 15, 2019
f9887be
Test commit: failing e2e test
zeina-idris Oct 15, 2019
d7536e5
Improve test
zeina-idris Oct 15, 2019
85682b3
Apply test on another product in order list
zeina-idris Oct 16, 2019
84d1a13
Add set time out in cart detail page for discount code button
zeina-idris Oct 16, 2019
1caab60
Add loading spinner when loading in cart and order list
zeina-idris Oct 16, 2019
b621443
Improve if cases for loading, empty and existing pages
zeina-idris Oct 16, 2019
d1d9b5f
E2e test: add set time out to all elements that communicate with the …
zeina-idris Oct 16, 2019
bbd5a22
Merge branch development
zeina-idris Oct 21, 2019
df1ffde
Switch back to test the second order in order list
zeina-idris Oct 21, 2019
ad93275
Set timeout for empty order list
zeina-idris Oct 21, 2019
776a1db
Add createCustomer before each test
zeina-idris Oct 21, 2019
509ba63
Fix if statements for loading and empty cases
zeina-idris Nov 4, 2019
bb63dac
Remove unnecessary timeouts
zeina-idris Nov 4, 2019
b4ce14a
Reuse apollo loading query
zeina-idris Nov 5, 2019
35250da
Improve code in template so unit test doesnt fail
zeina-idris Nov 5, 2019
e8405e4
Improve test for success state button
zeina-idris Nov 5, 2019
4e922ea
Add graphqlTimeout in cypress config options
zeina-idris Nov 7, 2019
1298986
Merge branch 'development' into fix-flaky-tests
lauraluiz Nov 11, 2019
57ae03e
Organise conditionals efficiently
zeina-idris Nov 12, 2019
a2ed8d0
Improve order of conditionals
zeina-idris Nov 14, 2019
6702a95
Remove unnecessary timeouts from e2e tests
zeina-idris Nov 14, 2019
c20935a
Improve conditionals in product list component
zeina-idris Nov 15, 2019
58920c2
Improve code according to conditionals
zeina-idris Nov 15, 2019
6068057
Improve product list code and tests to handle all cases
zeina-idris Nov 21, 2019
135bd9a
Improve comditionals in cart detail page
zeina-idris Nov 21, 2019
7b021ff
Extract loading spinner and make it uniform
lauraluiz Dec 2, 2019
9ffc33d
Update cypress.json
zeina-idris Dec 2, 2019
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
1 change: 1 addition & 0 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"baseUrl": "http://localhost:8080",
"pluginsFile": "tests/e2e/plugins/index.js",
"projectId": "gfk5oj",
"graphqlTimeout": 20000,
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
"reporterOptions": {
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
Expand Down
1 change: 1 addition & 0 deletions src/assets/scss/_my-account-my-orders.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
border: 1px solid $alto;
padding: 20px;
}

.my-orders-title {
text-transform: uppercase;
font-size: 18px;
Expand Down
5 changes: 5 additions & 0 deletions src/assets/scss/_pop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
word-spacing: 0.1em;
}

.loading-spinner {
text-align: center;
padding: 50px;
}

#pop-product-list {

@media screen and (min-width: 767px) {
Expand Down
17 changes: 14 additions & 3 deletions src/components/cartdetail/PageCartDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
<!--{{> checkout/start-checkout-link id="cart-checkoutnow-btn"}}-->
</div>
</div>
<div v-if="cartNotEmpty">
<div v-if="isLoading"
class="loading-spinner">
<img data-test="spinner" src="../../assets/img/spinner.gif"/>
</div>
<div v-else-if="!isLoading && cartNotEmpty">
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
<div class="row">
<div class="col-sm-12">
<div class="current-in-bag">
Expand Down Expand Up @@ -57,9 +61,10 @@
<div v-else
class="empty-results-container">
<div class="empty-results">
<span
data-test="empty-cart">
<span data-test="empty-cart">
{{ $t('empty') }}
{{isLoading}}

zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
</span>
</div>
<div class="empty-cart-continue-shopping-btn">
Expand Down Expand Up @@ -92,6 +97,12 @@ export default {
me: null,
}),

computed: {
isLoading() {
return this.$apollo.loading;
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
},
},

mixins: [cartMixin],

apollo: {
Expand Down
1 change: 1 addition & 0 deletions src/components/common/form/LoadingButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
mode="in-out">
<span v-if="formState === 'success'"
key="success"
data-test="success-state-success"
class="state-layer">
<svg xmlns="http://www.w3.org/2000/svg"
class="check"
Expand Down
19 changes: 13 additions & 6 deletions src/components/productoverview/ProductList.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<template>
<div>
<form id="form-filter-products" name="filter-products" action="#">
<!-- {{#if content.searchTerm}}
<form v-if="!isLoading && products && products.results.length"
id="form-filter-products"
name="filter-products" action="#">
<!-- {{#if content.searchTerm}}
<input type="hidden" name="q" value="{{content.searchTerm}}"/>
{{/if}}-->

<div class="row item-list-pagination">
<!-- {{#if content.searchResult}}
<!-- {{#if content.searchResult}}
<div class="search-results-row">
{{> catalog/pop/search-result searchResult=content.searchResult}}
</div>
Expand All @@ -16,12 +18,13 @@
</div>
{{/if}}-->
<div class="col-xs-4 hidden-xs text-left">
<div v-if="products && products.results.length"
<div v-if="!isLoading && products && products.results.length"
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
class="custom-select-wrapper">
<ProductSortSelector @changeSort="changeSort" />
<!--{{> catalog/pop/sort-selector sortSelector=content.sortSelector}}-->
</div>
</div>

<div class="col-xs-4 hidden-xs text-center custom-pagination">
<ul class="page-numbers">
<!--{{> common/pagination pagination=content.pagination}}-->
Expand All @@ -35,17 +38,21 @@
<!--{{> catalog/pop/filters-sidebar}}-->
</div>
</form>
<div v-if="isLoading">

<div v-else-if="isLoading"
class="loading-spinner">
<img data-test="spinner" src="../../assets/img/spinner.gif"/>
</div>
<div v-else-if="products && !products.results.length">

<div v-else-if="!isLoading && products && !products.results.length">
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
<div class="empty-results-container">
<span class="empty-results"
data-test="empty-results">
{{ $t('catalog.noSearchResult.searchNotFound.notFound') }}
</span>
</div>
</div>

<transition name="fade">
<div v-if="!isLoading && products && products.results.length"
id="pop-product-list"
Expand Down
14 changes: 13 additions & 1 deletion src/components/useraccount/myorders/TabOrderList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>
<div v-if="me"
class="my-orders">
<div v-if="me.orders.results.length"
<div v-if="isLoading"
class="loading-spinner">
<img data-test="spinner" src="../../../assets/img/spinner.gif"/>
</div>

<div v-else-if="!isLoading && me.orders.results.length"
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
class="my-orders-content">
<div class="my-orders-table-wrapper">
<div class="row">
Expand Down Expand Up @@ -83,6 +88,7 @@
{{ $t('emptyOrders') }}
</span>
</div>

</div>
</template>

Expand All @@ -99,6 +105,12 @@ export default {
me: null,
}),

computed: {
isLoading() {
return this.$apollo.loading;
},
},

methods: {
translateStatus(state) {
return state ? this.$t(state) : '-';
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/specs/breadcrumb_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Breadcrumb', () => {
});

it('links to each category of the breadcrumb', () => {
cy.get('[data-test=breadcrumb-home-link]', { timeout: 20000 })
cy.get('[data-test=breadcrumb-home-link]', { timeout: Cypress.config('graphqlTimeout') })
.should('contain', 'Home')
.should('have.attr', 'href', '/')
.should('not.have.class', 'active');
Expand Down
19 changes: 10 additions & 9 deletions tests/e2e/specs/cartDetailPage_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('CartDetailPage', () => {
cy.addLineItem('/product/lemare-booties-0778-brown/M0E20000000E0XM', 2);
cy.addLineItem('/product/lemare-booties-0778-grey/M0E20000000E0WX', 3);
cy.visit('/cart');
cy.get('[data-test=cart-total-items]')
cy.get('[data-test=cart-total-items]', { timeout: Cypress.config('graphqlTimeout') })
.contains(/^\s*5 items in total\s*$/);

cy.get('[data-test=cart-total-price]')
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('CartDetailPage', () => {
cy.addLineItem('/product/lemare-booties-0778-grey/M0E20000000E0WX', 3);
cy.visit('/cart');

cy.get('[data-test=cart-line-item]')
cy.get('[data-test=cart-line-item]', { timeout: Cypress.config('graphqlTimeout') })
.should('have.length', 1)
.then(($lineItem) => {
cy.wrap($lineItem)
Expand All @@ -69,7 +69,7 @@ describe('CartDetailPage', () => {
.type('5');
cy.wrap($lineItem)
.find('[data-test=cart-line-item-total-price]')
.contains(/^\s*696,50\s€\s*$/);
.contains(/^\s*696,50\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.wrap($lineItem)
.find('[data-test=cart-line-item-quantity-inc]')
Expand All @@ -80,7 +80,7 @@ describe('CartDetailPage', () => {
.should('have.value', '7');
cy.wrap($lineItem)
.find('[data-test=cart-line-item-total-price]')
.contains(/^\s*975,10\s€\s*$/);
.contains(/^\s*975,10\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.wrap($lineItem)
.find('[data-test=cart-line-item-quantity-dec]')
Expand All @@ -90,12 +90,13 @@ describe('CartDetailPage', () => {
.should('have.value', '6');
cy.wrap($lineItem)
.find('[data-test=cart-line-item-total-price]')
.contains(/^\s*835,80\s€\s*$/);
.contains(/^\s*835,80\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.wrap($lineItem)
.find('[data-test=cart-line-item-delete]').click();
});
cy.get('[data-test=cart-line-item]').should('have.length', 0);
cy.get('[data-test=cart-line-item]')
.should('have.length', 0, { timeout: Cypress.config('graphqlTimeout') });
});

const cartDiscount = {
Expand All @@ -117,21 +118,21 @@ describe('CartDetailPage', () => {
cy.visit('/cart');

cy.get('[data-test=cart-line-item-total-price]')
.contains(/^\s*199,00\s€\s*$/);
.contains(/^\s*199,00\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.get('[data-test=discount-code-input]')
.type('SUNRISE_CI');
cy.get('[data-test=apply-discount-code-button]')
.click();
cy.get('[data-test=cart-total-price]')
.contains(/^\s*99,50\s€\s*$/);
.contains(/^\s*99,50\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.get('[data-test=discount-code-name]')
.contains('SUNRISE_CI');
cy.get('[data-test=remove-discount-button]')
.click();

cy.get('[data-test=cart-line-item-total-price]')
.contains(/^\s*199,00\s€\s*$/);
.contains(/^\s*199,00\s€\s*$/, { timeout: Cypress.config('graphqlTimeout') });
});
});
2 changes: 1 addition & 1 deletion tests/e2e/specs/categoriesMenu_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Categories menu', () => {
});

it('links to any level category', () => {
cy.get('[data-test=category-1st-level]', { timeout: 20000 })
cy.get('[data-test=category-1st-level]', { timeout: Cypress.config('graphqlTimeout') })
.eq(1)
.then(($menu) => {
cy.wrap($menu)
Expand Down
10 changes: 6 additions & 4 deletions tests/e2e/specs/locationSelector_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ describe('Location selector', () => {
it('changes text to selected language', () => {
cy.changeLanguage('Deutsch');

cy.get('[data-test=product-name]').should('contain', 'Stiefeletten Lemare grau');
cy.get('[data-test=stores-link]').should('contain', 'Filiale');
cy.get('[data-test=product-name]')
.should('contain', 'Stiefeletten Lemare grau', { timeout: Cypress.config('graphqlTimeout') });
cy.get('[data-test=stores-link]')
.should('contain', 'Filiale');

cy.changeLanguage('English');

cy.get('[data-test=product-name]').should('contain', 'Booties Lemare grey');
cy.get('[data-test=product-name]')
.should('contain', 'Booties Lemare grey', { timeout: Cypress.config('graphqlTimeout') });
cy.get('[data-test=stores-link]').should('contain', 'Stores');
});

Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/specs/login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ describe('Login', () => {
};

it('logs in', () => {
cy.createCustomer(customer);
cy.login(customer);
cy.location('pathname').should('eq', '/user/account');
cy.location('pathname').should('eq', '/user/account', { timeout: Cypress.config('graphqlTimeout') });
cy.checkCustomerIsLoggedIn(customer);

cy.reload();
cy.location('pathname').should('eq', '/user/account');
cy.location('pathname').should('eq', '/user/account', { timeout: Cypress.config('graphqlTimeout') });
cy.checkCustomerIsLoggedIn(customer);

cy.get('[data-test=logout-button]').click();
cy.location('pathname').should('eq', '/login');
cy.location('pathname').should('eq', '/login', { timeout: Cypress.config('graphqlTimeout') });
cy.get('[data-test=login-button]').should('exist');
cy.get('[data-test=logout-button]').should('not.exist');
cy.get('[data-test=login-info-name]').should('not.exist');
Expand Down
21 changes: 11 additions & 10 deletions tests/e2e/specs/miniCart_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ describe('MiniCart', () => {
localStorage.removeItem('auth');
cy.visit('/');
});

it('links to shopping cart', () => {
cy.get('[data-test=mini-cart-open-button]')
.click()
.should('have.attr', 'href', '/cart');
.should('have.attr', 'href', '/cart', { timeout: Cypress.config('graphqlTimeout') });
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
});

it('displays content of cart', () => {
cy.get('[data-test=mini-cart-open-button]', { timeout: 20000 })
.contains(/^\s*Cart\s*0\s*$/);
cy.get('[data-test=mini-cart-open-button]')
.contains(/^\s*Cart\s*0\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.addLineItem('/product/lemare-booties-0778-brown/M0E20000000E0XM', 2);
cy.get('[data-test=mini-cart-open-button]', { timeout: 20000 })
.contains(/^\s*Cart\s*2\s*$/);
cy.get('[data-test=mini-cart-open-button]')
.contains(/^\s*Cart\s*2\s*$/, { timeout: Cypress.config('graphqlTimeout') });

cy.addLineItem('/product/lemare-booties-0778-grey/M0E20000000E0WX', 3);
cy.get('[data-test=mini-cart-open-button]')
.contains(/^\s*Cart\s*5\s*$/)
.contains(/^\s*Cart\s*5\s*$/, { timeout: Cypress.config('graphqlTimeout') })
.trigger('mouseenter');

cy.get('[data-test=mini-cart-price]')
Expand Down Expand Up @@ -47,7 +48,7 @@ describe('MiniCart', () => {
.eq(1)
.click();
cy.get('[data-test=mini-cart-open-button]')
.contains(/^\s*Cart\s*3\s*$/)
.contains(/^\s*Cart\s*3\s*$/, { timeout: Cypress.config('graphqlTimeout') })
.click();
cy.get('[data-test=mini-cart-content]')
.find('[data-test=mini-cart-line-item]')
Expand All @@ -59,9 +60,9 @@ describe('MiniCart', () => {
cy.get('[data-test=mini-cart-content]').should('not.be.visible');

cy.addLineItem('/product/lemare-booties-0778-brown/M0E20000000E0XM', 2);
cy.get('[data-test=mini-cart-content]')
.should('be.visible')
.wait(3000)
cy.get('[data-test=mini-cart-content]', { timeout: Cypress.config('graphqlTimeout') })
.should('be.visible');
cy.wait(3000)
.should('not.be.visible');

cy.get('[data-test=mini-cart-open-button]').trigger('mouseenter');
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/specs/orderDetail_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ describe('OrderDetailPage', () => {

before(() => {
cy.addDiscountCode(cartDiscount, 'SUNRISE_CI');
cy.createCustomer(customerDraft);
cy.login(customerDraft);
cy.createOrder(cartDraft, orderDraft);
});
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e/specs/orderList_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ describe('my orders', () => {

beforeEach(() => {
cy.visit('/');
cy.createCustomer(customer);
cy.login(customer);
});

it('shows my orders', () => {
cy.createOrder(cartDraft1, orderDraft1);
cy.createOrder(cartDraft2, orderDraft2);
cy.get('[data-test=my-orders-button]', { timeout: 20000 }).click();
cy.get('[data-test=my-orders-button]', { timeout: Cypress.config('graphqlTimeout') }).click();
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
cy.get('[data-test=order-list]')
.should('have.length', 2)
zeina-idris marked this conversation as resolved.
Show resolved Hide resolved
.eq(1)
Expand All @@ -70,9 +71,9 @@ describe('my orders', () => {
});

it('displays an empty order list message when no orders have been placed', () => {
cy.get('[data-test=my-orders-button]').click();
cy.get('[data-test=my-orders-button]', { timeout: Cypress.config('graphqlTimeout') }).click();
cy.get('[data-test=order-list]')
.should('have.length', 0);
.should('have.length', 0, { timeout: Cypress.config('graphqlTimeout') });
cy.get('[data-test=empty-order-list]')
.contains('You have not placed any orders yet!');
});
Expand Down
Loading