2023-10-11 13:24:33 +03:00
|
|
|
/** @file Test the login flow. */
|
|
|
|
import * as test from '@playwright/test'
|
|
|
|
|
|
|
|
import * as actions from './actions'
|
|
|
|
|
|
|
|
test.test('sign up flow', async ({ page }) => {
|
2024-01-31 14:35:41 +03:00
|
|
|
const api = await actions.mockApi({ page })
|
2024-01-23 00:26:15 +03:00
|
|
|
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)
|
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
// Set username panel
|
2024-01-23 00:26:15 +03:00
|
|
|
await actions.locateEmailInput(page).fill(email)
|
|
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
|
|
await actions.locateLoginButton(page).click()
|
2024-01-31 14:35:41 +03:00
|
|
|
await test.expect(actions.locateSetUsernamePanel(page)).toBeVisible()
|
2024-01-23 00:26:15 +03:00
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
// Logged in, but account disabled
|
2024-01-23 00:26:15 +03:00
|
|
|
await actions.locateUsernameInput(page).fill(name)
|
|
|
|
await actions.locateSetUsernameButton(page).click()
|
2024-01-31 14:35:41 +03:00
|
|
|
await test.expect(actions.locateUpgradeButton(page)).toBeVisible()
|
|
|
|
await test.expect(actions.locateDriveView(page)).not.toBeVisible()
|
2024-01-23 00:26:15 +03:00
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
// Logged in, and account enabled
|
2024-01-23 00:26:15 +03:00
|
|
|
const currentUser = api.currentUser
|
|
|
|
test.expect(currentUser).toBeDefined()
|
|
|
|
if (currentUser != null) {
|
|
|
|
currentUser.isEnabled = true
|
|
|
|
}
|
2024-01-31 14:35:41 +03:00
|
|
|
await actions.login({ page }, email)
|
|
|
|
await test.expect(actions.locateUpgradeButton(page)).not.toBeVisible()
|
|
|
|
await test.expect(actions.locateDriveView(page)).toBeVisible()
|
2024-01-23 00:26:15 +03:00
|
|
|
|
|
|
|
test.expect(api.currentUser?.email, 'new user has correct email').toBe(email)
|
|
|
|
test.expect(api.currentUser?.name, 'new user has correct name').toBe(name)
|
2023-10-11 13:24:33 +03:00
|
|
|
})
|