enso/app/ide-desktop/lib/dashboard/e2e/assetPanel.spec.ts
Nikita Pekin 6d73dadcee
impr(enso/cloud-v2#912): Add organization_id and user_id fields to SimpleUser (#9508)
- Updates the model types for the request/response bodies to match the backend.
  - Renames `CreatePermissionRequestBody::userSubjects` to match `CreatePermissionRequestBody::actorsIds` on the backend
  - Renames `UserInfo::organization_id` to camel case
  - Adds `UserInfo::userId` field to match the backend
  - Merges `SimpleUser` into `UserInfo`

Previously, `UserInfo`'s `OrganizationId` was serialized as `pk`. This
is not desired since `pk` is an implementation detail (relating to
DynamoDB). This commit renames the field to accurately reflect the type
of data it contains.

- Renames `User::id` to `User::organizationId`.

Previously, the user's organization ID was under the `id` field. As of
enso-cloud/cloud-v2#1098, this is no longer the case. The
`organizationId` field is no longer a user's primary identifier --
`userId` should be used for that purpose instead. So this field has been
renamed to `organizationId` to more clearly describe the purpose of the
field.

Affects the responses expected from the following endpoints:

- `PUT /users/me/picture`
- `PUT /users/me`
- `GET /users/me`
- `PUT /users/{userId}/usergroups`

- Adds `User::userId` field.

Previously, the user's organization ID was used to uniquely identify a
user. Now that multiple users can be invited to an organization, it is
no longer appropriate to use organization ID to uniquely refer to a
user. For this purpose, the backend has introduced the `userId` field.

Affects the responses expected from the following endpoints:

- `POST /users`
- `PUT  /users/me/picture`
- `PUT  /users/me`
- `GET  /users/me`
- `PUT  /users/{userId}/usergroups`

Removes the `user` param from `tryGetSingletonOwnerPermission`. This
param was previously required. It was required because a `userSubject`
was necessary to optimistically generate a `UserPermission`. With recent
refactors, a `userId` can be used in place of `userSubject` to generate
a `UserPermission`. The existing param `owner` provides the `userId`, so
the `user` param is redundant and can be removed.

- Removes `UserInfo` from the `FullUserSession`.

Previously, `UserInfo` in the `FullUserSession` was required to obtain a
`userSubject`. Now, `userSubject` has been deprecated in favour of
`userId`. `User` provides `userId`, and is present in the
`FullUserSession`. Thus, this commit removes `UserInfo` from the
`FullUserSession` since it is redundant.

- Renames `UserInfo` fields to `camelCase`

Previously, `UserInfo`'s fields were serialized as `snake_case`. This is
not desired since the convention for the frontend is to use `camelCase`
for field names where possible. This commit renames the fields to be
`camelCase`, now that the backend has been updated accordingly.

- Sorts by `userId` rather than `email`
- Compares by `userId` rather than `email`

- Extends `User` from `UserInfo`

After refactoring, `UserInfo` is now a subset of `User`. To remove
duplication, this commit modifies `User` to extend `UserInfo`.
2024-03-27 15:58:08 +01:00

53 lines
1.8 KiB
TypeScript

/** @file Tests for the asset panel. */
import * as test from '@playwright/test'
import * as backend from '#/services/Backend'
import * as permissions from '#/utilities/permissions'
import * as actions from './actions'
test.test('open and close asset panel', async ({ page }) => {
await actions.mockAllAndLogin({ page })
const assetRows = actions.locateAssetRows(page)
await actions.locateNewFolderIcon(page).click()
await actions.clickAssetRow(assetRows.nth(0))
await test.expect(actions.locateAssetPanel(page)).not.toBeVisible()
await actions.locateAssetPanelIcon(page).click()
await test.expect(actions.locateAssetPanel(page)).toBeVisible()
await actions.locateAssetPanelIcon(page).click()
await test.expect(actions.locateAssetPanel(page)).not.toBeVisible()
})
test.test('asset panel contents', async ({ page }) => {
const { api } = await actions.mockAll({ page })
const { defaultOrganizationId, defaultUserId } = api
const assetRows = actions.locateAssetRows(page)
const description = 'foo bar'
const username = 'baz quux'
const email = 'baz.quux@email.com'
api.addProject('project', {
description,
permissions: [
{
permission: permissions.PermissionAction.own,
user: {
organizationId: defaultOrganizationId,
userId: defaultUserId,
name: username,
email: backend.EmailAddress(email),
},
},
],
})
await page.goto('/')
await actions.login({ page })
await actions.clickAssetRow(assetRows.nth(0))
await actions.locateAssetPanelIcon(page).click()
await test.expect(actions.locateAssetPanelDescription(page)).toHaveText(description)
// `getByText` is required so that this assertion works if there are multiple permissions.
await test.expect(actions.locateAssetPanelPermissions(page).getByText(username)).toBeVisible()
})