enso/app/gui/integration-test/dashboard/assetPanel.spec.ts
Sergei Garin caeaf413b5
Do not send the generated name to the Backend (#11735)
This PR removes sending the pre-generated name to the remote backend. We don't have full control over this and can't guarantee the uniqness of the name purely client-side.

Closes: https://github.com/enso-org/cloud-v2/issues/1600

For the local backend we still generate the name though.
2024-12-03 14:27:10 +00:00

84 lines
2.6 KiB
TypeScript

/** @file Tests for the asset panel. */
import { expect, test } from '@playwright/test'
import * as backend from '#/services/Backend'
import * as permissions from '#/utilities/permissions'
import * as actions from './actions'
// =================
// === Constants ===
// =================
/** An example description for the asset selected in the asset panel. */
const DESCRIPTION = 'foo bar'
/** An example owner username for the asset selected in the asset panel. */
const USERNAME = 'baz quux'
/** An example owner email for the asset selected in the asset panel. */
const EMAIL = 'baz.quux@email.com'
// =============
// === Tests ===
// =============
test('open and close asset panel', ({ page }) =>
actions
.mockAllAndLogin({ page })
.withAssetPanel(async (assetPanel) => {
await expect(assetPanel).toBeVisible()
})
.toggleAssetPanel()
.withAssetPanel(async (assetPanel) => {
await expect(assetPanel).not.toBeVisible()
}))
test('asset panel contents', ({ page }) =>
actions
.mockAllAndLogin({
page,
setupAPI: (api) => {
const { defaultOrganizationId, defaultUserId } = api
api.addProject({
description: DESCRIPTION,
permissions: [
{
permission: permissions.PermissionAction.own,
user: {
organizationId: defaultOrganizationId,
// Using the default ID causes the asset to have a dynamic username.
userId: backend.UserId(defaultUserId + '2'),
name: USERNAME,
email: backend.EmailAddress(EMAIL),
},
},
],
})
},
})
.driveTable.clickRow(0)
.toggleDescriptionAssetPanel()
.do(async () => {
await test.expect(actions.locateAssetPanelDescription(page)).toHaveText(DESCRIPTION)
// `getByText` is required so that this assertion works if there are multiple permissions.
// This is not visible; "Shared with" should only be visible on the Enterprise plan.
// await test.expect(actions.locateAssetPanelPermissions(page).getByText(USERNAME)).toBeVisible()
}))
test('Asset Panel Documentation view', ({ page }) => {
return actions
.mockAllAndLogin({
page,
setupAPI: (api) => {
api.addProject({})
},
})
.driveTable.clickRow(0)
.toggleDocsAssetPanel()
.withAssetPanel(async (assetPanel) => {
await expect(assetPanel.getByTestId('asset-panel-tab-panel-docs')).toBeVisible()
await expect(assetPanel.getByTestId('asset-docs-content')).toBeVisible()
await expect(assetPanel.getByTestId('asset-docs-content')).toHaveText(/Project Goal/)
})
})