enso/app/ide-desktop/lib/dashboard/e2e/signUpFlow.spec.ts
somebody1234 784d06912f
Make (almost) all interfaces readonly (#8800)
This is not strictly necessary (as indicated by the fact that no actual logic needed to be changed), but it doesn't hurt to make this change.
- Make (almost) all `interface`s `readonly`
- Some of them are *not* readonly; this is intentional as those *do* need to be mutated
- A `no-restricted-syntax` lint rule has been added, but only for `interfaces` - it has been added neither for `classes` nor for `readonly T[]`
- A lint rule for `extends React.PropsWithChildren` instead of `extends Readonly<React.PropsWithChildren>` would be easy to add though...

# Important Notes
- There should be no logic changes, so QA shouldn't need to test anything in particular.
2024-02-07 11:26:59 +00:00

45 lines
1.8 KiB
TypeScript

/** @file Test the login flow. */
import * as test from '@playwright/test'
import * as actions from './actions'
test.test('sign up flow', async ({ page }) => {
const api = await actions.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)
// 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)).toBeVisible()
// Logged in, but account disabled
await actions.locateUsernameInput(page).fill(name)
await actions.locateSetUsernameButton(page).click()
await test.expect(actions.locateUpgradeButton(page)).toBeVisible()
await test.expect(actions.locateDriveView(page)).not.toBeVisible()
// Logged in, and account enabled
const currentUser = api.currentUser
test.expect(currentUser).toBeDefined()
if (currentUser != null) {
// This is required because `UserOrOrganization` is `readonly`.
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-restricted-syntax, no-extra-semi
;(currentUser as { isEnabled: boolean }).isEnabled = true
}
await actions.login({ page }, email)
await test.expect(actions.locateUpgradeButton(page)).not.toBeVisible()
await test.expect(actions.locateDriveView(page)).toBeVisible()
test.expect(api.currentUser?.email, 'new user has correct email').toBe(email)
test.expect(api.currentUser?.name, 'new user has correct name').toBe(name)
})