Skip to content

Commit

Permalink
Hopefully fix e2e tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
bvaughn committed Mar 23, 2024
1 parent 5729348 commit b042251
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
39 changes: 35 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
name: Playwright Tests
name: Run test suites
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
jobs:
test:
generate-test-run-id:
name: Generate Test Run ID
runs-on: ubuntu-latest
steps:
- run: yarn add uuid
shell: sh
- uses: actions/github-script@v6
id: uuid
with:
result-encoding: string
script: return require("uuid").v4()
outputs:
testRunId: ${{ steps.uuid.outputs.result }}
e2e-test:
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
name: Playwright e2e tests
needs: [generate-test-run-id]
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
Expand All @@ -18,12 +34,27 @@ jobs:
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests
run: pnpm exec playwright test
run: pnpm test:e2e
env:
NEXT_PUBLIC_APP_URL: ${{ needs.preview-branch.outputs.url }}
NEXT_PUBLIC_APP_URL: ${{ github.event.deployment_status.environment_url }}
RECORD_REPLAY_TEST_RUN_ID: ${{ needs.generate-test-run-id.outputs.testRunId }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
unit-test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Install dependencies
run: npm install -g pnpm && pnpm install
- name: Run tests
run: pnpm test
12 changes: 5 additions & 7 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,13 @@ export async function middleware(request: NextRequest) {

// Require authentication for protected routes
if (pathname.startsWith("/org") || pathname.startsWith("/team")) {
// e2e tests
// Support e2e test and Support workflows
const url = new URL(nextUrl);
if (url.searchParams.has("e2e")) {
const apiKey = url.searchParams.get("apiKey");
if (apiKey) {
response.headers.set(HEADERS.accessToken, apiKey);
const apiKey = url.searchParams.get("apiKey");
if (apiKey) {
response.headers.set(HEADERS.accessToken, apiKey);

return response;
}
return response;
}

const session = await getSession(request, response);
Expand Down

0 comments on commit b042251

Please sign in to comment.