mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 08:53:31 +03:00
3c31155fe9
- Implements https://github.com/enso-org/cloud-v2/issues/631 - Tests for dashboard (`app/ide-desktop/lib/dashboard/`): - End-to-end tests - Unit tests - Component tests The purpose of this PR is to introduce the testing framework - more tests can be added later in separate PRs. # Important Notes To test, run `npm run test` in `app/ide-desktop`, or `app/ide-desktop/lib/dashboard/`. All tests should pass. Individual test types can be run using `npm run test-unit`, `npm run test-component` and `npm run test-e2e` in `app/ide-desktop/lib/dashboard/`. Individual end-to-end tests can be run using `npx playwright test -c playwright-e2e.config.ts test-e2e/<file name>.spec.ts` in `app/ide-desktop/lib/dashboard/`. End-to-end tests require internet access to pass (for things like fonts). This PR *does* check in screenshots to guard against visual regessions (and/or to make visual changes obvious)
47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
/** @file Test the "change password" modal. */
|
|
import * as test from '@playwright/test'
|
|
|
|
import * as actions from './actions'
|
|
import * as api from './api'
|
|
|
|
test.test('change password modal', async ({ page }) => {
|
|
await api.mockApi(page)
|
|
await actions.login(page)
|
|
|
|
// Screenshot #1: Change password modal
|
|
await actions.locateUserMenuButton(page).click()
|
|
await actions.locateChangePasswordButton(page).click()
|
|
await test.expect(actions.locateChangePasswordModal(page)).toHaveScreenshot()
|
|
|
|
// Screenshot #2: Invalid old password
|
|
await actions.locateOldPasswordInput(page).fill(actions.INVALID_PASSWORD)
|
|
test.expect(
|
|
await page.evaluate(() => document.querySelector('form')?.checkValidity()),
|
|
'form should reject invalid old password'
|
|
).toBe(false)
|
|
await actions.locateResetButton(page).click()
|
|
|
|
// Screenshot #3: Invalid new password
|
|
await actions.locateOldPasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateNewPasswordInput(page).fill(actions.INVALID_PASSWORD)
|
|
test.expect(
|
|
await page.evaluate(() => document.querySelector('form')?.checkValidity()),
|
|
'form should reject invalid new password'
|
|
).toBe(false)
|
|
await actions.locateResetButton(page).click()
|
|
|
|
// Screenshot #4: Invalid "confirm new password"
|
|
await actions.locateNewPasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateConfirmNewPasswordInput(page).fill(actions.INVALID_PASSWORD)
|
|
test.expect(
|
|
await page.evaluate(() => document.querySelector('form')?.checkValidity()),
|
|
'form should reject invalid "confirm new password"'
|
|
).toBe(false)
|
|
await actions.locateResetButton(page).click()
|
|
|
|
// Screenshot #5: After form submission
|
|
await actions.locateConfirmNewPasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateResetButton(page).click()
|
|
await test.expect(actions.locateChangePasswordModal(page)).not.toBeAttached()
|
|
})
|