Skip to content

Commit

Permalink
Improve location selector e2e test with open/close testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lauraluiz committed Sep 4, 2019
1 parent b149dd4 commit ecaa244
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions tests/e2e/specs/locationSelector_spec.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
describe('Location selector', () => {
context('with initial DE', () => {
beforeEach(() => {
localStorage.setItem('locale', 'de');
cy.visit('/product/lemare-booties-0778-grey/M0E20000000E0WX');
});

it('changes text to EN', () => {
cy.get('[data-test=product-name]').should('contain', 'Stiefeletten Lemare grau');
cy.get('[data-test=stores-link]').should('contain', 'Filiale');

cy.get('[data-test=location-selector-open-button]').click();
cy.get('span[data-test=location-selector-dropdown]')
.click()
.parent()
.contains('English')
.click()
.should(() => {
expect(localStorage.getItem('locale')).to.eq('en');
});

cy.get('[data-test=product-name]').should('contain', 'Booties Lemare grey');
cy.get('[data-test=stores-link]').should('contain', 'Stores');

cy.get('span[data-test=location-selector-dropdown]')
.parent()
.should('exist')
.trigger('mouseleave')
.should('not.exist');
});
beforeEach(() => {
cy.visit('/product/lemare-booties-0778-grey/M0E20000000E0WX');
});

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.changeLanguage('English');

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

it('opens and closes location selector', () => {
cy.changeLanguage('Deutsch');
cy.get('span[data-test=location-selector-dropdown]')
.parent()
.should('not.exist');

cy.get('[data-test=location-selector-open-button]').click();
cy.get('span[data-test=location-selector-dropdown]')
.parent()
.should('exist')
.trigger('mouseleave')
.should('not.exist');

cy.get('[data-test=location-selector-open-button]').click();
cy.get('span[data-test=location-selector-dropdown]')
.parent()
.should('exist');

cy.get('[data-test=location-selector-open-button]').click();
cy.get('span[data-test=location-selector-dropdown]')
.parent()
.should('not.exist');
});
});

0 comments on commit ecaa244

Please sign in to comment.