|
1 | 1 | import { expect, test } from '@playwright/test'; |
| 2 | +import { expectH1AndTitle } from './lib/lib'; |
2 | 3 |
|
3 | 4 | test.beforeEach(async ({ page }) => { |
4 | 5 | await page.goto('/donate/'); |
5 | 6 | }); |
6 | 7 |
|
7 | | -test.describe('Donate Page', () => { |
8 | | - test('donate page has expected content', async ({ page }) => { |
9 | | - await expect(page.locator('main h1')).toBeVisible(); |
10 | | - await expect(page).toHaveTitle(/donate/i); |
| 8 | +test.describe('Donate', () => { |
| 9 | + test('has expected content', async ({ page }) => { |
| 10 | + await expectH1AndTitle({ |
| 11 | + page, |
| 12 | + h1 : "Make a Donation", |
| 13 | + title: "Donate - Seattle Community Network" |
| 14 | + }); |
11 | 15 | }); |
12 | 16 |
|
13 | | - test('donation buttons are present', async ({ page }) => { |
| 17 | + test('donation CTAs work', async ({ page }) => { |
14 | 18 | const buttonLocators = [ |
15 | | - 'data-test=donate-paypal', |
16 | | - 'data-test=donate-gofundme', |
17 | | - 'data-test=donate-square', |
| 19 | + { |
| 20 | + linkLocator : 'data-test=donate-paypal', |
| 21 | + destLocator : 'Local Connectivity Lab' |
| 22 | + }, |
| 23 | + { |
| 24 | + linkLocator : 'data-test=donate-gofundme', |
| 25 | + destLocator : 'Local Connectivity Lab' |
| 26 | + }, |
| 27 | + { |
| 28 | + linkLocator : 'data-test=donate-square', |
| 29 | + destLocator : 'Seattle Community Network' |
| 30 | + }, |
18 | 31 | ]; |
19 | 32 |
|
20 | | - for (const locator of buttonLocators) { |
21 | | - await expect(page.locator(locator)).toBeVisible(); |
| 33 | + for (const {linkLocator, destLocator} of buttonLocators) { |
| 34 | + const cta = page.locator(linkLocator); |
| 35 | + |
| 36 | + await expect(page.locator(linkLocator)).toBeVisible(); |
| 37 | + await cta.click(); |
| 38 | + await expect(page.locator('body')).toContainText(destLocator); |
| 39 | + |
| 40 | + await page.goBack(); |
22 | 41 | } |
23 | 42 | }); |
24 | 43 | }); |
0 commit comments