From 6fb3d83ef324d743f3e260a12310cc65f449d14b Mon Sep 17 00:00:00 2001 From: syyspe Date: Thu, 13 Aug 2026 20:09:06 +0300 Subject: [PATCH] Fix CI env loading and flaky API token regeneration test drizzle-kit push and next dev both select .env.test vs .env.local based on process.env.NODE_ENV, but the workflow only wrote NODE_ENV into the generated .env.test file, which is too late to affect that choice. Migrations then ran against an empty DATABASE_URL. Setting NODE_ENV: test at the job level fixes both the migration step and the Playwright-driven dev server. Also replaced the fixed 500ms wait in "can regenerate API token" with an auto-retrying assertion, since the server action + revalidate round trip can exceed 500ms on slower CI runners, causing the test to read the token before the UI updates. --- .github/workflows/playwright.yml | 2 ++ tests/blog-app.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 1a0fb94..2c6c20d 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -10,6 +10,8 @@ jobs: test: timeout-minutes: 60 runs-on: ubuntu-latest + env: + NODE_ENV: test steps: - uses: actions/checkout@v4 diff --git a/tests/blog-app.spec.ts b/tests/blog-app.spec.ts index 6c62676..90e3363 100644 --- a/tests/blog-app.spec.ts +++ b/tests/blog-app.spec.ts @@ -460,8 +460,8 @@ test.describe("Blog Application", () => { // Generate new token without reloading await page.getByTestId("generate-token-button").click() - // Wait for token to potentially change - await page.waitForTimeout(500) + // Wait for the token text to actually change (server action + revalidate) + await expect(page.getByTestId("api-token")).not.toHaveText(firstToken!) const secondToken = await page.getByTestId("api-token").textContent() // Tokens should be different