-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(os-159): added e2e tests for breadcrumbs (#6267)
* Sync `release-2.4` with `release/next` (#6237) * test(os-159): added e2e tests for breadcrumbs on category page * Update packages/commercetools/theme/tests/e2e/integration/e2e-breadcrumbs.spec.ts
- Loading branch information
1 parent
acc3e54
commit 3ca1442
Showing
6 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
packages/commercetools/theme/tests/e2e/fixtures/test-data/e2e-breadcrumbs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"Should display breadcrumbs list properly - category": { | ||
"category": "women", | ||
"expectedLength": 2 | ||
}, | ||
"Should display breadcrumbs list properly - subcategory": { | ||
"category": "women", | ||
"subcategory": "women-clothing", | ||
"expectedLength": 3 | ||
}, | ||
"Should display breadcrumbs list properly - nested subcategory": { | ||
"category": "women", | ||
"subcategory": "women-clothing-jackets", | ||
"expectedLength": 4 | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
packages/commercetools/theme/tests/e2e/integration/e2e-breadcrumbs.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import page from '../pages/factory'; | ||
|
||
const testsCases = [ | ||
'category', | ||
'subcategory', | ||
'nested subcategory' | ||
]; | ||
|
||
const breadcrumbsNames = [ | ||
'Home', | ||
'Women', | ||
'Clothing', | ||
'Jackets' | ||
]; | ||
|
||
context(['regression'], 'Breadcrumbs', () => { | ||
beforeEach(function () { | ||
cy.fixture('test-data/e2e-breadcrumbs').then((fixture) => { | ||
this.fixtures = { | ||
data: fixture | ||
}; | ||
}); | ||
}); | ||
|
||
testsCases.forEach(testCase => { | ||
it(`Should display breadcrumbs list properly - ${testCase}`, function () { | ||
const data = this.fixtures.data[this.test.title]; | ||
const category = page.category(data.category, data.subcategory); | ||
|
||
category.visit(); | ||
|
||
page.components.breadcrumbs.container.should('not.be.empty'); | ||
page.components.breadcrumbs.listItems.should('have.length', data.expectedLength); | ||
|
||
page.components.breadcrumbs.listItems.each((item, index) => { | ||
expect(item.text()).to.contain(breadcrumbsNames[index]); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/commercetools/theme/tests/e2e/pages/components/breadcrumbs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { el } from '../utils/element'; | ||
|
||
class Breadcrumbs { | ||
|
||
get container(): Cypress.Chainable { | ||
return el('breadcrumbs'); | ||
} | ||
|
||
get listItems(): Cypress.Chainable { | ||
return el('breadcrumbs', '.sf-breadcrumbs__list-item'); | ||
} | ||
} | ||
|
||
export default new Breadcrumbs(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters