diff --git a/.github/workflows/pre-release-tests.yml b/.github/workflows/pre-release-tests.yml index 878d6714..7bc6ab17 100644 --- a/.github/workflows/pre-release-tests.yml +++ b/.github/workflows/pre-release-tests.yml @@ -45,8 +45,7 @@ jobs: with: # Tests are only done on one playground to avoid long testing time start: yarn local:env:react - env: playground=reactlocal - spec: cypress/integration/local-ui.spec.js + env: playground=local - uses: actions/upload-artifact@v2 if: failure() with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebec20cb..e7c69c5e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,15 +30,23 @@ jobs: uses: actions/setup-node@v2 with: node-version: "14.x" + - name: Download the latest stable version of Meilisearch + run: | + curl -L https://install.meilisearch.com | sh + chmod +x meilisearch + - name: Run Meilisearch + run: | + ./meilisearch --master-key=masterKey --no-analytics true & - name: Install dependencies - run: yarn --dev && yarn --cwd ./playgrounds/vue - - name: Run Browser tests + run: yarn --dev && yarn --cwd ./tests/env/react + - name: Setup Meilisearch Index + run: yarn local:env:setup + - name: Run local browser tests uses: cypress-io/github-action@v2 with: # Tests are only done on one playground to avoid long testing time - start: yarn playground:vue - env: playground=vue - spec: cypress/integration/search-ui.spec.js + start: yarn local:env:react + env: playground=local - uses: actions/upload-artifact@v2 if: failure() with: diff --git a/cypress.env.json b/cypress.env.json index a987b251..fb34cb6a 100644 --- a/cypress.env.json +++ b/cypress.env.json @@ -1,17 +1,5 @@ { - "react": { - "host": "http://localhost:1111" - }, - "angular": { - "host": "http://localhost:4200" - }, - "vue": { - "host": "http://localhost:8080" - }, - "javascript": { - "host": "http://localhost:2222" - }, - "reactlocal": { + "local": { "host": "http://localhost:9999" } } diff --git a/cypress/integration/local-ui.spec.js b/cypress/integration/local-ui.spec.js deleted file mode 100644 index 0c2f87ec..00000000 --- a/cypress/integration/local-ui.spec.js +++ /dev/null @@ -1,85 +0,0 @@ -const { - playground, - [playground]: { host }, -} = Cypress.env() - -const HIT_ITEM_CLASS = - playground === 'react' || playground === 'reactlocal' - ? '.ais-InfiniteHits-item' - : '.ais-Hits-item' - -describe(`${playground} playground test`, () => { - before(() => { - cy.clearCookies() - cy.visit(host) - }) - - it('Should visit the dashboard', () => { - cy.url().should('match', /http:\/\/localhost:/) - }) - - it('Contains stats', () => { - cy.contains('15 results') - }) - - it('Contains filter clear', () => { - cy.contains('Clear all filters') - }) - - it('Contains Genres', () => { - cy.contains('Action') - }) - - it('Contains searchBar', () => { - cy.get('.ais-SearchBox-input').should('have.value', '') - }) - - it('Contains Hits', () => { - cy.get(HIT_ITEM_CLASS).eq(0).contains('Counter-Strike') - cy.get(HIT_ITEM_CLASS).eq(0).contains('9.99 $') - }) - - it('Sort by recommendationCound ascending', () => { - const select = `.ais-SortBy-select` - cy.get(select).select('steam-video-games:recommendationCount:asc') - cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Deathmatch Classic') - }) - - it('Sort by default relevancy', () => { - const select = `.ais-SortBy-select` - cy.get(select).select('steam-video-games') - cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Counter-Strike') - }) - - it('click on facets', () => { - const checkbox = `.ais-RefinementList-list .ais-RefinementList-checkbox` - cy.get(checkbox).eq(1).click() - cy.get(HIT_ITEM_CLASS).eq(1).contains('Team Fortress Classic') - cy.get(HIT_ITEM_CLASS).eq(1).contains('4.99 $') - }) - - it('Search', () => { - cy.get('.ais-SearchBox-input').type('Half-Life') - cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Half-Life') - }) - - it('Unclick on facets', () => { - const checkbox = `.ais-RefinementList-list .ais-RefinementList-checkbox` - cy.get(checkbox).eq(0).click() - cy.get(HIT_ITEM_CLASS).eq(0).contains('Half-Life') - }) - - it('Placeholder Search', () => { - cy.get('.ais-SearchBox-input').clear() - cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Counter-Strike') - }) - - it('Paginate Search', () => { - cy.get('.ais-InfiniteHits-loadMore').click() - cy.get(HIT_ITEM_CLASS).should('have.length', 11) - }) -}) diff --git a/cypress/integration/search-ui.spec.js b/cypress/integration/search-ui.spec.js index 61f5d5e5..bdbde734 100644 --- a/cypress/integration/search-ui.spec.js +++ b/cypress/integration/search-ui.spec.js @@ -3,8 +3,7 @@ const { [playground]: { host }, } = Cypress.env() -const HIT_ITEM_CLASS = - playground === 'react' ? '.ais-InfiniteHits-item' : '.ais-Hits-item' +const HIT_ITEM_CLASS = '.ais-InfiniteHits-item' describe(`${playground} playground test`, () => { before(() => { @@ -17,20 +16,15 @@ describe(`${playground} playground test`, () => { }) it('Contains stats', () => { - if (playground === 'react') cy.contains('12,546 results') - if (playground === 'angular') cy.contains('12546 results') + cy.contains('15 results') }) it('Contains filter clear', () => { - if (playground === 'react') cy.contains('Clear all filters') - if (playground === 'angular') cy.contains('Clear refinements') + cy.contains('Clear all filters') }) it('Contains Genres', () => { - cy.contains('Genres') cy.contains('Action') - if (playground === 'react') cy.contains('5,554') - if (playground === 'angular') cy.contains('5554') }) it('Contains searchBar', () => { @@ -46,7 +40,7 @@ describe(`${playground} playground test`, () => { const select = `.ais-SortBy-select` cy.get(select).select('steam-video-games:recommendationCount:asc') cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Rag Doll Kung Fu') + cy.get(HIT_ITEM_CLASS).eq(0).contains('Deathmatch Classic') }) it('Sort by default relevancy', () => { @@ -57,28 +51,23 @@ describe(`${playground} playground test`, () => { }) it('click on facets', () => { - cy.get(HIT_ITEM_CLASS).eq(0).contains('Counter-Strike') - const checkbox = `.ais-RefinementList-list .ais-RefinementList-checkbox` cy.get(checkbox).eq(1).click() - - if (playground === 'react') cy.contains('1,939') - if (playground === 'angular') cy.contains('1939') - - cy.contains('Counter-Strike').should('not.exist') + cy.wait(1000) + cy.get(HIT_ITEM_CLASS).eq(1).contains('Team Fortress Classic') + cy.get(HIT_ITEM_CLASS).eq(1).contains('4.99 $') }) it('Search', () => { - cy.get('.ais-SearchBox-input').type('orwell') + cy.get('.ais-SearchBox-input').type('Half-Life') cy.wait(1000) - cy.get(HIT_ITEM_CLASS).eq(0).contains('Orwell') - cy.get(HIT_ITEM_CLASS).eq(0).contains('Late 2016') + cy.get(HIT_ITEM_CLASS).eq(0).contains('Half-Life') }) it('Unclick on facets', () => { const checkbox = `.ais-RefinementList-list .ais-RefinementList-checkbox` cy.get(checkbox).eq(0).click() - cy.get(HIT_ITEM_CLASS).eq(0).contains('Orwell') + cy.get(HIT_ITEM_CLASS).eq(0).contains('Half-Life') }) it('Placeholder Search', () => { @@ -88,19 +77,7 @@ describe(`${playground} playground test`, () => { }) it('Paginate Search', () => { - cy.get(HIT_ITEM_CLASS).eq(0).contains('Counter-Strike') - - if (playground === 'react') { - cy.get('.ais-InfiniteHits-loadMore').click() - cy.get(HIT_ITEM_CLASS).should('have.length', 12) - } else { - if (playground === 'vue') { - cy.get('.ais-Pagination-item').eq(3).click() - } else { - cy.get('.ais-Pagination-item--page').eq(1).click() - } - - cy.contains('Counter-Strike').should('not.exist') - } + cy.get('.ais-InfiniteHits-loadMore').click() + cy.get(HIT_ITEM_CLASS).should('have.length', 11) }) }) diff --git a/package.json b/package.json index 1d01e3fb..442dcdd6 100644 --- a/package.json +++ b/package.json @@ -8,12 +8,9 @@ "test:watch": "yarn test --watch", "test": "jest --runInBand --selectProjects dom --selectProjects node", "test:build": "yarn build && jest --runInBand --selectProjects build", - "test:e2e:all": "sh scripts/e2e.sh", - "test:e2e:local": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress run --env playground=reactlocal --spec 'cypress/integration/local-ui.spec.js'\"", - "test:e2e:local:watch": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress open --env playground=reactlocal\"", + "test:e2e": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress run --env playground=local \"", + "test:e2e:watch": "yarn local:env:setup && concurrently --kill-others -s first \"yarn local:env:react\" \"cypress open --env playground=local\"", "test:all": "yarn test:e2e:all && yarn test && test:build", - "test:e2e": "concurrently --kill-others -s first \"yarn playground:vue\" \"cypress run --env playground=vue\"", - "test:e2e:watch": "concurrently --kill-others -s first \"yarn playground:vue\" \"cypress open --env playground=vue\"", "cy:open": "cypress open", "playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve", "playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start", diff --git a/scripts/e2e.sh b/scripts/e2e.sh deleted file mode 100755 index 20849211..00000000 --- a/scripts/e2e.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -npx concurrently --kill-others -s first "yarn playground:vue" "cypress run --spec 'cypress/integration/search-ui.js'\" --env playground=vue" -npx concurrently --kill-others -s first "NODE_ENV=test yarn playground:angular" "cypress run --spec 'cypress/integration/search-ui.js'\" --env playground=angular" -npx concurrently --kill-others -s first "NODE_ENV=test yarn playground:react" "cypress run --spec 'cypress/integration/search-ui.js'\" --env playground=react" -npx concurrently --kill-others -s first "NODE_ENV=test yarn playground:javascript" "cypress run --spec 'cypress/integration/search-ui.js'\" --env playground=javascript" -yarn local:env:setup && npx concurrently --kill-others -s first \"yarn local:env:react\" \"cypress run --spec 'cypress/integration/local-ui.js'\""