mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 08:21:49 +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)
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
/** @file Test the login flow. */
|
|
import * as test from '@playwright/test'
|
|
|
|
import * as actions from './actions'
|
|
import * as apiModule from './api'
|
|
|
|
// =============
|
|
// === Tests ===
|
|
// =============
|
|
|
|
test.test('sign up flow', async ({ page }) => {
|
|
const api = await apiModule.mockApi(page)
|
|
api.setCurrentUser(null)
|
|
await page.goto('/')
|
|
|
|
const email = 'example.email+1234@testing.org'
|
|
const name = 'a custom user name'
|
|
|
|
// These values should be different, otherwise the email and name may come from the defaults.
|
|
test.expect(email).not.toStrictEqual(api.defaultEmail)
|
|
test.expect(name).not.toStrictEqual(api.defaultName)
|
|
|
|
// Screenshot #1: Set username panel
|
|
await actions.locateEmailInput(page).fill(email)
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateLoginButton(page).click()
|
|
await test.expect(actions.locateSetUsernamePanel(page)).toHaveScreenshot()
|
|
|
|
// Screenshot #2: Logged in, but account disabled
|
|
await actions.locateUsernameInput(page).fill(name)
|
|
await actions.locateSetUsernameButton(page).click()
|
|
await test.expect(page).toHaveScreenshot()
|
|
|
|
// Screenshot #3: Logged in, and account enabled
|
|
const currentUser = api.currentUser
|
|
test.expect(currentUser).toBeDefined()
|
|
if (currentUser != null) {
|
|
currentUser.isEnabled = true
|
|
}
|
|
await actions.login(page, email)
|
|
await test.expect(page).toHaveScreenshot()
|
|
|
|
test.expect(api.currentUser?.email, 'new user has correct email').toBe(email)
|
|
test.expect(api.currentUser?.name, 'new user has correct name').toBe(name)
|
|
})
|