can sort projects #3362
This commit is contained in:
@ -6,6 +6,128 @@ test.afterEach(async ({ page }, testInfo) => {
|
|||||||
await tearDown(page, testInfo)
|
await tearDown(page, testInfo)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test(
|
||||||
|
'Can sort projects on home page',
|
||||||
|
{ tag: '@electron' },
|
||||||
|
async ({ browserName }, testInfo) => {
|
||||||
|
test.skip(
|
||||||
|
browserName === 'webkit',
|
||||||
|
'Skip on Safari because `window.tearDown` does not work'
|
||||||
|
)
|
||||||
|
const { electronApp, page } = await setupElectron({
|
||||||
|
testInfo,
|
||||||
|
folderSetupFn: async (dir) => {
|
||||||
|
await fsp.mkdir(`${dir}/router-template-slate`, { recursive: true })
|
||||||
|
await fsp.copyFile(
|
||||||
|
'src/wasm-lib/tests/executor/inputs/router-template-slate.kcl',
|
||||||
|
`${dir}/router-template-slate/main.kcl`
|
||||||
|
)
|
||||||
|
|
||||||
|
// wait more than a second so the timestamp is different
|
||||||
|
await new Promise((r) => setTimeout(r, 1_200))
|
||||||
|
await fsp.mkdir(`${dir}/bracket`, { recursive: true })
|
||||||
|
await fsp.copyFile(
|
||||||
|
'src/wasm-lib/tests/executor/inputs/focusrite_scarlett_mounting_braket.kcl',
|
||||||
|
`${dir}/bracket/main.kcl`
|
||||||
|
)
|
||||||
|
|
||||||
|
// wait more than a second so the timestamp is different
|
||||||
|
await new Promise((r) => setTimeout(r, 1_200))
|
||||||
|
await fsp.mkdir(`${dir}/lego`, { recursive: true })
|
||||||
|
await fsp.copyFile(
|
||||||
|
'src/wasm-lib/tests/executor/inputs/lego.kcl',
|
||||||
|
`${dir}/lego/main.kcl`
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
await page.goto('http://localhost:3000/')
|
||||||
|
await page.setViewportSize({ width: 1200, height: 500 })
|
||||||
|
|
||||||
|
const getAllProjects = () => page.getByTestId('project-link').all()
|
||||||
|
|
||||||
|
page.on('console', console.log)
|
||||||
|
|
||||||
|
await test.step('should be shorted by modified initially', async () => {
|
||||||
|
const lastModifiedButton = page.getByRole('button', {
|
||||||
|
name: 'Last Modified',
|
||||||
|
})
|
||||||
|
await expect(lastModifiedButton).toBeVisible()
|
||||||
|
await expect(lastModifiedButton.getByLabel('arrow down')).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
|
const projectNamesOrderedByModified = [
|
||||||
|
'lego',
|
||||||
|
'bracket',
|
||||||
|
'router-template-slate',
|
||||||
|
]
|
||||||
|
await test.step('Check the order of the projects is correct', async () => {
|
||||||
|
for (const [index, projectLink] of (await getAllProjects()).entries()) {
|
||||||
|
await expect(projectLink).toContainText(
|
||||||
|
projectNamesOrderedByModified[index]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Reverse modified order', async () => {
|
||||||
|
const lastModifiedButton = page.getByRole('button', {
|
||||||
|
name: 'Last Modified',
|
||||||
|
})
|
||||||
|
await lastModifiedButton.click()
|
||||||
|
await expect(lastModifiedButton).toBeVisible()
|
||||||
|
await expect(lastModifiedButton.getByLabel('arrow up')).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check the order of the projects is has reversed', async () => {
|
||||||
|
for (const [index, projectLink] of (await getAllProjects()).entries()) {
|
||||||
|
await expect(projectLink).toContainText(
|
||||||
|
[...projectNamesOrderedByModified].reverse()[index]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Change order to by name', async () => {
|
||||||
|
const nameButton = page.getByRole('button', {
|
||||||
|
name: 'Name',
|
||||||
|
})
|
||||||
|
await nameButton.click()
|
||||||
|
await expect(nameButton).toBeVisible()
|
||||||
|
await expect(nameButton.getByLabel('arrow down')).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
|
const projectNamesOrderedByName = [
|
||||||
|
'bracket',
|
||||||
|
'lego',
|
||||||
|
'router-template-slate',
|
||||||
|
]
|
||||||
|
await test.step('Check the order of the projects is by name', async () => {
|
||||||
|
for (const [index, projectLink] of (await getAllProjects()).entries()) {
|
||||||
|
await expect(projectLink).toContainText(
|
||||||
|
projectNamesOrderedByName[index]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Reverse name order', async () => {
|
||||||
|
const nameButton = page.getByRole('button', {
|
||||||
|
name: 'Name',
|
||||||
|
})
|
||||||
|
await nameButton.click()
|
||||||
|
await expect(nameButton).toBeVisible()
|
||||||
|
await expect(nameButton.getByLabel('arrow up')).toBeVisible()
|
||||||
|
})
|
||||||
|
|
||||||
|
await test.step('Check the order of the projects is by name reversed', async () => {
|
||||||
|
for (const [index, projectLink] of (await getAllProjects()).entries()) {
|
||||||
|
await expect(projectLink).toContainText(
|
||||||
|
[...projectNamesOrderedByName].reverse()[index]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
await electronApp.close()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'When the project folder is empty, user can create new project and open it.',
|
'When the project folder is empty, user can create new project and open it.',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
|
@ -2,7 +2,12 @@ import { cloneElement } from 'react'
|
|||||||
|
|
||||||
const CustomIconMap = {
|
const CustomIconMap = {
|
||||||
arc: (
|
arc: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arc"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -12,7 +17,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
angle: (
|
angle: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="angle"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -22,7 +32,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
arrowDown: (
|
arrowDown: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arrow down"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -32,7 +47,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
arrowLeft: (
|
arrowLeft: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arrow left"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -42,7 +62,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
arrowRight: (
|
arrowRight: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arrow right"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -52,7 +77,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
arrowRotateRight: (
|
arrowRotateRight: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arrow rotate right"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -62,7 +92,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
arrowUp: (
|
arrowUp: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="arrow up"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -72,7 +107,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
booleanExclude: (
|
booleanExclude: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="boolean exclude"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -82,7 +122,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
booleanIntersect: (
|
booleanIntersect: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="boolean intersect"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -92,7 +137,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
booleanSubtract: (
|
booleanSubtract: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="boolean subtract"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -102,7 +152,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
booleanUnion: (
|
booleanUnion: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="boolean union"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -112,7 +167,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
bug: (
|
bug: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="bug"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -122,7 +182,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
checkmark: (
|
checkmark: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="checkmark"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -132,7 +197,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
caretDown: (
|
caretDown: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="caret down"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -142,7 +212,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
chamfer3d: (
|
chamfer3d: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="chamfer 3d"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -152,7 +227,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
circle: (
|
circle: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="circle"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -162,7 +242,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
clipboardCheckmark: (
|
clipboardCheckmark: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="clipboard checkmark"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -172,7 +257,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
clipboardPlus: (
|
clipboardPlus: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="clipboard plus"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -182,7 +272,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
close: (
|
close: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="close"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -192,7 +287,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
code: (
|
code: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="code"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -202,7 +302,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
dimension: (
|
dimension: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="dimension"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
@ -354,7 +459,12 @@ const CustomIconMap = {
|
|||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
horizontalDash: (
|
horizontalDash: (
|
||||||
<svg viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
|
viewBox="0 0 20 20"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
aria-label="horizontal Dash"
|
||||||
|
>
|
||||||
<path
|
<path
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
clipRule="evenodd"
|
clipRule="evenodd"
|
||||||
|
Reference in New Issue
Block a user