-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add Playwright tests for mapper flow (#1766)
* fix(projectSlice): convert taskId to number for condition check * fix(environment): set validated taskStatus action empty array * fix(mapperFlow): mapper flow test add * feat(entityPopup): add entity popup test * fix(createprojectTest): add wait for project creation success * fix(mapperFlowTest): wrap test to testSuite * fix(e2e): update test file name * feat(02-mapper-flow): comment section test add * fix(02-mapper-flow): add visual comparision test step for task status comparision * feat(02-mapper-flow): visual comparision base snapshots * fix(03-entity-update): expect alert on map feature in odk btn click
- Loading branch information
Showing
9 changed files
with
230 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test.describe('mapper flow', () => { | ||
test('mapper flow', async ({ page }) => { | ||
await page.goto('/'); | ||
// await page.goto('http://fmtm.localhost:7050/'); | ||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
await page | ||
.getByLabel('', { exact: true }) | ||
.locator('div') | ||
.filter({ hasText: "Temporary AccountIf you're" }) | ||
.nth(3) | ||
.click(); | ||
|
||
// click first project card on the home page | ||
await page.locator('.MuiCardContent-root').first().click(); | ||
|
||
// click on task | ||
await page.waitForTimeout(4000); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 445, | ||
y: 95, | ||
}, | ||
}); | ||
await expect(page.getByText('Status: READY')).toBeVisible(); | ||
await page.getByRole('alert').waitFor({ state: 'hidden' }); | ||
await page.getByTitle('Close').getByTestId('CloseIcon').click(); | ||
expect(await page.locator('canvas').screenshot()).toMatchSnapshot('ready.png'); | ||
|
||
await page.locator('canvas').click({ | ||
position: { | ||
x: 445, | ||
y: 95, | ||
}, | ||
}); | ||
// STATUS: READY | ||
await page.getByRole('button', { name: 'START MAPPING' }).waitFor({ state: 'visible' }); | ||
await page.getByRole('button', { name: 'START MAPPING' }).click(); | ||
await page.waitForSelector('div:has-text("updated status to LOCKED_FOR_MAPPING"):nth-of-type(1)'); | ||
await expect( | ||
page | ||
.locator('div') | ||
.filter({ hasText: /updated status to LOCKED_FOR_MAPPING/ }) | ||
.first(), | ||
).toBeVisible(); | ||
await page.getByRole('alert').waitFor({ state: 'hidden' }); | ||
await page.getByTitle('Close').getByTestId('CloseIcon').click(); | ||
expect(await page.locator('canvas').screenshot()).toMatchSnapshot('locked-for-mapping.png'); | ||
|
||
await page.locator('canvas').click({ | ||
position: { | ||
x: 445, | ||
y: 95, | ||
}, | ||
}); | ||
//STATUS: LOCKED_FOR_MAPPING | ||
await page.getByRole('button', { name: 'MARK AS FULLY MAPPED' }).click(); | ||
await page.getByRole('button', { name: 'MARK AS FULLY MAPPED' }).click(); | ||
await page.waitForSelector('div:has-text("updated status to MAPPED"):nth-of-type(1)'); | ||
await expect( | ||
page | ||
.locator('div') | ||
.filter({ hasText: /updated status to MAPPED/ }) | ||
.first(), | ||
).toBeVisible(); | ||
await page.getByRole('alert').waitFor({ state: 'hidden' }); | ||
await page.getByTitle('Close').getByTestId('CloseIcon').click(); | ||
expect(await page.locator('canvas').screenshot()).toMatchSnapshot('mapped.png'); | ||
|
||
await page.locator('canvas').click({ | ||
position: { | ||
x: 445, | ||
y: 95, | ||
}, | ||
}); | ||
// STATUS: MAPPED | ||
await page.getByRole('button', { name: 'START VALIDATION' }).click(); | ||
await page.getByRole('button', { name: 'FULLY MAPPED' }).click(); | ||
|
||
await page.getByText('has been updated to VALIDATED').waitFor({ state: 'visible' }); | ||
await expect(page.getByText('has been updated to VALIDATED')).toBeVisible(); | ||
|
||
// click on validated task after map renders | ||
await page.waitForTimeout(4000); | ||
expect(await page.locator('canvas').screenshot()).toMatchSnapshot('validated.png'); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 445, | ||
y: 95, | ||
}, | ||
}); | ||
await expect(page.getByText('Status: VALIDATED')).toBeVisible(); | ||
}); | ||
|
||
test('comment section', async ({ page }) => { | ||
await page.goto('/'); | ||
// await page.goto('http://fmtm.localhost:7050/'); | ||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
await page | ||
.getByLabel('', { exact: true }) | ||
.locator('div') | ||
.filter({ hasText: "Temporary AccountIf you're" }) | ||
.nth(3) | ||
.click(); | ||
|
||
// click first project card on the home page | ||
await page.locator('.MuiCardContent-root').first().click(); | ||
|
||
await page.waitForTimeout(4000); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 475, | ||
y: 127, | ||
}, | ||
}); | ||
|
||
// Assert no comment is visible | ||
await page.getByRole('button', { name: 'Comments' }).click(); | ||
await expect(page.getByText('No Comments!')).toBeVisible(); | ||
|
||
// Add comment | ||
await page.getByTestId('FormatBoldIcon').click(); | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap > p').click(); | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap').fill('Test playwright'); | ||
await page.getByRole('button', { name: 'SAVE COMMENT' }).click(); | ||
await expect( | ||
page | ||
.locator('div') | ||
.filter({ hasText: /Test playwright/ }) | ||
.first(), | ||
).toBeVisible(); | ||
|
||
// Add comment | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap > p').click(); | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap > p').click(); | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap').fill('map features accurately'); | ||
await page.getByRole('button', { name: 'SAVE COMMENT' }).click(); | ||
await expect( | ||
page | ||
.locator('div') | ||
.filter({ hasText: /map features accurately/ }) | ||
.first(), | ||
).toBeVisible(); | ||
|
||
// Save empty comment | ||
await page.locator('.fmtm-min-h-\\[150px\\] > .tiptap > p').click(); | ||
await page.getByRole('button', { name: 'SAVE COMMENT' }).click(); | ||
await page.getByRole('heading', { name: 'Empty comment field.' }).click(); | ||
await page.getByRole('alert').click(); | ||
}); | ||
}); |
Binary file added
BIN
+257 KB
...tend/e2e/02-mapper-flow.spec.ts-snapshots/locked-for-mapping-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+256 KB
src/frontend/e2e/02-mapper-flow.spec.ts-snapshots/mapped-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+255 KB
src/frontend/e2e/02-mapper-flow.spec.ts-snapshots/ready-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+255 KB
src/frontend/e2e/02-mapper-flow.spec.ts-snapshots/validated-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { test, expect } from '@playwright/test'; | ||
|
||
test('entity update', async ({ page }) => { | ||
await page.goto('/'); | ||
await page.getByRole('button', { name: 'Sign in' }).click(); | ||
await page | ||
.getByLabel('', { exact: true }) | ||
.locator('div') | ||
.filter({ hasText: "Temporary AccountIf you're" }) | ||
.nth(3) | ||
.click(); | ||
|
||
// click first project card on the home page | ||
await page.locator('.MuiCardContent-root').first().click(); | ||
|
||
// click on task & assert task popup visibility | ||
await page.waitForTimeout(4000); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 388, | ||
y: 220, | ||
}, | ||
}); | ||
await expect(page.getByText('Status: READY')).toBeVisible(); | ||
await expect(page.getByRole('button', { name: 'START MAPPING' })).toBeVisible(); | ||
|
||
// click on entity within task & assert feature popup visibility | ||
await page.waitForTimeout(4000); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 387, | ||
y: 211, | ||
}, | ||
}); | ||
await expect(page.getByRole('heading', { name: 'Feature:' })).toBeVisible(); | ||
await expect(page.getByRole('button', { name: 'MAP FEATURE IN ODK' })).toBeEnabled(); | ||
await page.getByRole('button', { name: 'MAP FEATURE IN ODK' }).click(); | ||
await expect( | ||
page.getByRole('alert').locator('div').filter({ hasText: 'Requires a mobile phone with ODK collect' }), | ||
).toBeVisible(); | ||
|
||
// check if task status is updated to locked_for_mapping on entity map | ||
await page.waitForSelector('div:has-text("updated status to LOCKED_FOR_MAPPING"):nth-of-type(1)'); | ||
await expect( | ||
page | ||
.locator('div') | ||
.filter({ hasText: /updated status to LOCKED_FOR_MAPPING/ }) | ||
.first(), | ||
).toBeVisible(); | ||
|
||
// click on task to check if task popup has been updated | ||
await page.waitForTimeout(4000); | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 411, | ||
y: 171, | ||
}, | ||
}); | ||
|
||
// await page.getByText('Status: LOCKED_FOR_MAPPING').click(); | ||
await expect(page.getByText('Status: LOCKED_FOR_MAPPING')).toBeVisible(); | ||
|
||
// click entity to confirm task is locked | ||
await page.locator('canvas').click({ | ||
position: { | ||
x: 387, | ||
y: 211, | ||
}, | ||
}); | ||
await expect(page.getByRole('button', { name: 'MAP FEATURE IN ODK' })).toBeDisabled(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters