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 all 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": 10000,
"reporterOptions": {
"reporterEnabled": "spec, mocha-junit-reporter",
"mochaJunitReporterReporterOptions": {
Expand Down
Binary file removed src/assets/img/spinner.gif
Binary file not shown.
5 changes: 3 additions & 2 deletions src/assets/scss/_general.scss
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ button {
}

.img-lazy {
background: white url('../img/spinner.gif') no-repeat 50% 50%;
background: white url('../img/loading.svg') no-repeat 50% 50%;
color: $white;
display: block;
// image's height
height: 300px;
width: 100%;
}

.img-lazy-error {
Expand All @@ -196,4 +197,4 @@ button {
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
}
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
31 changes: 20 additions & 11 deletions src/components/cartdetail/PageCartDetail.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<template>
<div v-if="me"
class="cart-page container">
<div class="row">
<div class="col-sm-8 col-xs-12">
</div>
<div class="col-sm-4">
<!--{{> checkout/start-checkout-link id="cart-checkoutnow-btn"}}-->
<div class="cart-page container">
<LoadingSpinner v-if="isLoading"/>

<div v-else-if="cartNotEmpty">
<div class="row">
<div class="col-sm-8 col-xs-12">
</div>
<div class="col-sm-4">
<!--{{> checkout/start-checkout-link id="cart-checkoutnow-btn"}}-->
</div>
</div>
</div>
<div v-if="cartNotEmpty">
<div class="row">
<div class="col-sm-12">
<div class="current-in-bag">
Expand Down Expand Up @@ -54,11 +55,11 @@
</div>
</div>
</div>

<div v-else
class="empty-results-container">
<div class="empty-results">
<span
data-test="empty-cart">
<span data-test="empty-cart">
{{ $t('empty') }}
</span>
</div>
Expand All @@ -74,6 +75,7 @@
<script>
import gql from 'graphql-tag';
import cartMixin from '@/mixins/cartMixin';
import LoadingSpinner from '../common/LoadingSpinner.vue';
import CartLikeSummary from '../common/cartlike/CartLikeSummary.vue';
import LineItemDeleteForm from './LineItemDeleteForm.vue';
import LineItemQuantityForm from './LineItemQuantityForm.vue';
Expand All @@ -82,6 +84,7 @@ import DisplayableMoneyFragment from '@/components/DisplayableMoney.gql';

export default {
components: {
LoadingSpinner,
CartLikeSummary,
LineItemQuantityForm,
LineItemDeleteForm,
Expand All @@ -92,6 +95,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
14 changes: 14 additions & 0 deletions src/components/common/LoadingSpinner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<div class="loading-spinner">
<img src="../../assets/img/loading.svg"
data-test="spinner"/>
</div>
</template>

<style scoped>
.loading-spinner {
width: 100%;
text-align: center;
padding: 50px;
}
</style>
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
106 changes: 60 additions & 46 deletions src/components/productoverview/ProductList.vue
Original file line number Diff line number Diff line change
@@ -1,71 +1,83 @@
<template>
<div>
<form id="form-filter-products" name="filter-products" action="#">
<!-- {{#if content.searchTerm}}
<input type="hidden" name="q" value="{{content.searchTerm}}"/>
{{/if}}-->
<LoadingSpinner v-if="isLoading"/>

<div class="row item-list-pagination">
<!-- {{#if content.searchResult}}
<div class="search-results-row">
{{> catalog/pop/search-result searchResult=content.searchResult}}
</div>
{{else}}
<div class="jumbotron-row">
{{> catalog/pop/jumbotron jumbotron=content.jumbotron}}
</div>
<div v-else-if="categories && products">
<form v-if="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="col-xs-4 hidden-xs text-left">
<div v-if="products && products.results.length"
class="custom-select-wrapper">
<ProductSortSelector @changeSort="changeSort" />
<!--{{> catalog/pop/sort-selector sortSelector=content.sortSelector}}-->

<div class="row item-list-pagination">
<!-- {{#if content.searchResult}}
<div class="search-results-row">
{{> catalog/pop/search-result searchResult=content.searchResult}}
</div>
{{else}}
<div class="jumbotron-row">
{{> catalog/pop/jumbotron jumbotron=content.jumbotron}}
</div>
{{/if}}-->
<div class="col-xs-4 hidden-xs text-left">
<div 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}}-->
</ul>
</div>
<div class="col-xs-4 hidden-xs text-right">
<!--{{> catalog/pop/display-selector displaySelector=content.displaySelector}}-->
</div>
</div>
<div class="col-xs-4 hidden-xs text-center custom-pagination">
<ul class="page-numbers">
<!--{{> common/pagination pagination=content.pagination}}-->
</ul>
<div class="product-filter hidden-xs">
<!--{{> catalog/pop/filters-sidebar}}-->
</div>
<div class="col-xs-4 hidden-xs text-right">
<!--{{> catalog/pop/display-selector displaySelector=content.displaySelector}}-->

<div id="pop-product-list"
class="row">
<ProductThumbnail v-for="product in products.results"
data-test="product-list"
:key="product.id"
:product="product" />
</div>
</form>
<div v-else>
<div class="empty-results-container">
<span class="empty-results"
data-test="empty-results">
{{ $t('catalog.noSearchResult.searchNotFound.notFound') }}
</span>
</div>
</div>
</div>
<div class="product-filter hidden-xs">
<!--{{> catalog/pop/filters-sidebar}}-->
</div>
</form>
<div v-if="isLoading">
<img data-test="spinner" src="../../assets/img/spinner.gif"/>
</div>
<div v-else-if="products && !products.results.length">

<div v-else>
<div class="empty-results-container">
<span class="empty-results"
data-test="empty-results">
{{ $t('catalog.noSearchResult.searchNotFound.notFound') }}
data-test="category-not-found">
{{ $t('catalog.noSearchResult.searchNotFound.categoryNotFound') }}
</span>
</div>
</div>
<transition name="fade">
<div v-if="!isLoading && products && products.results.length"
id="pop-product-list"
class="row">
<ProductThumbnail v-for="product in products.results"
data-test="product-list"
:key="product.id"
:product="product" />
</div>
</transition>
</div>
</template>

<script>
import gql from 'graphql-tag';
import LoadingSpinner from '../common/LoadingSpinner.vue';
import ProductThumbnail from '../common/ProductThumbnail.vue';
import ProductSortSelector from './ProductSortSelector.vue';

export default {
components: {
LoadingSpinner,
ProductThumbnail,
ProductSortSelector,
},
Expand All @@ -79,7 +91,9 @@ export default {
}),

computed: {
category: vm => vm.categories.results[0],
category() {
return this.categories.results[0];
},

isLoading() {
return this.$apollo.loading;
Expand Down Expand Up @@ -154,7 +168,7 @@ export default {
sort: this.sort,
};
},
skip: vm => !vm.categories,
skip: vm => !vm.categories || !vm.category,
},
},
};
Expand Down
22 changes: 17 additions & 5 deletions src/components/useraccount/myorders/TabOrderList.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<template>
<div v-if="me"
class="my-orders">
<div v-if="me.orders.results.length"
class="my-orders-content">
<div class="my-orders">
<LoadingSpinner v-if="isLoading"/>

<div v-else-if="orderListNotEmpty"
class="my-orders-content">
<div class="my-orders-table-wrapper">
<div class="row">
<div class="col-md-2 col-sm-3 col-xs-4">
Expand Down Expand Up @@ -90,15 +91,26 @@
import gql from 'graphql-tag';
import BaseMoney from '../../common/BaseMoney.vue';
import BaseDate from '../../common/BaseDate.vue';
import LoadingSpinner from '../../common/LoadingSpinner.vue';
import DisplayableMoneyFragment from '@/components/DisplayableMoney.gql';

export default {
components: { BaseMoney, BaseDate },
components: { BaseMoney, BaseDate, LoadingSpinner },

data: () => ({
me: null,
}),

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

orderListNotEmpty() {
return this.me?.orders?.results.length > 0;
},
},

methods: {
translateStatus(state) {
return state ? this.$t(state) : '-';
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ catalog:
noSearchResult:
searchNotFound:
title: "Suchergebnisse"
notFound: "Keine Ergebnisse Gefunden."
notFound: "Keine Ergebnisse Gefunden"
categoryNotFound: "Kategorie nicht gefunden"
keyword: null
description: "Es gab leider keine Treffer für Ihre Suche nach \"xxxxx\". Prüfe die Schreibweise oder suche nach einem Synonym."
popularSearchPhrases:
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ catalog:
noSearchResult:
searchNotFound:
title: "Search Results"
notFound: "No Results Found."
notFound: "No Results Found"
categoryNotFound: "Category Not Found"
keyword: "zero"
description: "Search was unable to find any results for \"Batman\", you may have typed your word incorrectly, or are being too specific. Try using a broader search phrase or try one of our most popular search phrases."
popularSearchPhrases:
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
Loading