2024-01-31 14:35:41 +03:00
|
|
|
/** @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'
|
|
|
|
|
2024-06-20 19:19:01 +03:00
|
|
|
// =================
|
|
|
|
// === 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.test('open and close asset panel', ({ page }) =>
|
2024-07-16 12:55:45 +03:00
|
|
|
actions
|
|
|
|
.mockAllAndLogin({ page })
|
|
|
|
.createFolder()
|
|
|
|
.driveTable.clickRow(0)
|
|
|
|
.withAssetPanel(async (assetPanel) => {
|
|
|
|
await actions.expectNotOnScreen(assetPanel)
|
|
|
|
})
|
|
|
|
.toggleAssetPanel()
|
|
|
|
.withAssetPanel(async (assetPanel) => {
|
|
|
|
await actions.expectOnScreen(assetPanel)
|
|
|
|
})
|
|
|
|
.toggleAssetPanel()
|
|
|
|
.withAssetPanel(async (assetPanel) => {
|
|
|
|
await actions.expectNotOnScreen(assetPanel)
|
|
|
|
}),
|
2024-06-20 19:19:01 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
test.test('asset panel contents', ({ page }) =>
|
2024-07-16 12:55:45 +03:00
|
|
|
actions
|
|
|
|
.mockAll({
|
|
|
|
page,
|
|
|
|
setupAPI: (api) => {
|
|
|
|
const { defaultOrganizationId, defaultUserId } = api
|
|
|
|
api.addProject('project', {
|
|
|
|
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),
|
2024-06-20 19:19:01 +03:00
|
|
|
},
|
2024-07-16 12:55:45 +03:00
|
|
|
},
|
|
|
|
],
|
2024-06-20 19:19:01 +03:00
|
|
|
})
|
2024-07-16 12:55:45 +03:00
|
|
|
},
|
|
|
|
})
|
|
|
|
.login()
|
|
|
|
.do(async (thePage) => {
|
2024-08-28 20:51:31 +03:00
|
|
|
await actions.passAgreementsDialog({ page: thePage })
|
2024-07-16 12:55:45 +03:00
|
|
|
})
|
|
|
|
.driveTable.clickRow(0)
|
|
|
|
.toggleAssetPanel()
|
|
|
|
.do(async () => {
|
|
|
|
await test.expect(actions.locateAssetPanelDescription(page)).toHaveText(DESCRIPTION)
|
|
|
|
// `getByText` is required so that this assertion works if there are multiple permissions.
|
2024-10-21 13:30:19 +03:00
|
|
|
// This is not visible; "Shared with" should only be visible on the Enterprise plan.
|
|
|
|
// await test.expect(actions.locateAssetPanelPermissions(page).getByText(USERNAME)).toBeVisible()
|
2024-07-16 12:55:45 +03:00
|
|
|
}),
|
2024-06-20 19:19:01 +03:00
|
|
|
)
|