diff --git a/.github/workflows/playwright_selfhost.yml b/.github/workflows/playwright_selfhost.yml new file mode 100644 index 000000000..80e295ae3 --- /dev/null +++ b/.github/workflows/playwright_selfhost.yml @@ -0,0 +1,31 @@ +name: Playwright Selfhost Tests +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Create .env file + run: cp .env.e2e .env + - name: Install dependencies + run: npm install -g pnpm && pnpm install + - name: Build Frontend App + run: pnpm build:e2e + - name: docker compose run + run: docker-compose up -d + - name: Run Playwright tests + run: pnpm exec playwright test self-host.spec.ts + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/e2e/self-host.spec.ts b/e2e/self-host.spec.ts new file mode 100644 index 000000000..c8ffc9a74 --- /dev/null +++ b/e2e/self-host.spec.ts @@ -0,0 +1,31 @@ +import util from 'node:util' + +const exec = util.promisify(require('node:child_process').exec) +import { test, expect } from '@playwright/test' + +test.beforeAll(async () => { + await exec('pnpm db:truncate') +}) + +test.describe('new install', () => { + test('show siginup page and create user, finally showing Dashboard page', async ({ + page, + }) => { + await page.goto('http://localhost:3000/') + await expect(page.getByTestId('signup-page')).toBeVisible() + await expect(page.getByTestId('signup-page')).toHaveText(/Signup/) + + // input signup form + await page.getByTestId('signup-name-input').fill('newTransitionBloger') + await page.getByTestId('signup-password-input').fill('superstroingpassword') + // sbumit + await page.getByTestId('signup-submit-btn').click() + // pageTransition /dashboard + await expect(page).toHaveURL('http://localhost:3000/dashboard') + await expect(page.locator('main h1')).toHaveText(/Dashboard/) + }) +}) + +test.afterAll(async () => { + await exec('pnpm db:reset') +})