From e95558fb51f94507c39bad69ea740c13ae83cd5f Mon Sep 17 00:00:00 2001 From: Untone Date: Sun, 4 Feb 2024 16:25:23 +0300 Subject: [PATCH] e2e --- .gitea/workflows/main.yml | 10 +++++++-- .github/workflows/node-ci.yml | 22 ++------------------ LICENSE | 2 +- package.json | 1 + tests/basic-routes.spec.ts | 39 ++++++++++++++--------------------- 5 files changed, 27 insertions(+), 47 deletions(-) diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index aad56c74..6a0b9341 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -26,6 +26,9 @@ jobs: - name: Check types run: npm run typecheck + - name: Test production build + run: npm run build + Playwright: timeout-minutes: 60 runs-on: ubuntu-latest @@ -40,10 +43,13 @@ jobs: run: npx playwright install --with-deps - name: Start Web Server - run: npm start & + run: npm start > server.log 2>&1 & + - name: Web Server startup log + run: sleep 10 && cat server.log + - name: Run Playwright tests - run: npx playwright test + run: npm run e2e - uses: actions/upload-artifact@v3 if: always() with: diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 00e5ed2d..c60516d1 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -26,23 +26,5 @@ jobs: - name: Check types run: npm run typecheck - Playwright: - timeout-minutes: 60 - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - - name: Install dependencies - run: npm ci - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 + - name: Test production build + run: npm run build diff --git a/LICENSE b/LICENSE index 2a51def1..bd093f69 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2023 Discours +Copyright (c) 2021-2024 Discours Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/package.json b/package.json index 75167868..d34f2265 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "codegen": "graphql-codegen", "deploy": "graphql-codegen && npm run typecheck && vite build && vercel", "dev": "vite", + "e2e": "npx playwright test --project=chromium", "fix": "npm run lint:code:fix && npm run lint:styles:fix", "format": "npx @biomejs/biome format src/. --write", "hygen": "HYGEN_TMPLS=gen hygen", diff --git a/tests/basic-routes.spec.ts b/tests/basic-routes.spec.ts index 67956cc4..3157458e 100644 --- a/tests/basic-routes.spec.ts +++ b/tests/basic-routes.spec.ts @@ -1,30 +1,21 @@ import { expect, test } from '@playwright/test' +const baseHost = 'https://localhost:3000' + const pagesTitles = { - 'http://localhost:3000/': 'Дискурс', - 'http://localhost:3000/feed': 'Дискурс: лента', - 'http://localhost:3000/create': 'Дискурс', - 'http://localhost:3000/about/donate': 'Дискурс: поддержка', - 'http://localhost:3000/authors': 'Дискурс: авторы', - 'http://localhost:3000/topics': 'Дискурс: темы', - 'http://localhost:3000/inbox': 'Дискурс', + '/': /Дискурс/, + '/feed': /Дискурс/, + '/create': /Дискурс/, + '/about/donate': /Дискурс/, + '/authors': /Дискурс/, + '/topics': /Дискурс/, + '/inbox': /Дискурс/, } -test('has title', async ({ page }) => { - await page.goto('http://localhost:3000/') - - // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Дискурс/) -}) - -test('check some links', async ({ page }) => { - await page.goto('http://localhost:3000/feed') - - await expect(page).toHaveTitle(/Дискурс/) - - // Click the get started link. - // await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - //await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +Object.keys(pagesTitles).forEach((res: string) => { + test(`страница ${res}`, async ({ page }) => { + await page.goto(`${baseHost}${res}`) + const title = pagesTitles[res] + await expect(page).toHaveTitle(title) + }) })