add cypress tests and refactor search interface #1
This file contains hidden or 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
| name: Cypress E2E Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| jobs: | |
| cypress-run: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| # Run tests in parallel across multiple containers | |
| containers: [1, 2, 3, 4] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build application | |
| run: npm run build | |
| - name: Create test environment file | |
| run: | | |
| echo "JELLYFIN_SERVER_URL=http://localhost:8096" > .env.local | |
| echo "JELLYFIN_API_KEY=test-api-key" >> .env.local | |
| echo "JELLYFIN_USERNAME=test-user" >> .env.local | |
| echo "NODE_ENV=test" >> .env.local | |
| - name: Run Cypress tests | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| build: npm run build | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| wait-on-timeout: 120 | |
| browser: chrome | |
| record: true | |
| parallel: true | |
| group: 'E2E Tests' | |
| env: | |
| # Pass the Dashboard record key as an environment variable | |
| CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
| # GitHub token for Cypress Dashboard | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Commit info for Cypress Dashboard | |
| COMMIT_INFO_MESSAGE: ${{ github.event.head_commit.message }} | |
| COMMIT_INFO_SHA: ${{ github.sha }} | |
| - name: Upload screenshots on failure | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cypress-screenshots-${{ matrix.containers }} | |
| path: cypress/screenshots | |
| retention-days: 7 | |
| - name: Upload videos on failure | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: cypress-videos-${{ matrix.containers }} | |
| path: cypress/videos | |
| retention-days: 7 | |
| # Separate job for component tests | |
| cypress-component: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run Cypress component tests | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| component: true | |
| browser: chrome | |
| # Job to run specific test suites | |
| cypress-suites: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| suite: [mobile, admin, tv, integration] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build application | |
| run: npm run build | |
| - name: Create test environment file | |
| run: | | |
| echo "JELLYFIN_SERVER_URL=http://localhost:8096" > .env.local | |
| echo "JELLYFIN_API_KEY=test-api-key" >> .env.local | |
| echo "JELLYFIN_USERNAME=test-user" >> .env.local | |
| echo "NODE_ENV=test" >> .env.local | |
| - name: Run Mobile Interface Tests | |
| if: matrix.suite == 'mobile' | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| command: npm run test:e2e:mobile | |
| browser: chrome | |
| - name: Run Admin Interface Tests | |
| if: matrix.suite == 'admin' | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| command: npm run test:e2e:admin | |
| browser: chrome | |
| - name: Run TV Interface Tests | |
| if: matrix.suite == 'tv' | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| command: npm run test:e2e:tv | |
| browser: chrome | |
| - name: Run Integration Tests | |
| if: matrix.suite == 'integration' | |
| uses: cypress-io/github-action@v6 | |
| with: | |
| start: npm start | |
| wait-on: 'http://localhost:3000' | |
| command: npm run test:e2e:integration | |
| browser: chrome | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: cypress-results-${{ matrix.suite }} | |
| path: | | |
| cypress/screenshots | |
| cypress/videos | |
| cypress/reports | |
| retention-days: 7 | |
| # Summary job that depends on all test jobs | |
| test-summary: | |
| runs-on: ubuntu-latest | |
| needs: [cypress-run, cypress-component, cypress-suites] | |
| if: always() | |
| steps: | |
| - name: Check test results | |
| run: | | |
| if [[ "${{ needs.cypress-run.result }}" == "failure" || | |
| "${{ needs.cypress-component.result }}" == "failure" || | |
| "${{ needs.cypress-suites.result }}" == "failure" ]]; then | |
| echo "Some tests failed" | |
| exit 1 | |
| else | |
| echo "All tests passed" | |
| fi |