Skip to content

Commit a7e2098

Browse files
committed
tests
1 parent 9e4aa8e commit a7e2098

1 file changed

Lines changed: 29 additions & 10 deletions

File tree

e2e/donate.test.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
import { expect, test } from '@playwright/test';
2+
import { expectH1AndTitle } from './lib/lib';
23

34
test.beforeEach(async ({ page }) => {
45
await page.goto('/donate/');
56
});
67

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+
});
1115
});
1216

13-
test('donation buttons are present', async ({ page }) => {
17+
test('donation CTAs work', async ({ page }) => {
1418
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+
},
1831
];
1932

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();
2241
}
2342
});
2443
});

0 commit comments

Comments
 (0)