2023-10-11 13:24:33 +03:00
|
|
|
/** @file Test the login flow. */
|
|
|
|
import * as test from '@playwright/test'
|
|
|
|
|
|
|
|
import * as actions from './actions'
|
|
|
|
|
|
|
|
// =============
|
|
|
|
// === Tests ===
|
|
|
|
// =============
|
|
|
|
|
|
|
|
test.test('sign up without organization id', async ({ page }) => {
|
2024-01-23 00:26:15 +03:00
|
|
|
await page.goto('/')
|
|
|
|
await page.waitForLoadState('domcontentloaded')
|
|
|
|
await page.goto('/registration')
|
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)
|
2023-10-11 13:24:33 +03:00
|
|
|
|
2024-01-23 00:26:15 +03:00
|
|
|
// Sign up
|
|
|
|
await actions.locateEmailInput(page).fill(actions.VALID_EMAIL)
|
|
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
|
|
await actions.locateConfirmPasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
|
|
await actions.locateRegisterButton(page).click()
|
2023-10-11 13:24:33 +03:00
|
|
|
|
2024-01-23 00:26:15 +03:00
|
|
|
// Log in
|
|
|
|
await actions.locateEmailInput(page).fill(actions.VALID_EMAIL)
|
|
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
|
|
await actions.locateLoginButton(page).click()
|
2023-10-11 13:24:33 +03:00
|
|
|
|
2024-01-23 00:26:15 +03:00
|
|
|
// Set username
|
|
|
|
await actions.locateUsernameInput(page).fill('arbitrary username')
|
|
|
|
await actions.locateSetUsernameButton(page).click()
|
2023-10-11 13:24:33 +03:00
|
|
|
|
2024-01-23 00:26:15 +03:00
|
|
|
test
|
|
|
|
.expect(api.currentUser?.id, 'new user has correct organization id')
|
|
|
|
.toBe(api.defaultOrganizationId)
|
2023-10-11 13:24:33 +03:00
|
|
|
})
|