2024-03-18 11:47:01 +03:00
|
|
|
/** @file Test the drive view. */
|
|
|
|
import * as test from '@playwright/test'
|
|
|
|
|
|
|
|
import * as actions from './actions'
|
|
|
|
|
2024-06-19 18:24:11 +03:00
|
|
|
const PASS_TIMEOUT = 5_000
|
|
|
|
|
2024-07-16 12:55:45 +03:00
|
|
|
test.test('extra columns should stick to right side of assets table', ({ page }) =>
|
|
|
|
actions
|
|
|
|
.mockAllAndLogin({ page })
|
|
|
|
.driveTable.toggleColumn.accessedByProjects()
|
|
|
|
.driveTable.toggleColumn.accessedData()
|
2024-07-26 09:34:51 +03:00
|
|
|
.withAssetsTable(async (table) => {
|
|
|
|
await table.evaluate((element) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
let scrollableParent: HTMLElement | SVGElement | null = element
|
|
|
|
while (
|
|
|
|
scrollableParent != null &&
|
|
|
|
scrollableParent.scrollWidth <= scrollableParent.clientWidth
|
|
|
|
) {
|
|
|
|
scrollableParent = scrollableParent.parentElement
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
|
|
scrollableParent?.scrollTo({ left: 999999, behavior: 'instant' })
|
|
|
|
})
|
2024-03-18 11:47:01 +03:00
|
|
|
})
|
2024-07-26 09:34:51 +03:00
|
|
|
.do(async (thePage) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
const extraColumns = actions.locateExtraColumns(thePage)
|
|
|
|
const assetsTable = actions.locateAssetsTable(thePage)
|
|
|
|
await test
|
|
|
|
.expect(async () => {
|
|
|
|
const extraColumnsRight = await extraColumns.evaluate(
|
2024-07-26 09:34:51 +03:00
|
|
|
(element) => element.getBoundingClientRect().right,
|
2024-07-16 12:55:45 +03:00
|
|
|
)
|
|
|
|
const assetsTableRight = await assetsTable.evaluate(
|
2024-07-26 09:34:51 +03:00
|
|
|
(element) => element.getBoundingClientRect().right,
|
2024-07-16 12:55:45 +03:00
|
|
|
)
|
|
|
|
test.expect(extraColumnsRight).toEqual(assetsTableRight)
|
|
|
|
})
|
|
|
|
.toPass({ timeout: PASS_TIMEOUT })
|
2024-07-26 09:34:51 +03:00
|
|
|
}),
|
2024-07-16 12:55:45 +03:00
|
|
|
)
|
2024-03-18 11:47:01 +03:00
|
|
|
|
|
|
|
test.test('extra columns should stick to top of scroll container', async ({ page }) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
await actions.mockAllAndLogin({
|
|
|
|
page,
|
2024-07-26 09:34:51 +03:00
|
|
|
setupAPI: (api) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
|
|
for (let i = 0; i < 100; i += 1) {
|
|
|
|
api.addFile('a')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
2024-03-18 11:47:01 +03:00
|
|
|
|
|
|
|
await actions.locateAccessedByProjectsColumnToggle(page).click()
|
|
|
|
await actions.locateAccessedDataColumnToggle(page).click()
|
2024-07-26 09:34:51 +03:00
|
|
|
await actions.locateAssetsTable(page).evaluate((element) => {
|
2024-03-18 11:47:01 +03:00
|
|
|
let scrollableParent: HTMLElement | SVGElement | null = element
|
|
|
|
while (
|
|
|
|
scrollableParent != null &&
|
|
|
|
scrollableParent.scrollWidth <= scrollableParent.clientWidth
|
|
|
|
) {
|
|
|
|
scrollableParent = scrollableParent.parentElement
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
|
|
scrollableParent?.scrollTo({ top: 999999, behavior: 'instant' })
|
|
|
|
})
|
|
|
|
const extraColumns = actions.locateExtraColumns(page)
|
|
|
|
const assetsTable = actions.locateAssetsTable(page)
|
|
|
|
await test
|
|
|
|
.expect(async () => {
|
|
|
|
const extraColumnsTop = await extraColumns.evaluate(
|
2024-07-26 09:34:51 +03:00
|
|
|
(element) => element.getBoundingClientRect().top,
|
2024-03-18 11:47:01 +03:00
|
|
|
)
|
2024-07-26 09:34:51 +03:00
|
|
|
const assetsTableTop = await assetsTable.evaluate((element) => {
|
2024-03-18 11:47:01 +03:00
|
|
|
let scrollableParent: HTMLElement | SVGElement | null = element
|
|
|
|
while (
|
|
|
|
scrollableParent != null &&
|
|
|
|
scrollableParent.scrollWidth <= scrollableParent.clientWidth
|
|
|
|
) {
|
|
|
|
scrollableParent = scrollableParent.parentElement
|
|
|
|
}
|
|
|
|
return scrollableParent?.getBoundingClientRect().top
|
|
|
|
})
|
|
|
|
test.expect(extraColumnsTop).toEqual(assetsTableTop)
|
|
|
|
})
|
2024-06-19 18:24:11 +03:00
|
|
|
.toPass({ timeout: PASS_TIMEOUT })
|
2024-03-18 11:47:01 +03:00
|
|
|
})
|
|
|
|
|
2024-07-16 12:55:45 +03:00
|
|
|
test.test('can drop onto root directory dropzone', ({ page }) =>
|
|
|
|
actions
|
|
|
|
.mockAllAndLogin({ page })
|
|
|
|
.createFolder()
|
|
|
|
.uploadFile('b', 'testing')
|
|
|
|
.driveTable.doubleClickRow(0)
|
2024-08-12 13:25:18 +03:00
|
|
|
.driveTable.withRows(async (rows, nonAssetRows) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
const parentLeft = await actions.getAssetRowLeftPx(rows.nth(0))
|
2024-08-12 13:25:18 +03:00
|
|
|
const childLeft = await actions.getAssetRowLeftPx(nonAssetRows.nth(0))
|
2024-07-16 12:55:45 +03:00
|
|
|
test.expect(childLeft, 'Child is indented further than parent').toBeGreaterThan(parentLeft)
|
|
|
|
})
|
|
|
|
.driveTable.dragRow(1, actions.locateRootDirectoryDropzone(page))
|
2024-07-26 09:34:51 +03:00
|
|
|
.driveTable.withRows(async (rows) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
const firstLeft = await actions.getAssetRowLeftPx(rows.nth(0))
|
2024-08-12 13:25:18 +03:00
|
|
|
const secondLeft = await actions.getAssetRowLeftPx(rows.nth(1))
|
2024-07-16 12:55:45 +03:00
|
|
|
test.expect(firstLeft, 'Siblings have same indentation').toEqual(secondLeft)
|
2024-07-26 09:34:51 +03:00
|
|
|
}),
|
2024-07-16 12:55:45 +03:00
|
|
|
)
|