Skip to content

Commit a83a77a

Browse files
updated Volunteer Services Playwright flow as per new UI
1 parent bbf5e38 commit a83a77a

2 files changed

Lines changed: 94 additions & 15 deletions

File tree

test-data/Volunteer-data.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ export const volunteerTestData = {
77
volunteerMatch: 'https://www.idealist.org/volunteermatch'
88
},
99

10+
1011
locators: {
11-
menuButton: 'text=Volunteer Services',
12-
menuRole: 'ul[role="menu"]',
13-
howWeOperate: 'a[href="/how-we-operate"]',
14-
collaborators: 'a[href="/collaborators"]',
15-
joinCommunity: 'text=Join the Community',
16-
volunteerMatch: 'a[href="https://www.idealist.org/volunteermatch"]'
12+
// Matches: await page.getByRole('button', { name: 'Volunteer Services' })
13+
menuButton: { role: 'button', name: 'Volunteer Services' },
14+
// Matches: await page.getByRole('menuitem', { name: 'How We Operate' })
15+
howWeOperate: { role: 'menuitem', name: 'How We Operate' },
16+
// Matches: await page.getByRole('menuitem', { name: 'Our Collaborators' })
17+
collaborators: { role: 'menuitem', name: 'Our Collaborators' },
18+
//For how we operate
19+
joinCommunityBtn: { role: 'button', name: 'Join the community' },
20+
//For our collaborators
21+
joinCommunityLink: { role: 'link', name: 'Join the community' },
22+
// Matches: await page.getByRole('link', { name: 'Volunteer Match Volunteer' })
23+
volunteerMatch: { role: 'link', name: 'Volunteer Match Volunteer' }
1724
}
1825
};

tests/Volunteer.spec.js

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
import { test, expect } from '@playwright/test';
1+
/*import { test, expect } from '@playwright/test';
22
import { volunteerTestData as data } from '../test-data';
33
44
test.describe('Volunteer Services Flow', () => {
55
6-
test.beforeEach(async ({ page }) => {
7-
await page.goto(data.urls.home);
8-
await page.waitForTimeout(1500); // see home load
9-
});
6+
test('Volunteer Services full flow', async ({ page }) => {
107
11-
const openVolunteerMenu = async (page) => {
12-
await page.getByRole('button', { name: 'Volunteer Services' }).click();
13-
await page.waitForTimeout(1500); // see dropdown open
14-
};
8+
// Go to home only once
9+
await page.goto(data.urls.home);
10+
11+
// Open Volunteer Services
12+
await page.getByRole(menuButton.role, { name: menuButton.name }).click();
13+
14+
// Go to How We Operate
15+
await page.getByRole(howWeOperate.role, { name: howWeOperate.name }).click();
16+
await expect(page).toHaveURL(data.urls.howWeOperate);
17+
18+
// Click Join Community
19+
await page.getByRole(joinCommunityBtn.role, { name: joinCommunityBtn.name }).click();
20+
await expect(page).toHaveURL(data.urls.contact);
21+
await page.waitForTimeout(1500);
1522
1623
test('How We Operate -> Contact', async ({ page }) => {
1724
@@ -60,4 +67,69 @@ test.describe('Volunteer Services Flow', () => {
6067
await newPage.close();
6168
});
6269
70+
});*/
71+
72+
import { test, expect } from '@playwright/test';
73+
import { volunteerTestData as data } from '../test-data';
74+
75+
const { menuButton, howWeOperate, collaborators, joinCommunityBtn, joinCommunityLink, volunteerMatch } = data.locators;
76+
77+
test.describe('Volunteer Services Flow', () => {
78+
79+
test.beforeEach(async ({ page }) => {
80+
await page.goto(data.urls.home);
81+
await page.waitForTimeout(1500)
82+
});
83+
84+
const openVolunteerMenu = async (page) => {
85+
//await page.goto(data.urls.home);
86+
await page.getByRole(menuButton.role, { name: menuButton.name }).click();
87+
await page.waitForTimeout(1500);
88+
};
89+
90+
91+
test('How We Operate -> Contact', async ({ page }) => {
92+
93+
await openVolunteerMenu(page);
94+
95+
await page.getByRole(howWeOperate.role, { name: howWeOperate.name }).click();
96+
97+
await expect(page).toHaveURL(data.urls.howWeOperate);
98+
await page.waitForTimeout(1500);
99+
//await page.getByRole(data.locators.joinCommunityBtn.role, { name: data.locators.joinCommunityBtn.name }).click();
100+
await page.getByRole(joinCommunityBtn.role, { name: joinCommunityBtn.name }).click();
101+
await expect(page).toHaveURL(data.urls.contact);
102+
await page.waitForTimeout(1500);
103+
});
104+
105+
test('Our Collaborators -> Contact', async ({ page }) => {
106+
107+
await openVolunteerMenu(page);
108+
109+
await page.getByRole(collaborators.role, { name: collaborators.name }).click();
110+
await expect(page).toHaveURL(data.urls.collaborators);
111+
await page.waitForTimeout(1500);
112+
113+
await page.getByRole(joinCommunityLink.role, { name: joinCommunityLink.name }).click();
114+
await expect(page).toHaveURL(data.urls.contact);
115+
await page.waitForTimeout(1500);
116+
});
117+
118+
test('Collaborators -> Volunteer Match opens new tab', async ({ page }) => {
119+
120+
await openVolunteerMenu(page);
121+
122+
await page.getByRole(collaborators.role, { name: collaborators.name }).click();
123+
124+
const newPagePromise = page.context().waitForEvent('page');
125+
await page.getByRole(volunteerMatch.role, { name: volunteerMatch.name }).click();
126+
const newPage = await newPagePromise;
127+
128+
await newPage.waitForLoadState();
129+
await expect(newPage).toHaveURL(data.urls.volunteerMatch);
130+
await page.waitForTimeout(1500);
131+
await newPage.close();
132+
});
133+
63134
});
135+

0 commit comments

Comments
 (0)