Skip to content

Commit

Permalink
Revert "Turn off cypress tests for now" (#114)
Browse files Browse the repository at this point in the history
Reverts #110

---------

Co-authored-by: astone123 <[email protected]>
  • Loading branch information
wweitzel and astone123 authored Aug 26, 2024
1 parent 4f10235 commit bb0939a
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 2 deletions.
44 changes: 43 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,51 @@ jobs:
name: build
- name: Run unit tests
run: bun run test
cypress-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: build
env:
CYPRESS_RECORD_KEY: ${{ secrets.TOP90_CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.0
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Restore cached dependencies
id: dependency-restore
uses: actions/cache/restore@v3
with:
path: node_modules/
key: ${{ runner.os }}-node-modules-${{ hashFiles('bun.lockb') }}
- name: Start app
run: bun start &
- name: Restore Cypress cache
id: cypress-restore
uses: actions/cache/restore@v3
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('bun.lockb') }}
- name: Install Cypress
run: bun cypress install
- name: Save Cypress cache
id: cypress-save
uses: actions/cache/save@v3
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.os }}-cypress-${{ hashFiles('bun.lockb') }}
- name: Run Cypress e2e with record
if: ${{ env.CYPRESS_RECORD_KEY }}
run: bun cypress run --e2e --record
- name: Run Cypress e2e
if: ${{ !env.CYPRESS_RECORD_KEY }}
run: bun cypress run --e2e
deploy:
name: Deploy
needs: [build, jest-tests]
needs: [build, jest-tests, cypress-tests]
if: github.ref_name == 'master'
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 3 additions & 0 deletions e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ beforeEach(() => {
cy.intercept('GET', `${Cypress.env('API_BASE_URL')}/fixtures*`, {fixture: 'fixtures'}).as(
'fixtures'
);
cy.intercept('GET', `${Cypress.env('API_BASE_URL')}/fixtures/*`, {fixture: 'fixture'}).as(
'fixture'
);
cy.intercept('GET', `${Cypress.env('API_BASE_URL')}/goals*`, {fixture: 'goals'}).as('goals');
});
2 changes: 1 addition & 1 deletion e2e/fixtures.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('fixtures', () => {
expect(loc.pathname).to.eq('/fixtures/1049002');
});

cy.wait(['@goals', '@goals']).then((interceptions) => {
cy.wait(['@goals', '@goals', '@fixture']).then((interceptions) => {
const reqQuery = JSON.parse(interceptions[1].request.query.json as string);
cy.wrap(reqQuery).its('filter').its('fixtureId').should('equal', 1049002);
});
Expand Down
35 changes: 35 additions & 0 deletions e2e/fixtures/fixture.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"fixture": {
"id": 1208518,
"referee": "",
"date": "2024-08-26T12:30:00-07:00",
"timestamp": 0,
"teams": {
"home": {
"id": 533,
"name": "Villarreal",
"aliases": null,
"code": "",
"country": "",
"founded": 0,
"national": false,
"logo": "https://media.api-sports.io/football/teams/533.png",
"createdAt": ""
},
"away": {
"id": 538,
"name": "Celta Vigo",
"aliases": null,
"code": "",
"country": "",
"founded": 0,
"national": false,
"logo": "https://media.api-sports.io/football/teams/538.png",
"createdAt": ""
}
},
"leagueId": 140,
"season": 2024,
"createdAt": "2024-08-18T15:28:13.30605Z"
}
}

0 comments on commit bb0939a

Please sign in to comment.