From 0b29465b39544232394a0706c72a3060d053a6ef Mon Sep 17 00:00:00 2001 From: Georgi Parlakov Date: Wed, 10 Jul 2024 18:20:30 +0300 Subject: [PATCH 1/2] chore: add admin campaign applications - add a login fixture - add a test that verifies the current admin list of campaign applications --- .env.local.example | 2 ++ .../campaign-application-create.spec.ts | 10 +++++++ e2e/utils/fixtures.ts | 30 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 e2e/tests/regression/campaign-application/campaign-application-create.spec.ts create mode 100644 e2e/utils/fixtures.ts diff --git a/.env.local.example b/.env.local.example index 8ec1a117f..51d784173 100644 --- a/.env.local.example +++ b/.env.local.example @@ -43,3 +43,5 @@ PAYPAL_CLIENT_ID=sb ########### GHOST_API_URL=https://blog.podkrepi.bg GHOST_CONTENT_KEY=86ec17c4b9660acd66b6034682 +PODKREPI_EMAIL=admin@podkrepi.bg +PODKREPI_PASSWORD=$ecurePa33 diff --git a/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts b/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts new file mode 100644 index 000000000..b75ffa4e9 --- /dev/null +++ b/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts @@ -0,0 +1,10 @@ +import { test, expect } from '../../../utils/fixtures' + +test.describe('Create campaign application', () => { + test('should see list of applications', async ({ page, baseURL }) => { + await page.goto(`${baseURL}/admin/campaign-applications`) + + await expect(page.getByRole('heading')).toHaveText('Кандидат Кампании') + await expect(page.getByRole('row')).toHaveCount(6); // title plus 5 rows + }) +}) diff --git a/e2e/utils/fixtures.ts b/e2e/utils/fixtures.ts new file mode 100644 index 000000000..18abae170 --- /dev/null +++ b/e2e/utils/fixtures.ts @@ -0,0 +1,30 @@ +import { test as base } from '@playwright/test' +import dotenv from 'dotenv' + +dotenv.config({path: '../.env.local'}) +dotenv.config({path: '../.env'}) + +const email = process.env.PODKREPI_EMAIL! +const password = process.env.PODKREPI_PASSWORD! + +export const test = base.extend({ + storageState: async ({ browser, baseURL }, use) => { + const page = await browser.newPage() + await page.goto(`${baseURL}/login`) + + await page.locator('[name=email]').fill(email) + await page.locator('[name=password]').fill(password) + + await page.locator('[type=submit]').click() + await page.waitForURL((url) => !url.pathname.includes('login')) + + const state = await page.context().storageState() + + await page.close() + + use(state) + }, +}) + +/** export the expect for consistency i.e. to be able to do `import { test, expect } from '../utils/fixtures'` */ +export { expect } from 'playwright/test' From a05e37dd5d7dd1d52ccd1bbcdd66236df1494dd9 Mon Sep 17 00:00:00 2001 From: Georgi Parlakov Date: Sun, 29 Sep 2024 17:29:52 +0300 Subject: [PATCH 2/2] fix: test only title of the list as no camp-applications yet --- README.md | 2 ++ .../campaign-application/campaign-application-create.spec.ts | 2 +- e2e/utils/fixtures.ts | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d156180b..3a9914eca 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,9 @@ Watch releases of this repository to be notified about future updates: ## Contributors ✨ + [![All Contributors](https://img.shields.io/badge/all_contributors-83-orange.svg?style=flat-square)](#contributors-) + Please check [contributors guide](https://github.com/podkrepi-bg/frontend/blob/master/CONTRIBUTING.md) for: diff --git a/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts b/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts index b75ffa4e9..df61cb4b4 100644 --- a/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts +++ b/e2e/tests/regression/campaign-application/campaign-application-create.spec.ts @@ -5,6 +5,6 @@ test.describe('Create campaign application', () => { await page.goto(`${baseURL}/admin/campaign-applications`) await expect(page.getByRole('heading')).toHaveText('Кандидат Кампании') - await expect(page.getByRole('row')).toHaveCount(6); // title plus 5 rows + // await expect(page.getByRole('row')).toHaveCount(1); // just title b/c no campaign applications yet }) }) diff --git a/e2e/utils/fixtures.ts b/e2e/utils/fixtures.ts index 18abae170..4b08001f4 100644 --- a/e2e/utils/fixtures.ts +++ b/e2e/utils/fixtures.ts @@ -1,8 +1,8 @@ import { test as base } from '@playwright/test' import dotenv from 'dotenv' -dotenv.config({path: '../.env.local'}) -dotenv.config({path: '../.env'}) +dotenv.config({ path: '../.env.local' }) +dotenv.config({ path: '../.env' }) const email = process.env.PODKREPI_EMAIL! const password = process.env.PODKREPI_PASSWORD!