Skip to content

Commit

Permalink
Merge pull request #3047 from Codeinwp/cypress/storybook-tests
Browse files Browse the repository at this point in the history
test: adds tests for Storybook components
  • Loading branch information
selul authored Sep 3, 2021
2 parents 6b23ce3 + d17ca42 commit 7571df1
Show file tree
Hide file tree
Showing 32 changed files with 1,664 additions and 19 deletions.
32 changes: 24 additions & 8 deletions .github/workflows/e2e-storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ on:

jobs:
e2e-storybook:
strategy:
fail-fast: false
matrix:
# run 3 copies of the current job in parallel
containers: [1, 2, 3]
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/[email protected]
with:
persist-credentials: false
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -27,12 +30,25 @@ jobs:
- name: Build Cypress
working-directory: ./e2e-tests
run: yarn install --frozen-lockfile
- name: Install and Build 🔧
- name: Start Storybook
run: |
yarn install --frozen-lockfile
yarn run build
yarn storybook &
- name: E2E Tests 🚀
working-directory: ./e2e-tests
run: |
yarn run cypress:storybook:run --record --key=${{ secrets.CYPRESS_RECORD_KEY }}
- name: Run Storybook Cypress tests 🚀 - ${{ matrix.container }}
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
uses: cypress-io/github-action@v2
with:
working-directory: ./e2e-tests
env: host=localhost,port=6006
browser: chrome
headless: true
parallel: true
group: e2e-storybook
config-file: cypress.storybook.json
record: true
spec: cypress/integration/storybook/**/*,
14 changes: 8 additions & 6 deletions e2e-tests/cypress.storybook.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"projectId": "d8fiqf",
"baseUrl": "http://localhost:6006",
"retries": 1,
"videoUploadOnPasses": false,
"numTestsKeptInMemory": 0,
"integrationFolder": "cypress/integration/storybook"
"projectId": "d8fiqf",
"baseUrl": "http://localhost:6006",
"retries": 1,
"videoUploadOnPasses": false,
"numTestsKeptInMemory": 0,
"watchForFileChanges": false,
"integrationFolder": "cypress/integration/storybook",
"experimentalStudio": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
{
"allOptions": [
{
"name": "Current Single Title",
"value": "{current_single_title}"
},
{
"name": "Current Single Excerpt",
"value": "{current_single_excerpt}"
},
{
"name": "Current Single URL",
"value": "{current_single_url}"
},
{
"name": "Current Post Meta",
"value": "{current_post_meta}"
},
{
"name": "Author meta",
"value": "{meta_author}"
},
{
"name": "Date meta",
"value": "{meta_date}"
},
{
"name": "Category meta",
"value": "{meta_category}"
},
{
"name": "Comments meta",
"value": "{meta_comments}"
},
{
"name": "Author meta",
"value": "{meta_author}"
},
{
"name": "Time to read meta",
"value": "{meta_time_to_read}"
},
{
"name": "Archive Description",
"value": "{archive_description}"
},

{
"name": "Archive Title",
"value": "{archive_title}"
},
{
"name": "Archive URL",
"value": "{archive_url}"
},
{
"name": "Author Bio",
"value": "{author_bio}"
},
{
"name": "Author Name",
"value": "{author_name}"
},
{
"name": "Author URL",
"value": "{author_url}"
},
{
"name": "Site Title",
"value": "{site_title}"
},
{
"name": "Site Tagline",
"value": "{site_tagline}"
},
{
"name": "Home URL",
"value": "{home_url}"
},
{
"name": "Current Year",
"value": "{current_year}"
},
{
"name": "Total + Currency Symbol",
"value": "{cart_total_currency_symbol}"
},
{
"name": "Total",
"value": "{cart_total}"
},
{
"name": "Currency Name",
"value": "{currency_name}"
},
{
"name": "Currency Symbol",
"value": "{currency_symbol}"
},
{
"name": "Product Price",
"value": "{product_price}"
},
{
"name": "Product Title",
"value": "{product_title}"
},
{
"name": "Cart URL",
"value": "{cart_link}"
},
{
"name": "Checkout URL",
"value": "{checkout_link}"
}
],
"onlyUrl": [
{
"name": "Current Single URL",
"value": "{current_single_url}"
},
{
"name": "Archive URL",
"value": "{archive_url}"
},
{
"name": "Author URL",
"value": "{author_url}"
},
{
"name": "Home URL",
"value": "{home_url}"
},
{
"name": "Cart URL",
"value": "{cart_link}"
},
{
"name": "Checkout URL",
"value": "{checkout_link}"
}
],
"noUrl": [
{
"name": "Current Single Title",
"value": "{current_single_title}"
},
{
"name": "Current Single Excerpt",
"value": "{current_single_excerpt}"
},
{
"name": "Current Post Meta",
"value": "{current_post_meta}"
},
{
"name": "Author meta",
"value": "{meta_author}"
},
{
"name": "Date meta",
"value": "{meta_date}"
},
{
"name": "Category meta",
"value": "{meta_category}"
},
{
"name": "Comments meta",
"value": "{meta_comments}"
},
{
"name": "Author meta",
"value": "{meta_author}"
},
{
"name": "Time to read meta",
"value": "{meta_time_to_read}"
},
{
"name": "Archive Description",
"value": "{archive_description}"
},

{
"name": "Archive Title",
"value": "{archive_title}"
},
{
"name": "Author Bio",
"value": "{author_bio}"
},
{
"name": "Author Name",
"value": "{author_name}"
},
{
"name": "Site Title",
"value": "{site_title}"
},
{
"name": "Site Tagline",
"value": "{site_tagline}"
},
{
"name": "Current Year",
"value": "{current_year}"
},
{
"name": "Total + Currency Symbol",
"value": "{cart_total_currency_symbol}"
},
{
"name": "Total",
"value": "{cart_total}"
},
{
"name": "Currency Name",
"value": "{currency_name}"
},
{
"name": "Currency Symbol",
"value": "{currency_symbol}"
},
{
"name": "Product Price",
"value": "{product_price}"
},
{
"name": "Product Title",
"value": "{product_title}"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
describe('Accordion', function () {
before(function () {
beforeEach(function () {
cy.visitStorybook();
});

it('Initially Opened', function () {
cy.loadStory('Customizer/Controls/Accordion', 'Initially Opened');

cy.get('.nv-accordion').should('have.class', 'expanded');
cy.get('.accordion-content').should('exist');
cy.get('.accordion-content');

cy.get('.nv-accordion').click();
cy.get('.nv-accordion').should('not.have.class', 'expanded');
Expand All @@ -22,7 +22,7 @@ describe('Accordion', function () {

cy.get('.nv-accordion').click();
cy.get('.nv-accordion').should('have.class', 'expanded');
cy.get('.accordion-content').should('exist');
cy.get('.accordion-content');
});

it('Label Works', function () {
Expand Down
Loading

0 comments on commit 7571df1

Please sign in to comment.