Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"pre-commit": "yarn format && yarn lint && yarn ts && yarn test && yarn build",
"playwright:run": "yarn run playwright test playwright/e2e",
"playwright:debug": "yarn run playwright test playwright/e2e --debug",
"playwright:demo": "SLOW_MO=750 yarn run playwright test playwright/e2e --headed",
"playwright:demo": "SLOW_MO=750 TIMEOUT=600000 yarn run playwright test playwright/e2e --headed",
"test:e2e": "NODE_OPTIONS=--max-old-space-size=16384 REACT_APP_TERRAWARE_TIER=test start-server-and-test start http://127.0.0.1:3000 playwright:run",
"dump:local": "./scripts/dump.sh local",
"dump:docker": "./scripts/dump.sh docker",
Expand Down
6 changes: 2 additions & 4 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@ export default defineConfig({
// Folder for test artifacts such as screenshots, videos, traces, etc.
outputDir: './playwright/test-results',

/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests. */
workers: 1,
workers: process.env.CI ? 1 : 4,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand All @@ -34,7 +32,7 @@ export default defineConfig({
slowMo: parseInt(process.env.SLOW_MO || '0'),
},
},
testMatch: 'test.list.ts',
timeout: process.env.CI ? 60000 : parseInt(process.env.TIMEOUT || '15000'),

/* Configure projects for major browsers */
projects: process.env.CI
Expand Down
239 changes: 129 additions & 110 deletions playwright/e2e/suites/accession.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { expect, test } from '@playwright/test';

import { changeToSuperAdmin } from '../utils/userUtils';
import { exactOptions, waitFor } from '../utils/utils';

test.setTimeout(60000);
test.beforeEach(async ({ context }, testInfo) => {
await changeToSuperAdmin(context);
});
import { exactOptions, selectOrg, waitFor } from '../utils/utils';

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

export default function AccessionTests() {
test('Add An Accession', async ({ page }, testInfo) => {
await page.goto('http://127.0.0.1:3000');
test.describe('AccessionTests', () => {
// Skip the withdraw tests if the first test fails (Add An Accession)
test.describe.configure({ mode: 'serial' });

let accessionId = 'UNSET';
test.beforeEach(async ({ page, context }, testInfo) => {
await changeToSuperAdmin(context);
await page.goto('http://127.0.0.1:3000');
await waitFor(page, '#home');
await selectOrg(page, 'Terraformation (staging)');
});

test('Add An Accession', async ({ page }, testInfo) => {
await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();
await page.getByRole('button', { name: 'Add Accession' }).click();
Expand All @@ -42,7 +42,7 @@ export default function AccessionTests() {
await page.locator('#gpsCoords1').getByRole('textbox').fill('8, 8dfdsf');
await page.locator('#location').getByRole('img').click();
await page.getByText('garage').click();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByRole('button', { name: 'Save' }).click({ delay: 50 });

const accessionPrefix = `${yearId}-1-2-00`;
await expect(page.getByRole('main')).toContainText(accessionPrefix);
Expand Down Expand Up @@ -112,7 +112,7 @@ export default function AccessionTests() {

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

accessionRow = (
const accessionRow = (
await page
.getByText(accessionId)
.locator('../..')
Expand All @@ -124,101 +124,120 @@ export default function AccessionTests() {
await expect(page.getByRole('main')).toContainText('Coconut');
});

test('Withdraw to Nursery by seed count', async ({ page }, testInfo) => {
await page.goto('http://127.0.0.1:3000');

await waitFor(page, '#home');

await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();
await page.locator('#destinationFacilityId').getByRole('textbox').click();
await page.getByText('Nursery', exactOptions).nth(0).click();
await page.getByLabel('Seed Count', exactOptions).check();
await page.locator('#withdrawnQuantity').getByRole('textbox').fill('300');
await page.getByRole('button', { name: 'Add Notes' }).click();
await page.locator('textarea').fill('Adding some test notes here!');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('195 Grams');
await expect(page.getByRole('main')).toContainText('~195 ct');
await page.getByRole('tab', { name: 'History' }).click();
await expect(page.getByLabel('History')).toContainText(
'Super Admin withdrew 300 seeds for nurseryAdding some test notes here!'
);
await page.getByRole('button', { name: 'Seedlings' }).click();
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
await expect(page.locator('#row1-species_scientificName')).toContainText('Coconut');
await expect(page.locator('#row1-facilityInventories')).toContainText('Nursery');
await expect(page.locator('#row1-germinatingQuantity')).toContainText('300');
await page.getByRole('tab', { name: 'By Nursery' }).click();
await expect(page.locator('#row1-facility_name')).toContainText('Nursery');
await page.getByRole('tab', { name: 'By Batch' }).click();
await expect(page.locator('#row1-batchNumber')).toContainText('2-1-002');
});

test('Withdraw to Outplant', async ({ page }, testInfo) => {
await page.goto('http://127.0.0.1:3000');

await waitFor(page, '#home');

await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();

await page.getByPlaceholder('Select...').first().click();
await page.getByText('Out-planting').click();
await page.getByLabel('Seed Count', { exact: true }).check();
await page.locator('#withdrawnQuantity').getByRole('textbox').fill('100');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('95 Grams');
await expect(page.getByRole('main')).toContainText('~95 ct');
test.describe('Withdraw Tests', () => {
test.describe.configure({ mode: 'default' });
test('Withdraw to Nursery by seed count', async ({ page }, testInfo) => {
await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();

const accessionRow = (
await page
.getByText(accessionId)
.locator('../..')
.evaluate((el) => el.id)
).replace('-accessionNumber', '');
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();
await page.locator('#destinationFacilityId').getByRole('textbox').click();
await page.getByText('Nursery', exactOptions).nth(0).click();
await page.getByLabel('Seed Count', exactOptions).check();
await page.locator('#withdrawnQuantity').getByRole('textbox').fill('300');
await page.getByRole('button', { name: 'Add Notes' }).click();
await page.locator('textarea').fill('Adding some test notes here!');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('195 Grams');
await expect(page.getByRole('main')).toContainText('~195 ct');
await page.getByRole('tab', { name: 'History' }).click();
await expect(page.getByLabel('History')).toContainText(
'Super Admin withdrew 300 seeds for nurseryAdding some test notes here!'
);
await page.getByRole('button', { name: 'Seedlings' }).click();
await page.getByRole('button', { name: 'Inventory', ...exactOptions }).click();
await page.getByText('Coconut', exactOptions).locator('../..').waitFor({ state: 'visible' });
const coconutRowNum = (
await page
.getByText('Coconut', exactOptions)
.locator('../..')
.evaluate((el) => el.id)
).replace('-species_scientificName', '');
await expect(page.locator(`#${coconutRowNum}-species_scientificName`)).toContainText('Coconut');
await expect(page.locator(`#${coconutRowNum}-facilityInventories`)).toContainText('Nursery');
await expect(page.locator(`#${coconutRowNum}-germinatingQuantity`)).toContainText('300');
await page.getByRole('tab', { name: 'By Nursery' }).click();
await expect(page.locator('#row1-facility_name')).toContainText('Nursery');
await page.getByRole('tab', { name: 'By Batch' }).click();
await expect(page.locator('#row1-batchNumber')).toContainText('2-1-002');
});

test('Withdraw to Outplant', async ({ page }, testInfo) => {
await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();

const accessionRow = (
await page
.getByText(accessionId)
.locator('../..')
.evaluate((el) => el.id)
).replace('-accessionNumber', '');
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();

await page.getByPlaceholder('Select...').first().click();
await page.getByText('Out-planting').click();
await page.getByLabel('Seed Count', { exact: true }).check();
await page.locator('#withdrawnQuantity').getByRole('textbox').fill('100');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('95 Grams');
await expect(page.getByRole('main')).toContainText('~95 ct');
});

test('Withdraw to Viability Test', async ({ page }, testInfo) => {
await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();

const accessionRow = (
await page
.getByText(accessionId)
.locator('../..')
.evaluate((el) => el.id)
).replace('-accessionNumber', '');
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();
await page.locator('.textfield-value > .tw-icon > path').first().click();
await page.getByText('Viability Testing').click();
await page.getByPlaceholder('Select...').nth(1).click();
await page.getByText('Nursery').click();
await page.locator('div:nth-child(3) > .select > .textfield-container > .textfield-value').click();
await page.getByText('Soil').click();
await page.getByPlaceholder('Select...').nth(3).click();
await page.getByText('Soak').click();
await page.locator('#withdrawnQuantity').getByRole('spinbutton').fill('20');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('75 Grams');
await expect(page.getByRole('main')).toContainText('~75 ct');
await page.getByRole('tab', { name: 'Viability Tests' }).click();
await expect(page.locator('#row1-testType')).toContainText('Nursery Germination');
await page.getByRole('table', { name: 'enhanced table' }).getByRole('img').click();
await expect(page.getByRole('main')).toContainText('Viability Result: Pending');
await expect(page.getByRole('main')).toContainText('Soil');
await expect(page.getByRole('main')).toContainText('Soak');
await expect(page.getByRole('main')).toContainText('20');
await page.getByRole('button', { name: 'Edit' }).click();
await page.getByPlaceholder('Select...').nth(1).click();
await page.getByText('Fresh').click();
await page.getByRole('button', { name: 'Add Observation' }).click();
await page.locator('#seedsGerminated').getByRole('textbox').fill('15');
await page.getByRole('button', { name: 'Save' }).click();
await page.waitForTimeout(1000); //Wait for modal to close
await page.locator('#row1-viabilityPercent').click();
await expect(page.getByRole('main')).toContainText('15');
await page.getByRole('button', { name: 'Edit' }).click();
await page.getByRole('button', { name: 'Add Observation' }).click();
await page.locator('div:nth-child(3) > div:nth-child(2) > div > .textfield > #seedsGerminated > input').fill('3');
await page.getByLabel('Mark as Complete').check();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByRole('button', { name: 'Apply Result' }).click();
await expect(page.locator('#row1-viabilityPercent')).toContainText('90%');
});
});

test('Withdraw to Viability Test', async ({ page }, testInfo) => {
await page.goto('http://127.0.0.1:3000');

await waitFor(page, '#home');

await page.getByRole('button', { name: 'Seeds' }).click();
await page.getByRole('button', { name: 'Accessions' }).click();
await page.locator(`#${accessionRow}-accessionNumber`).getByText(accessionId).click();
await page.getByRole('button', { name: 'Withdraw' }).click();
await page.locator('.textfield-value > .tw-icon > path').first().click();
await page.getByText('Viability Testing').click();
await page.getByPlaceholder('Select...').nth(1).click();
await page.getByText('Nursery').click();
await page.locator('div:nth-child(3) > .select > .textfield-container > .textfield-value').click();
await page.getByText('Soil').click();
await page.getByPlaceholder('Select...').nth(3).click();
await page.getByText('Soak').click();
await page.locator('#withdrawnQuantity').getByRole('spinbutton').fill('20');
await page.locator('#saveWithdraw').click();
await expect(page.getByRole('main')).toContainText('75 Grams');
await expect(page.getByRole('main')).toContainText('~75 ct');
await page.getByRole('tab', { name: 'Viability Tests' }).click();
await expect(page.locator('#row1-testType')).toContainText('Nursery Germination');
await page.getByRole('table', { name: 'enhanced table' }).getByRole('img').click();
await expect(page.getByRole('main')).toContainText('Viability Result: Pending');
await expect(page.getByRole('main')).toContainText('Soil');
await expect(page.getByRole('main')).toContainText('Soak');
await expect(page.getByRole('main')).toContainText('20');
await page.getByRole('button', { name: 'Edit' }).click();
await page.getByPlaceholder('Select...').nth(1).click();
await page.getByText('Fresh').click();
await page.getByRole('button', { name: 'Add Observation' }).click();
await page.locator('#seedsGerminated').getByRole('textbox').fill('15');
await page.getByRole('button', { name: 'Save' }).click();
await page.waitForTimeout(1000); //Wait for modal to close
await page.locator('#row1-viabilityPercent').click();
await expect(page.getByRole('main')).toContainText('15');
await page.getByRole('button', { name: 'Edit' }).click();
await page.getByRole('button', { name: 'Add Observation' }).click();
await page.locator('div:nth-child(3) > div:nth-child(2) > div > .textfield > #seedsGerminated > input').fill('3');
await page.getByLabel('Mark as Complete').check();
await page.getByRole('button', { name: 'Save' }).click();
await page.getByRole('button', { name: 'Apply Result' }).click();
await expect(page.locator('#row1-viabilityPercent')).toContainText('90%');
});
}
});
22 changes: 8 additions & 14 deletions playwright/e2e/suites/deliverables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ import {
verifyHomepageDeliverableStatus,
} from '../utils/participantDeliverable';
import { changeToContributor, changeToReadOnlyUser, changeToSuperAdmin } from '../utils/userUtils';
import { exactOptions, waitFor } from '../utils/utils';
import { exactOptions, selectOrg, waitFor } from '../utils/utils';

test.beforeEach(async ({ context }) => {
await changeToSuperAdmin(context);
});

export default function DeliverableTests() {
test('Deliverables tab shows up once cohort has module with deliverables', async ({ page, context }) => {
test.describe('DeliverableTests', () => {
test.beforeEach(async ({ page, context }) => {
await changeToSuperAdmin(context);
await page.goto('http://127.0.0.1:3000');
await waitFor(page, '#home');
await selectOrg(page, 'Terraformation (staging)');
});

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

Expand Down Expand Up @@ -83,9 +83,6 @@ export default function DeliverableTests() {
});

test('Questionnaire Deliverable', async ({ page }) => {
await page.goto('http://127.0.0.1:3000');
await waitFor(page, '#home');

const deliverableName = 'Phase 1 Questions';
const today = new Date();
const todayString = today.toISOString().split('T')[0];
Expand Down Expand Up @@ -293,9 +290,6 @@ export default function DeliverableTests() {
});

test('Species Deliverable', async ({ page }) => {
await page.goto('http://127.0.0.1:3000');
await waitFor(page, '#home');

const deliverableName = 'Phase 1 Species';
await verifyHomepageDeliverableStatus(deliverableName, 'Incomplete', true, 'Not Submitted', page);
await page.getByText('Deliverables', exactOptions).click();
Expand Down Expand Up @@ -355,4 +349,4 @@ export default function DeliverableTests() {
await validateSpeciesStatus('Banana', 'Update Needed', page);
await validateSpeciesStatus('Kousa Dogwood', 'Approved', page);
});
}
});
6 changes: 2 additions & 4 deletions playwright/e2e/suites/funderProjectProfile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { test } from '@playwright/test';
import { ProjectDetails, publishProjectProfile, validateProjectProfilePage } from '../utils/projectProfile';
import { changeToFunderUser, changeToSuperAdmin } from '../utils/userUtils';

test.setTimeout(20000);

export default function FunderProjectProfileTests() {
test.describe('FunderProjectProfileTests', () => {
test('Publish Project and then View Published Project', async ({ page, context }, testInfo) => {
// publish project
await changeToSuperAdmin(context);
Expand Down Expand Up @@ -52,4 +50,4 @@ export default function FunderProjectProfileTests() {

await validateProjectProfilePage(projectDetails, page);
});
}
});
Loading
Loading