Skip to content

Commit e4563ad

Browse files
committed
SW-7641 Make playwright tests run in parallel
1 parent be56739 commit e4563ad

22 files changed

+174
-289
lines changed

playwright.config.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ export default defineConfig({
1414
// Folder for test artifacts such as screenshots, videos, traces, etc.
1515
outputDir: './playwright/test-results',
1616

17-
/* Run tests in files in parallel */
18-
fullyParallel: true,
1917
/* Fail the build on CI if you accidentally left test.only in the source code. */
2018
forbidOnly: !!process.env.CI,
2119
/* Retry on CI only */
2220
retries: process.env.CI ? 2 : 0,
2321
/* Opt out of parallel tests. */
24-
workers: 1,
22+
workers: 4,
2523
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2624
reporter: 'html',
2725
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
@@ -34,7 +32,7 @@ export default defineConfig({
3432
slowMo: parseInt(process.env.SLOW_MO || '0'),
3533
},
3634
},
37-
testMatch: 'test.list.ts',
35+
timeout: 10000,
3836

3937
/* Configure projects for major browsers */
4038
projects: process.env.CI

playwright/e2e/suites/accession.spec.ts

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
import { expect, test } from '@playwright/test';
22

33
import { changeToSuperAdmin } from '../utils/userUtils';
4-
import { exactOptions, waitFor } from '../utils/utils';
5-
6-
test.setTimeout(60000);
7-
test.beforeEach(async ({ context }, testInfo) => {
8-
await changeToSuperAdmin(context);
9-
});
4+
import { exactOptions, selectOrg, waitFor } from '../utils/utils';
105

116
const yearId = new Date().getFullYear().toString().slice(-2);
12-
let accessionId = 'UNSET';
13-
let accessionRow = 'UNSET';
147

15-
export default function AccessionTests() {
16-
test('Add An Accession', async ({ page }, testInfo) => {
17-
await page.goto('http://127.0.0.1:3000');
8+
test.describe('AccessionTests', () => {
9+
let accessionId = 'UNSET';
1810

11+
test.describe.configure({ timeout: 20000 });
12+
test.beforeEach(async ({ page, context }, testInfo) => {
13+
await changeToSuperAdmin(context);
14+
await page.goto('http://127.0.0.1:3000');
1915
await waitFor(page, '#home');
16+
await selectOrg(page, 'Terraformation (staging)');
17+
});
2018

19+
test('Add An Accession', async ({ page }, testInfo) => {
2120
await page.getByRole('button', { name: 'Seeds' }).click();
2221
await page.getByRole('button', { name: 'Accessions' }).click();
2322
await page.getByRole('button', { name: 'Add Accession' }).click();
@@ -112,7 +111,7 @@ export default function AccessionTests() {
112111

113112
await page.getByRole('button', { name: 'Accessions' }).click();
114113

115-
accessionRow = (
114+
const accessionRow = (
116115
await page
117116
.getByText(accessionId)
118117
.locator('../..')
@@ -125,12 +124,15 @@ export default function AccessionTests() {
125124
});
126125

127126
test('Withdraw to Nursery by seed count', async ({ page }, testInfo) => {
128-
await page.goto('http://127.0.0.1:3000');
129-
130-
await waitFor(page, '#home');
131-
132127
await page.getByRole('button', { name: 'Seeds' }).click();
133128
await page.getByRole('button', { name: 'Accessions' }).click();
129+
130+
const accessionRow = (
131+
await page
132+
.getByText(accessionId)
133+
.locator('../..')
134+
.evaluate((el) => el.id)
135+
).replace('-accessionNumber', '');
134136
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
135137
await page.getByRole('button', { name: 'Withdraw' }).click();
136138
await page.locator('#destinationFacilityId').getByRole('textbox').click();
@@ -148,22 +150,31 @@ export default function AccessionTests() {
148150
);
149151
await page.getByRole('button', { name: 'Seedlings' }).click();
150152
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
151-
await expect(page.locator('#row1-species_scientificName')).toContainText('Coconut');
152-
await expect(page.locator('#row1-facilityInventories')).toContainText('Nursery');
153-
await expect(page.locator('#row1-germinatingQuantity')).toContainText('300');
153+
const coconutRowNum = (
154+
await page
155+
.getByText('Coconut', exactOptions)
156+
.locator('../..')
157+
.evaluate((el) => el.id)
158+
).replace('-species_scientificName', '');
159+
await expect(page.locator('#${coconutRowNum}-species_scientificName')).toContainText('Coconut');
160+
await expect(page.locator('#${coconutRowNum}-facilityInventories')).toContainText('Nursery');
161+
await expect(page.locator('#${coconutRowNum}-germinatingQuantity')).toContainText('300');
154162
await page.getByRole('tab', { name: 'By Nursery' }).click();
155163
await expect(page.locator('#row1-facility_name')).toContainText('Nursery');
156164
await page.getByRole('tab', { name: 'By Batch' }).click();
157165
await expect(page.locator('#row1-batchNumber')).toContainText('2-1-002');
158166
});
159167

160168
test('Withdraw to Outplant', async ({ page }, testInfo) => {
161-
await page.goto('http://127.0.0.1:3000');
162-
163-
await waitFor(page, '#home');
164-
165169
await page.getByRole('button', { name: 'Seeds' }).click();
166170
await page.getByRole('button', { name: 'Accessions' }).click();
171+
172+
const accessionRow = (
173+
await page
174+
.getByText(accessionId)
175+
.locator('../..')
176+
.evaluate((el) => el.id)
177+
).replace('-accessionNumber', '');
167178
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
168179
await page.getByRole('button', { name: 'Withdraw' }).click();
169180

@@ -177,12 +188,15 @@ export default function AccessionTests() {
177188
});
178189

179190
test('Withdraw to Viability Test', async ({ page }, testInfo) => {
180-
await page.goto('http://127.0.0.1:3000');
181-
182-
await waitFor(page, '#home');
183-
184191
await page.getByRole('button', { name: 'Seeds' }).click();
185192
await page.getByRole('button', { name: 'Accessions' }).click();
193+
194+
const accessionRow = (
195+
await page
196+
.getByText(accessionId)
197+
.locator('../..')
198+
.evaluate((el) => el.id)
199+
).replace('-accessionNumber', '');
186200
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
187201
await page.getByRole('button', { name: 'Withdraw' }).click();
188202
await page.locator('.textfield-value > .tw-icon > path').first().click();
@@ -221,4 +235,4 @@ export default function AccessionTests() {
221235
await page.getByRole('button', { name: 'Apply Result' }).click();
222236
await expect(page.locator('#row1-viabilityPercent')).toContainText('90%');
223237
});
224-
}
238+
});

playwright/e2e/suites/deliverables.spec.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ import {
3434
verifyHomepageDeliverableStatus,
3535
} from '../utils/participantDeliverable';
3636
import { changeToContributor, changeToReadOnlyUser, changeToSuperAdmin } from '../utils/userUtils';
37-
import { exactOptions, waitFor } from '../utils/utils';
37+
import { exactOptions, selectOrg, waitFor } from '../utils/utils';
3838

39-
test.beforeEach(async ({ context }) => {
40-
await changeToSuperAdmin(context);
41-
});
42-
43-
export default function DeliverableTests() {
44-
test('Deliverables tab shows up once cohort has module with deliverables', async ({ page, context }) => {
39+
test.describe('DeliverableTests', () => {
40+
test.describe.configure({ timeout: 20000 });
41+
test.beforeEach(async ({ page, context }) => {
42+
await changeToSuperAdmin(context);
4543
await page.goto('http://127.0.0.1:3000');
4644
await waitFor(page, '#home');
45+
await selectOrg(page, 'Terraformation (staging)');
46+
});
4747

48+
test('Deliverables tab shows up once cohort has module with deliverables', async ({ page, context }) => {
4849
const today = new Date();
4950
const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
5051

@@ -83,9 +84,6 @@ export default function DeliverableTests() {
8384
});
8485

8586
test('Questionnaire Deliverable', async ({ page }) => {
86-
await page.goto('http://127.0.0.1:3000');
87-
await waitFor(page, '#home');
88-
8987
const deliverableName = 'Phase 1 Questions';
9088
const today = new Date();
9189
const todayString = today.toISOString().split('T')[0];
@@ -293,9 +291,6 @@ export default function DeliverableTests() {
293291
});
294292

295293
test('Species Deliverable', async ({ page }) => {
296-
await page.goto('http://127.0.0.1:3000');
297-
await waitFor(page, '#home');
298-
299294
const deliverableName = 'Phase 1 Species';
300295
await verifyHomepageDeliverableStatus(deliverableName, 'Incomplete', true, 'Not Submitted', page);
301296
await page.getByText('Deliverables', exactOptions).click();
@@ -355,4 +350,4 @@ export default function DeliverableTests() {
355350
await validateSpeciesStatus('Banana', 'Update Needed', page);
356351
await validateSpeciesStatus('Kousa Dogwood', 'Approved', page);
357352
});
358-
}
353+
});

playwright/e2e/suites/funderProjectProfile.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { test } from '@playwright/test';
33
import { ProjectDetails, publishProjectProfile, validateProjectProfilePage } from '../utils/projectProfile';
44
import { changeToFunderUser, changeToSuperAdmin } from '../utils/userUtils';
55

6-
test.setTimeout(20000);
7-
8-
export default function FunderProjectProfileTests() {
6+
test.describe('FunderProjectProfileTests', () => {
97
test('Publish Project and then View Published Project', async ({ page, context }, testInfo) => {
108
// publish project
119
await changeToSuperAdmin(context);
@@ -52,4 +50,4 @@ export default function FunderProjectProfileTests() {
5250

5351
await validateProjectProfilePage(projectDetails, page);
5452
});
55-
}
53+
});

playwright/e2e/suites/fundingEntities.spec.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ import { publishProjectProfile } from '../utils/projectProfile';
66
import { changeToSuperAdmin } from '../utils/userUtils';
77
import { exactOptions } from '../utils/utils';
88

9-
test.setTimeout(20000);
10-
test.beforeEach(async ({ context }, testInfo) => {
11-
await changeToSuperAdmin(context);
12-
});
13-
149
type Funder = {
1510
name: string;
1611
email: string;
@@ -23,10 +18,14 @@ type FundingEntity = {
2318
funders?: Funder[];
2419
};
2520

26-
export default function FundingEntitiesTests() {
27-
test('Add a Funding Entity', async ({ page }, testInfo) => {
21+
test.describe('FundingEntitiesTests', () => {
22+
test.describe.configure({ timeout: 15000 });
23+
test.beforeEach(async ({ page, context }, testInfo) => {
24+
await changeToSuperAdmin(context);
2825
await navigateToFundingEntities(page);
26+
});
2927

28+
test('Add a Funding Entity', async ({ page }, testInfo) => {
3029
const newEntityName = `New Funding Entity-${new Date().getTime()}`;
3130

3231
// unpublished projects are not in projects list
@@ -69,8 +68,6 @@ export default function FundingEntitiesTests() {
6968
});
7069

7170
test('Edit a Funding Entity', async ({ page }, testInfo) => {
72-
await navigateToFundingEntities(page);
73-
7471
const updatedEntityName = `Existing Funding Entity-Updated`;
7572

7673
await page.getByText('Existing Funding Entity', exactOptions).click();
@@ -107,8 +104,6 @@ export default function FundingEntitiesTests() {
107104
});
108105

109106
test('Delete a Funding Entity', async ({ page }, testInfo) => {
110-
await navigateToFundingEntities(page);
111-
112107
await page.getByText('Funding Entity to Delete', exactOptions).click();
113108
await page.locator('#more-options').click();
114109
await page
@@ -121,7 +116,7 @@ export default function FundingEntitiesTests() {
121116
await page.waitForTimeout(1000); //Wait for funding entities list to load
122117
await expect(page.getByText('Funding Entity to Delete', exactOptions)).toBeHidden();
123118
});
124-
}
119+
});
125120

126121
async function validateFundingEntityPage(fundingEntity: FundingEntity, page: Page) {
127122
await expect(page.getByText(`Name${fundingEntity.name}`, exactOptions)).toBeVisible();

playwright/e2e/suites/inventory.spec.ts

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ import { Locator, expect, test } from '@playwright/test';
22
import { Page } from 'playwright-core';
33

44
import { changeToSuperAdmin } from '../utils/userUtils';
5-
import { exactOptions, waitFor } from '../utils/utils';
5+
import { exactOptions, selectOrg, waitFor } from '../utils/utils';
66

7-
test.setTimeout(60000);
8-
test.beforeEach(async ({ context }, testInfo) => {
9-
await changeToSuperAdmin(context);
10-
});
11-
12-
export default function InventoryTests() {
13-
test('Add A Batch (no accession)', async ({ page }, testInfo) => {
7+
test.describe('InventoryTests', () => {
8+
test.describe.configure({ timeout: 15000 });
9+
test.beforeEach(async ({ page, context }, testInfo) => {
10+
await changeToSuperAdmin(context);
1411
await page.goto('http://127.0.0.1:3000');
15-
1612
await waitFor(page, '#home');
13+
await selectOrg(page, 'Terraformation (staging)');
14+
});
15+
16+
test('Add A Batch (no accession)', async ({ page }, testInfo) => {
1717
await page.getByRole('button', { name: 'Seedlings' }).click();
1818
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
1919
await page.locator('#new-inventory').click();
@@ -61,9 +61,6 @@ export default function InventoryTests() {
6161
});
6262

6363
test('Add A Batch from an Accession', async ({ page }, testInfo) => {
64-
await page.goto('http://127.0.0.1:3000');
65-
66-
await waitFor(page, '#home');
6764
await page.getByRole('button', { name: 'Seedlings' }).click();
6865
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
6966
await page.locator('#new-inventory').click();
@@ -104,9 +101,6 @@ export default function InventoryTests() {
104101
});
105102

106103
test('Transition Status and Withdraw Dead', async ({ page }, testInfo) => {
107-
await page.goto('http://127.0.0.1:3000');
108-
109-
await waitFor(page, '#home');
110104
await page.getByRole('button', { name: 'Seedlings' }).click();
111105
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
112106
await page.getByRole('tab', { name: 'By Batch' }).click();
@@ -155,9 +149,6 @@ export default function InventoryTests() {
155149
});
156150

157151
test('Transfer Nurseries', async ({ page }, testInfo) => {
158-
await page.goto('http://127.0.0.1:3000');
159-
160-
await waitFor(page, '#home');
161152
await page.getByRole('button', { name: 'Seedlings' }).click();
162153
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
163154
await page.getByRole('tab', { name: 'By Batch' }).click();
@@ -237,9 +228,6 @@ export default function InventoryTests() {
237228
console.log(message.text());
238229
});
239230

240-
await page.goto('http://127.0.0.1:3000');
241-
242-
await waitFor(page, '#home');
243231
await page.getByRole('button', { name: 'Seedlings' }).click();
244232
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
245233
await page.getByRole('tab', { name: 'By Batch' }).click();
@@ -280,8 +268,6 @@ export default function InventoryTests() {
280268
});
281269

282270
test('Plants dashboard after outplanting', async ({ page }, testInfo) => {
283-
await page.goto('http://127.0.0.1:3000');
284-
await waitFor(page, '#home');
285271
await page.getByRole('button', { name: 'Plants' }).click();
286272
await page.getByRole('button', { name: 'Dashboard', ...exactOptions }).click();
287273
await expect(page.getByText('60')).toBeVisible();
@@ -291,9 +277,6 @@ export default function InventoryTests() {
291277
});
292278

293279
test('Withdrawals after outplanting', async ({ page }, testInfo) => {
294-
await page.goto('http://127.0.0.1:3000');
295-
await waitFor(page, '#home');
296-
297280
await page.getByRole('button', { name: 'Seedlings' }).click();
298281
await page.getByRole('button', { name: 'Withdrawals' }).click();
299282
const mapTab = page.locator('p.MuiTypography-root').filter({ hasText: 'Map', hasNotText: 'show for this' });
@@ -323,7 +306,7 @@ export default function InventoryTests() {
323306
await expect(page.getByText('Destination:Planting Site')).toBeVisible();
324307
await expect(page.getByText('Subzone:East-North')).toBeVisible();
325308
});
326-
}
309+
});
327310

328311
const getBatchNumberBySpeciesAndNursery = async (page: Page, species: string, nursery: string) => {
329312
const rowNumber = (

0 commit comments

Comments
 (0)