Skip to content

Commit

Permalink
chore: add admin campaign applications
Browse files Browse the repository at this point in the history
- add a login fixture
- add a test that verifies the current admin list of campaign applications
  • Loading branch information
gparlakov committed Jul 10, 2024
1 parent a795eba commit 6193054
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ PAYPAL_CLIENT_ID=sb
###########
GHOST_API_URL=https://blog.podkrepi.bg
GHOST_CONTENT_KEY=86ec17c4b9660acd66b6034682
[email protected]
PODKREPI_PASSWORD=$ecurePa33
3 changes: 1 addition & 2 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import type { PlaywrightTestConfig } from '@playwright/test'
import path from 'path'

const e2eReportsFolder = path.resolve(__dirname, 'e2e-reports')

/**
* See https://playwright.dev/docs/test-configuration
*/

const config: PlaywrightTestConfig = {
const config: PlaywrightTestConfig<{e2eReportsFolder: string, storageFile: string}> = {
name: 'Podkrepi.bg E2E tests',
testDir: './tests',
/* Maximum time one test can run for. */
Expand Down
Original file line number Diff line number Diff line change
@@ -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
})
})
30 changes: 30 additions & 0 deletions e2e/utils/fixtures.ts
Original file line number Diff line number Diff line change
@@ -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'

0 comments on commit 6193054

Please sign in to comment.