mirror of
https://github.com/enso-org/enso.git
synced 2025-01-02 06:31:59 +03:00
cf9d757457
- Fix https://github.com/enso-org/cloud-v2/issues/1383 - Fix file download - both on Electron, and in browser - Refresh versions list when uploading neww file version - Fix app crashing when asset is opened in asset panel while switching to Local Backend - Don't show asset id when asset is opened in asset panel, but user is on the Local backend, resulting in the internal Asset ID being shown - Fix drag-n-drop - ⚠️ `npm run dev` is NOT fixed in this PR - however it should already be fixed in another PR which has already been merged. This needs testing to confirm whether it is fixed though. Other changes: - Add support for "duplicate project" endpoint on Local Backend - Fix downloading project from nested directory on Local Backend (not working) - Refactor more E2E tests to use the "new" architecture - Simplify "new" E2E architecture to minimize boilerplate # Important Notes - When testing downloads, both Electron and browser should be tested as they use completely separate implementations for how files are downloaded.
124 lines
4.4 KiB
TypeScript
124 lines
4.4 KiB
TypeScript
/** @file Test the login flow. */
|
|
import * as test from '@playwright/test'
|
|
|
|
import * as actions from './actions'
|
|
import type * as api from './api'
|
|
|
|
// =================
|
|
// === Constants ===
|
|
// =================
|
|
|
|
const EMAIL = 'example.email+1234@testing.org'
|
|
const NAME = 'a custom user name'
|
|
const ORGANIZATION_ID = 'some testing organization id'
|
|
|
|
// =============
|
|
// === Tests ===
|
|
// =============
|
|
|
|
// Note: This does not check that the organization ID is sent in the correct format for the backend.
|
|
// It only checks that the organization ID is sent in certain places.
|
|
test.test('sign up with organization id', async ({ page }) => {
|
|
await page.goto('/')
|
|
await page.waitForLoadState('domcontentloaded')
|
|
await page.goto(
|
|
'/registration?' + new URLSearchParams([['organization_id', ORGANIZATION_ID]]).toString()
|
|
)
|
|
const api = await actions.mockApi({ page })
|
|
api.setCurrentUser(null)
|
|
|
|
// 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()
|
|
|
|
// Log in
|
|
await actions.locateEmailInput(page).fill(actions.VALID_EMAIL)
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateLoginButton(page).click()
|
|
await actions.passTermsAndConditionsDialog({ page })
|
|
|
|
// Set username
|
|
await actions.locateUsernameInput(page).fill('arbitrary username')
|
|
await actions.locateSetUsernameButton(page).click()
|
|
|
|
test
|
|
.expect(api.currentUser()?.organizationId, 'new user has correct organization id')
|
|
.toBe(ORGANIZATION_ID)
|
|
})
|
|
|
|
test.test('sign up without organization id', async ({ page }) => {
|
|
await page.goto('/')
|
|
await page.waitForLoadState('domcontentloaded')
|
|
await page.goto('/registration')
|
|
const api = await actions.mockApi({ page })
|
|
api.setCurrentUser(null)
|
|
|
|
// 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()
|
|
|
|
// Log in
|
|
await actions.locateEmailInput(page).fill(actions.VALID_EMAIL)
|
|
await actions.locatePasswordInput(page).fill(actions.VALID_PASSWORD)
|
|
await actions.locateLoginButton(page).click()
|
|
await actions.passTermsAndConditionsDialog({ page })
|
|
|
|
// Set username
|
|
await actions.locateUsernameInput(page).fill('arbitrary username')
|
|
await actions.locateSetUsernameButton(page).click()
|
|
|
|
test
|
|
.expect(api.currentUser()?.organizationId, 'new user has correct organization id')
|
|
.toBe(api.defaultOrganizationId)
|
|
})
|
|
|
|
test.test('sign up flow', ({ page }) => {
|
|
let api!: api.MockApi
|
|
return actions
|
|
.mockAll({
|
|
page,
|
|
setupAPI: theApi => {
|
|
api = theApi
|
|
theApi.setCurrentUser(null)
|
|
|
|
// These values should be different, otherwise the email and name may come from the defaults.
|
|
test.expect(EMAIL).not.toStrictEqual(theApi.defaultEmail)
|
|
test.expect(NAME).not.toStrictEqual(theApi.defaultName)
|
|
},
|
|
})
|
|
.loginAsNewUser(EMAIL, actions.VALID_PASSWORD)
|
|
.do(async thePage => {
|
|
await actions.passTermsAndConditionsDialog({ page: thePage })
|
|
})
|
|
.setUsername(NAME)
|
|
.do(async thePage => {
|
|
await test.expect(actions.locateUpgradeButton(thePage)).toBeVisible()
|
|
await test.expect(actions.locateDriveView(thePage)).not.toBeVisible()
|
|
})
|
|
.do(() => {
|
|
// 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
|
|
}
|
|
})
|
|
.openUserMenu()
|
|
.userMenu.logout()
|
|
.login(EMAIL, actions.VALID_PASSWORD)
|
|
.do(async () => {
|
|
await test.expect(actions.locateNotEnabledStub(page)).not.toBeVisible()
|
|
await test.expect(actions.locateDriveView(page)).toBeVisible()
|
|
})
|
|
.do(() => {
|
|
test.expect(api.currentUser()?.email, 'new user has correct email').toBe(EMAIL)
|
|
test.expect(api.currentUser()?.name, 'new user has correct name').toBe(NAME)
|
|
})
|
|
})
|