diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 9bb4f94..93e32cc 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -44,6 +44,9 @@ jobs: - name: Prepare environment run: | mkdir -p data + mkdir -p playwright/temp + mkdir -p playwright/data + chmod -R 777 playwright/temp touch .env.local echo "SERVER_IP=localhost" >> .env.local echo "DATABASE_URL=./data/zerobyte.db" >> .env.local @@ -54,21 +57,31 @@ jobs: - name: Wait for zerobyte to be ready run: | timeout 30s bash -c 'until curl -f http://localhost:4096/healthcheck; do echo "Waiting for server..." && sleep 2; done' - continue-on-error: false - name: Make playwright directory writable - run: sudo chmod -R 777 playwright + run: sudo chmod 777 playwright/data/zerobyte.db - name: Run Playwright tests run: bun run test:e2e - - name: Stop Docker Compose + - name: Dump container logs in playwright-report folder if: always() - run: docker compose down + run: | + tree playwright + docker logs zerobyte > playwright-report/container-logs.txt || true - - uses: actions/upload-artifact@v4 + - name: Debug - print content of /test-data in container + if: failure() + run: | + docker exec zerobyte /bin/ash -c "ls -la /test-data" || true + + - uses: actions/upload-artifact@v5 if: always() with: name: playwright-report path: playwright-report/ - retention-days: 30 + retention-days: 5 + + - name: Stop Docker Compose + if: always() + run: docker compose down diff --git a/e2e/0001-auth.setup.ts b/e2e/0001-auth.setup.ts index 72fb662..0908885 100644 --- a/e2e/0001-auth.setup.ts +++ b/e2e/0001-auth.setup.ts @@ -61,9 +61,9 @@ test("user can download recovery key", async ({ page }) => { const download = await downloadPromise; expect(download.suggestedFilename()).toBe("restic.pass"); - await download.saveAs("./data/restic.pass"); + await download.saveAs("./playwright/restic.pass"); - const fileContent = await fs.promises.readFile("./data/restic.pass", "utf8"); + const fileContent = await fs.promises.readFile("./playwright/restic.pass", "utf8"); expect(fileContent).toHaveLength(64); }); diff --git a/e2e/0002-backup-restore.spec.ts b/e2e/0002-backup-restore.spec.ts index cedcc7e..41adf51 100644 --- a/e2e/0002-backup-restore.spec.ts +++ b/e2e/0002-backup-restore.spec.ts @@ -5,7 +5,11 @@ import fs from "node:fs"; test.beforeAll(() => { const testDataPath = path.join(process.cwd(), "playwright", "temp"); if (fs.existsSync(testDataPath)) { - fs.rmSync(testDataPath, { recursive: true, force: true }); + for (const file of fs.readdirSync(testDataPath)) { + fs.rmSync(path.join(testDataPath, file), { recursive: true, force: true }); + } + } else { + fs.mkdirSync(testDataPath, { recursive: true }); } }); @@ -15,11 +19,7 @@ test("can backup & restore a file", async ({ page }) => { // 0. Create a test file in /test-data const testDataPath = path.join(process.cwd(), "playwright", "temp"); - if (!fs.existsSync(testDataPath)) { - fs.mkdirSync(testDataPath); - } const filePath = path.join(testDataPath, "test.json"); - fs.chmodSync(testDataPath, 0o777); fs.writeFileSync(filePath, JSON.stringify({ data: "test file" })); // 1. Create a local volume on /test-data diff --git a/playwright.config.ts b/playwright.config.ts index 7b4797d..af68399 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -5,7 +5,7 @@ export default defineConfig({ testDir: "./e2e", fullyParallel: true, forbidOnly: !!process.env.CI, - retries: process.env.CI ? 2 : 0, + retries: 0, workers: process.env.CI ? 1 : undefined, reporter: "html", use: {