mirror of
https://github.com/enso-org/enso.git
synced 2024-12-30 16:41:32 +03:00
3c31155fe9
- Implements https://github.com/enso-org/cloud-v2/issues/631 - Tests for dashboard (`app/ide-desktop/lib/dashboard/`): - End-to-end tests - Unit tests - Component tests The purpose of this PR is to introduce the testing framework - more tests can be added later in separate PRs. # Important Notes To test, run `npm run test` in `app/ide-desktop`, or `app/ide-desktop/lib/dashboard/`. All tests should pass. Individual test types can be run using `npm run test-unit`, `npm run test-component` and `npm run test-e2e` in `app/ide-desktop/lib/dashboard/`. Individual end-to-end tests can be run using `npx playwright test -c playwright-e2e.config.ts test-e2e/<file name>.spec.ts` in `app/ide-desktop/lib/dashboard/`. End-to-end tests require internet access to pass (for things like fonts). This PR *does* check in screenshots to guard against visual regessions (and/or to make visual changes obvious)
46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
/** @file Test the drive view. */
|
|
import * as test from '@playwright/test'
|
|
|
|
import * as actions from './actions'
|
|
import * as api from './api'
|
|
|
|
test.test('drive view', async ({ page }) => {
|
|
await api.mockApi(page)
|
|
await actions.mockDate(page)
|
|
await actions.login(page)
|
|
|
|
// Screenshot #1: Drive view
|
|
// Initially, the table contains the header row and the placeholder row.
|
|
await test.expect(actions.locateAssetsTableRows(page)).toHaveCount(2)
|
|
await test.expect(actions.locateDriveView(page)).toHaveScreenshot()
|
|
|
|
// Screenshot #2: Assets table with one asset
|
|
await actions.locateNewProjectButton(page).click()
|
|
// The placeholder row becomes hidden.
|
|
await test.expect(actions.locateAssetsTableRows(page)).toHaveCount(2)
|
|
await test.expect(actions.locateAssetsTable(page)).toHaveScreenshot()
|
|
|
|
await actions.locateNewProjectButton(page).click()
|
|
await test.expect(actions.locateAssetsTableRows(page)).toHaveCount(3)
|
|
|
|
// These are guarded by the `not.toBeUndefined` below.
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
const firstAssetRow = (await actions.locateAssetsTableRows(page).all())[1]!
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
const secondAssetRow = (await actions.locateAssetsTableRows(page).all())[2]!
|
|
test.expect(firstAssetRow).not.toBeUndefined()
|
|
test.expect(secondAssetRow).not.toBeUndefined()
|
|
// The last opened project needs to be stopped, to remove the toast notification notifying the
|
|
// user that project creation may take a while. Previously opened projects are stopped when the
|
|
// new project is created.
|
|
await actions.locateStopProjectButton(secondAssetRow).click()
|
|
|
|
// Screenshot #3: Project context menu
|
|
await firstAssetRow.click({ button: 'right' })
|
|
const contextMenu = actions.locateContextMenus(page)
|
|
await test.expect(contextMenu).toHaveScreenshot()
|
|
|
|
await actions.locateMoveToTrashButton(contextMenu).click()
|
|
await test.expect(actions.locateAssetsTableRows(page)).toHaveCount(2)
|
|
})
|