diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 32dd6ac42..86d6b98e1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -2,14 +2,6 @@ name: End-to-end on: [push, pull_request] -env: - BASE_CANONICAL_URL: ${{ vars.BASE_CANONICAL_URL }} - API_HOST_CLIENT: ${{ vars.API_HOST_CLIENT }} - API_HOST_SERVER: ${{ vars.API_HOST_SERVER }} - COOKIE_SECRET: ${{ secrets.COOKIE_SECRET }} - ADS_SESSION_COOKIE_NAME: ${{ vars.ADS_SESSION_COOKIE_NAME }} - SCIX_SESSION_COOKIE_NAME: ${{ vars.SCIX_SESSION_COOKIE_NAME }} - jobs: unit-tests: timeout-minutes: 60 @@ -54,6 +46,12 @@ jobs: e2e-tests: timeout-minutes: 60 runs-on: ubuntu-latest + env: + CI: true + BASE_CANONICAL_URL: ${{ vars.BASE_CANONICAL_URL }} + API_HOST_CLIENT: ${{ vars.API_HOST_CLIENT }} + API_HOST_SERVER: ${{ vars.API_HOST_SERVER }} + COOKIE_SECRET: ${{ vars.COOKIE_SECRET }} strategy: matrix: node-version: [ 18 ] @@ -78,6 +76,15 @@ jobs: - name: Install Playwright Browsers run: pnpm exec playwright install --with-deps + - name: setup environment variables + run: | + touch .env.local + echo "CI=${{ env.CI }}" >> .env.local + echo "BASE_CANONICAL_URL=${{ env.BASE_CANONICAL_URL }}" >> .env.local + echo "API_HOST_CLIENT=${{ env.API_HOST_CLIENT }}" >> .env.local + echo "API_HOST_SERVER=${{ env.API_HOST_SERVER }}" >> .env.local + echo "COOKIE_SECRET=${{ env.COOKIE_SECRET }}" >> .env.local + - name: Run integration tests run: pnpm integration diff --git a/playwright.config.ts b/playwright.config.ts index 570cb4e47..e752e4c49 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,11 +1,5 @@ import { defineConfig, devices } from '@playwright/test'; -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// require('dotenv').config(); - /** * See https://playwright.dev/docs/test-configuration. */ @@ -48,32 +42,20 @@ export default defineConfig({ name: 'webkit', use: { ...devices['Desktop Safari'] }, }, - - /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, - - /* Test against branded browsers. */ - // { - // name: 'Microsoft Edge', - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, - // }, - // { - // name: 'Google Chrome', - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, - // }, ], - - /* Run your local dev server before starting the tests */ webServer: { - command: 'pnpm run dev:mocks', - url: 'http://localhost:8000', + env: { + BASE_CANONICAL_URL: process.env.BASE_CANONICAL_URL || 'https://ui.adsabs.harvard.edu', + API_HOST_CLIENT: process.env.API_HOST_CLIENT || 'https://devapi.adsabs.harvard.edu/v1', + API_HOST_SERVER: process.env.API_HOST_SERVER || 'https://devapi.adsabs.harvard.edu/v1', + COOKIE_SECRET: process.env.COOKIE_SECRET || 'secret', + ADS_SESSION_COOKIE_NAME: process.env.ADS_SESSION_COOKIE_NAME || 'session', + SCIX_SESSION_COOKIE_NAME: process.env.SCIX_SESSION_COOKIE_NAME || 'scix_session', + }, + command: 'pnpm run dev', + port: 8000, + // 5 minute timeout + timeout: 300000, reuseExistingServer: !process.env.CI, }, });