Bug fix: open project command lists project names (#5176)
* Amend project open test to show failing case * Fix command config to use live context value * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) * Update src/lib/commandBarConfigs/projectsCommandConfig.ts Co-authored-by: Jonathan Tran <jonnytran@gmail.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: namespace-profile-ubuntu-8-cores) --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
This commit is contained in:
@ -4,7 +4,6 @@ import { expect } from '@playwright/test'
|
|||||||
type CmdBarSerialised =
|
type CmdBarSerialised =
|
||||||
| {
|
| {
|
||||||
stage: 'commandBarClosed'
|
stage: 'commandBarClosed'
|
||||||
// TODO no more properties needed but needs to be implemented in _serialiseCmdBar
|
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
stage: 'pickCommand'
|
stage: 'pickCommand'
|
||||||
@ -37,6 +36,9 @@ export class CmdBarFixture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _serialiseCmdBar = async (): Promise<CmdBarSerialised> => {
|
private _serialiseCmdBar = async (): Promise<CmdBarSerialised> => {
|
||||||
|
if (!(await this.page.getByTestId('command-bar-wrapper').isVisible())) {
|
||||||
|
return { stage: 'commandBarClosed' }
|
||||||
|
}
|
||||||
const reviewForm = this.page.locator('#review-form')
|
const reviewForm = this.page.locator('#review-form')
|
||||||
const getHeaderArgs = async () => {
|
const getHeaderArgs = async () => {
|
||||||
const inputs = await this.page.getByTestId('cmd-bar-input-tab').all()
|
const inputs = await this.page.getByTestId('cmd-bar-input-tab').all()
|
||||||
|
@ -1525,7 +1525,7 @@ extrude001 = extrude(200, sketch001)`)
|
|||||||
test(
|
test(
|
||||||
'Opening a project should successfully load the stream, (regression test that this also works when switching between projects)',
|
'Opening a project should successfully load the stream, (regression test that this also works when switching between projects)',
|
||||||
{ tag: '@electron' },
|
{ tag: '@electron' },
|
||||||
async ({ context, page }, testInfo) => {
|
async ({ context, page, cmdBar, homePage }, testInfo) => {
|
||||||
await context.folderSetupFn(async (dir) => {
|
await context.folderSetupFn(async (dir) => {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
fsp.mkdir(path.join(dir, 'router-template-slate'), { recursive: true }),
|
fsp.mkdir(path.join(dir, 'router-template-slate'), { recursive: true }),
|
||||||
@ -1563,11 +1563,38 @@ test(
|
|||||||
|
|
||||||
const pointOnModel = { x: 630, y: 280 }
|
const pointOnModel = { x: 630, y: 280 }
|
||||||
|
|
||||||
await test.step('Opening the bracket project should load the stream', async () => {
|
await test.step('Opening the bracket project via command palette should load the stream', async () => {
|
||||||
// expect to see the text bracket
|
await homePage.expectState({
|
||||||
await expect(page.getByText('bracket')).toBeVisible()
|
projectCards: [
|
||||||
|
{
|
||||||
|
title: 'bracket',
|
||||||
|
fileCount: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'router-template-slate',
|
||||||
|
fileCount: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sortBy: 'last-modified-desc',
|
||||||
|
})
|
||||||
|
|
||||||
await page.getByText('bracket').click()
|
await cmdBar.openCmdBar()
|
||||||
|
await cmdBar.chooseCommand('open project')
|
||||||
|
await cmdBar.expectState({
|
||||||
|
stage: 'arguments',
|
||||||
|
commandName: 'Open project',
|
||||||
|
currentArgKey: 'name',
|
||||||
|
currentArgValue: '',
|
||||||
|
headerArguments: {
|
||||||
|
Name: '',
|
||||||
|
},
|
||||||
|
highlightedHeaderArg: 'name',
|
||||||
|
})
|
||||||
|
await cmdBar.argumentInput.fill('brac')
|
||||||
|
await cmdBar.progressCmdBar()
|
||||||
|
await cmdBar.expectState({
|
||||||
|
stage: 'commandBarClosed',
|
||||||
|
})
|
||||||
|
|
||||||
await u.waitForPageLoad()
|
await u.waitForPageLoad()
|
||||||
|
|
||||||
@ -1588,7 +1615,7 @@ test(
|
|||||||
await expect(page.getByText('Create project')).toBeVisible()
|
await expect(page.getByText('Create project')).toBeVisible()
|
||||||
})
|
})
|
||||||
|
|
||||||
await test.step('Opening the router-template project should load the stream', async () => {
|
await test.step('Opening the router-template project via link should load the stream', async () => {
|
||||||
// expect to see the text bracket
|
// expect to see the text bracket
|
||||||
await expect(page.getByText('router-template-slate')).toBeVisible()
|
await expect(page.getByText('router-template-slate')).toBeVisible()
|
||||||
|
|
||||||
@ -1605,16 +1632,26 @@ test(
|
|||||||
.toBeLessThan(15)
|
.toBeLessThan(15)
|
||||||
})
|
})
|
||||||
|
|
||||||
await test.step('Opening the router-template project should load the stream', async () => {
|
await test.step('The projects on the home page should still be normal', async () => {
|
||||||
await page.getByTestId('project-sidebar-toggle').click()
|
await page.getByTestId('project-sidebar-toggle').click()
|
||||||
await expect(
|
await expect(
|
||||||
page.getByRole('button', { name: 'Go to Home' })
|
page.getByRole('button', { name: 'Go to Home' })
|
||||||
).toBeVisible()
|
).toBeVisible()
|
||||||
await page.getByRole('button', { name: 'Go to Home' }).click()
|
await page.getByRole('button', { name: 'Go to Home' }).click()
|
||||||
|
|
||||||
await expect(page.getByRole('link', { name: 'bracket' })).toBeVisible()
|
await homePage.expectState({
|
||||||
await expect(page.getByText('router-template-slate')).toBeVisible()
|
projectCards: [
|
||||||
await expect(page.getByText('Create project')).toBeVisible()
|
{
|
||||||
|
title: 'bracket',
|
||||||
|
fileCount: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'router-template-slate',
|
||||||
|
fileCount: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
sortBy: 'last-modified-desc',
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -98,6 +98,7 @@ export const CommandBar = () => {
|
|||||||
'fixed inset-0 z-50 overflow-y-auto pb-4 pt-1 ' +
|
'fixed inset-0 z-50 overflow-y-auto pb-4 pt-1 ' +
|
||||||
(isSelectionArgument ? 'pointer-events-none' : '')
|
(isSelectionArgument ? 'pointer-events-none' : '')
|
||||||
}
|
}
|
||||||
|
data-testid="command-bar-wrapper"
|
||||||
>
|
>
|
||||||
<Transition.Child
|
<Transition.Child
|
||||||
enter="duration-100 ease-out"
|
enter="duration-100 ease-out"
|
||||||
|
@ -41,12 +41,11 @@ export const projectsCommandBarConfig: StateMachineCommandSetConfig<
|
|||||||
name: {
|
name: {
|
||||||
inputType: 'options',
|
inputType: 'options',
|
||||||
required: true,
|
required: true,
|
||||||
options: [],
|
options: (_, context) =>
|
||||||
optionsFromContext: (context) =>
|
context?.projects.map((p) => ({
|
||||||
context.projects.map((p) => ({
|
name: p.name,
|
||||||
name: p.name!,
|
value: p.name,
|
||||||
value: p.name!,
|
})) || [],
|
||||||
})),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user