[Feature]: Load external model becomes Add file to project, global application add file to project with home page update. (#6506)
* chore: saving off skeleton
* fix: saving skeleton
* chore: skeleton for loading projects from project directory path
* chore: cleaning up useless state transition to be an on event direct to action state
* fix: new structure for web vs desktop vs react machine provider code
* chore: saving off skeleton
* fix: skeleton logic for react? going to move it from a string to obj.string
* fix: trying to prevent error element unmount on global react components. This is bricking JS state
* fix: we are so back
* chore: implemented navigating to specfic KCL file
* chore: implementing renaming project
* chore: deleting project
* fix: auto fixes
* fix: old debug/testing file oops
* chore: generic create new file
* chore: skeleton for web create file provide
* chore: basic machine vitest... need to figure out how to get window.electron implemented in vitest?
* chore: save off progress before deleting other project implementation, a few missing features still
* chore: trying a different init skeleton? most likely will migrate
* chore: first attempt of purging projects context provider
* chore: enabling toast for some machine state
* chore: enabling more toast success and error
* chore: writing read write state to the system io based on the project path
* fix: tsc fixes
* fix: use file system watcher, navigate to project after creation via the requestProjectName
* chore: open project command, hooks vs snapshot context helpers
* chore: implemented open and create project for e2e testing. They are hard coded in poor spot for now.
* fix: codespell fixes
* chore: implementing more project commands
* chore: PR improvements for root.tsx
* chore: leaving comment about new Router.tsx layout
* fix: removing debugging code
* fix: rewriting component for readability
* fix: improving web initialization
* chore: implementing import file from url which is not actually that?
* fix: clearing search params on import file from url
* fix: fixed two e2e tests, forgot needsReview when making new command
* fix: fixing some import from url business logic to pass e2e tests
* chore: script for diffing circular deps +/-
* fix: formatting
* fix: massive fix for circular depsga!
* fix: trying to fix some errors and auto fmt
* fix: updating deps
* fix: removing debugging code
* fix: big clean up
* fix: more deletion
* fix: tsc cleanup
* fix: TSC TSC TSC TSC!
* fix: typo fix
* fix: clear query params on web only, desktop not required
* fix: removing unused code
* fmt
* Bring back `trap` removed in merge
* Use explicit types instead of `any`s on arg configs
* Add project commands directly to command palette
* fix: deleting debugging code, from PR review
* fix: this got added back(?)
* fix: using referred type
* fix: more PR clean up
* fix: big block comment for xstate architecture decision
* fix: more pr comment fixes
* fix: saving off logic, need a big cleanup because I hacked it together to get a POC
* fix: extra business?
* fix: merge conflict just added them back why dude
* fix: more PR comments
* fix: big ciruclar deps fix, commandBarActor in appActor
* chore: writing e2e test, still need to fix 3 bugs
* chore: adding more scenarios
* fix: formatting
* fix: fixing tsc errors
* chore: deleting the old text to cad and using the new application level one, almost there
* fix: prompt to edit works
* fix: large push to get 1 text to cad command... the usage is a little buggy with delete and navigate within /file
* fix: settings for highlight edges now works
* chore: adding another e2e test
* fix: cleaning up e2e tests and writing more of them
* fix: tsc type
* chore: more e2e improvements, unique project name in text to cad
* chore: e2e tests should be good to go
* fix: gotcha comment
* fix: enabled web t2c, codespell fixes
* fix: fixing merge conflcits??
* feat: implemented load external for kcl samples
* feat: load external model from disk
* fix: trying to delete old stuff
* fix: all command trigger locations now have defaults for current project
* fix: gotcha comment for the future
* chore: hiding import file from url command, two separate commands for 3d and kcl file adding
* chore: commands are now add file to project, 3rd iteration
* fix: t2c in file menu fixed
* chore: updating file menu for new global actions
* fix: auto fixes
* fix: the command bar arg flow for web add kcl file seems backwards?
* chore: updated home layout, added create from kcl sample button
* chore: remapping some menu actions
* fix: fixing open dialog copy
* fix: an e2e test
* fix: fixed e2e tests
* fix: fixed e2e tests
* fix: auto fixes
* fix: pr clean up
* fix: removing console log
* fix: PR updates
* fix: the reviewed stage boolean required the expected state to change. Also I progressed the command bar too soon
* fix: no idea how this passed locally yesterday? I removed the {dir} unused but I need the function's logic but not the return value...
* fix: should be good to go?
---------
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
This commit is contained in:
@ -73,7 +73,7 @@ export class ToolbarFixture {
|
||||
this.fileTreeBtn = page.locator('[id="files-button-holder"]')
|
||||
this.createFileBtn = page.getByTestId('create-file-button')
|
||||
this.treeInputField = page.getByTestId('tree-input-field')
|
||||
this.loadButton = page.getByTestId('load-external-model-pane-button')
|
||||
this.loadButton = page.getByTestId('add-file-to-project-pane-button')
|
||||
|
||||
this.filePane = page.locator('#files-pane')
|
||||
this.featureTreePane = page.locator('#feature-tree-pane')
|
||||
|
||||
@ -550,7 +550,7 @@ test.describe(
|
||||
const expected = 'Open project'
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
test('Modeling.File.Load external model', async ({
|
||||
test('Modeling.File.Add file to project', async ({
|
||||
tronApp,
|
||||
cmdBar,
|
||||
page,
|
||||
@ -571,10 +571,10 @@ test.describe(
|
||||
throw new Error('app or app.applicationMenu is missing')
|
||||
}
|
||||
const openProject = app.applicationMenu.getMenuItemById(
|
||||
'File.Load external model'
|
||||
'File.Add file to project'
|
||||
)
|
||||
if (!openProject) {
|
||||
throw new Error('File.Load external model')
|
||||
throw new Error('File.Add file to project')
|
||||
}
|
||||
openProject.click()
|
||||
})
|
||||
@ -584,7 +584,7 @@ test.describe(
|
||||
const actual = await cmdBar.cmdBarElement
|
||||
.getByTestId('command-name')
|
||||
.textContent()
|
||||
const expected = 'Load external model'
|
||||
const expected = 'Add file to project'
|
||||
expect(actual).toBe(expected)
|
||||
})
|
||||
test('Modeling.File.Export current part', async ({
|
||||
|
||||
@ -23,7 +23,6 @@ test.describe('Testing loading external models', () => {
|
||||
'Web: should overwrite current code, cannot create new file',
|
||||
async ({ editor, context, page, homePage }) => {
|
||||
const u = await getUtils(page)
|
||||
|
||||
await test.step(`Test setup`, async () => {
|
||||
await context.addInitScript((code) => {
|
||||
window.localStorage.setItem('persistCode', code)
|
||||
@ -82,12 +81,13 @@ test.describe('Testing loading external models', () => {
|
||||
* "gear-rack": https://github.com/KittyCAD/kcl-samples/blob/main/gear-rack/main.kcl
|
||||
*/
|
||||
test(
|
||||
'Desktop: should create new file by default, optionally overwrite',
|
||||
'Desktop: should create new file by default, creates a second file with automatic unique name',
|
||||
{ tag: '@electron' },
|
||||
async ({ editor, context, page, scene, cmdBar, toolbar }) => {
|
||||
if (runningOnWindows()) {
|
||||
}
|
||||
const { dir } = await context.folderSetupFn(async (dir) => {
|
||||
|
||||
await context.folderSetupFn(async (dir) => {
|
||||
const bracketDir = join(dir, 'bracket')
|
||||
await fsp.mkdir(bracketDir, { recursive: true })
|
||||
await fsp.writeFile(join(bracketDir, 'main.kcl'), bracket, {
|
||||
@ -100,37 +100,28 @@ test.describe('Testing loading external models', () => {
|
||||
const sampleOne = {
|
||||
file: 'parametric-bearing-pillow-block' + FILE_EXT,
|
||||
title: 'Parametric Bearing Pillow Block',
|
||||
}
|
||||
const sampleTwo = {
|
||||
file: 'gear-rack' + FILE_EXT,
|
||||
title: '100mm Gear Rack',
|
||||
file1: 'parametric-bearing-pillow-block-1' + FILE_EXT,
|
||||
}
|
||||
const projectCard = page.getByRole('link', { name: 'bracket' })
|
||||
const commandMethodArgButton = page.getByRole('button', {
|
||||
name: 'Method',
|
||||
})
|
||||
const commandMethodOption = page.getByRole('option', {
|
||||
name: 'Overwrite',
|
||||
})
|
||||
const overwriteWarning = page.getByText(
|
||||
'Overwrite current file with sample?'
|
||||
)
|
||||
const confirmButton = page.getByRole('button', { name: 'Submit command' })
|
||||
const projectMenuButton = page.getByTestId('project-sidebar-toggle')
|
||||
const newlyCreatedFile = (name: string) =>
|
||||
page.getByRole('listitem').filter({
|
||||
has: page.getByRole('button', { name }),
|
||||
})
|
||||
const defaultLoadCmdBarState: CmdBarSerialised = {
|
||||
commandName: 'Load external model',
|
||||
currentArgKey: 'source',
|
||||
commandName: 'Add file to project',
|
||||
currentArgKey: 'sample',
|
||||
currentArgValue: '',
|
||||
headerArguments: {
|
||||
Method: 'newFile',
|
||||
Method: 'Existing project',
|
||||
Sample: '',
|
||||
Source: '',
|
||||
Source: 'kcl-samples',
|
||||
ProjectName: 'bracket',
|
||||
},
|
||||
highlightedHeaderArg: 'source',
|
||||
highlightedHeaderArg: 'sample',
|
||||
stage: 'arguments',
|
||||
}
|
||||
|
||||
@ -152,11 +143,10 @@ test.describe('Testing loading external models', () => {
|
||||
|
||||
await test.step(`Load a KCL sample with the command palette`, async () => {
|
||||
await toolbar.loadButton.click()
|
||||
await cmdBar.selectOption({ name: 'KCL Samples' }).click()
|
||||
await cmdBar.expectState(defaultLoadCmdBarState)
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.selectOption({ name: sampleOne.title }).click()
|
||||
await expect(overwriteWarning).not.toBeVisible()
|
||||
await cmdBar.progressCmdBar()
|
||||
await page.waitForTimeout(1000)
|
||||
})
|
||||
|
||||
@ -166,33 +156,19 @@ test.describe('Testing loading external models', () => {
|
||||
await expect(projectMenuButton).toContainText(sampleOne.file)
|
||||
})
|
||||
|
||||
await test.step(`Now overwrite the current file`, async () => {
|
||||
await test.step(`Load a KCL sample with the command palette`, async () => {
|
||||
await toolbar.loadButton.click()
|
||||
await cmdBar.selectOption({ name: 'KCL Samples' }).click()
|
||||
await cmdBar.expectState(defaultLoadCmdBarState)
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.selectOption({ name: sampleTwo.title }).click()
|
||||
await commandMethodArgButton.click()
|
||||
await commandMethodOption.click()
|
||||
await expect(commandMethodArgButton).toContainText('overwrite')
|
||||
await expect(overwriteWarning).toBeVisible()
|
||||
await confirmButton.click()
|
||||
await cmdBar.selectOption({ name: sampleOne.title }).click()
|
||||
await expect(overwriteWarning).not.toBeVisible()
|
||||
await page.waitForTimeout(1000)
|
||||
})
|
||||
|
||||
await test.step(`Ensure we overwrote the current file without navigating`, async () => {
|
||||
await editor.expectEditor.toContain('// ' + sampleTwo.title)
|
||||
await test.step(`Check actual file contents`, async () => {
|
||||
await expect
|
||||
.poll(async () => {
|
||||
return await fsp.readFile(
|
||||
join(dir, 'bracket', sampleOne.file),
|
||||
'utf-8'
|
||||
)
|
||||
})
|
||||
.toContain('// ' + sampleTwo.title)
|
||||
})
|
||||
await expect(newlyCreatedFile(sampleOne.file)).toBeVisible()
|
||||
await expect(newlyCreatedFile(sampleTwo.file)).not.toBeVisible()
|
||||
await expect(projectMenuButton).toContainText(sampleOne.file)
|
||||
await test.step(`Ensure we made and opened a new file with a unique name`, async () => {
|
||||
await editor.expectEditor.toContain('// ' + sampleOne.title)
|
||||
await expect(newlyCreatedFile(sampleOne.file1)).toBeVisible()
|
||||
await expect(projectMenuButton).toContainText(sampleOne.file1)
|
||||
})
|
||||
}
|
||||
)
|
||||
@ -226,19 +202,20 @@ test.describe('Testing loading external models', () => {
|
||||
|
||||
async function loadExternalFileThroughCommandBar(tronApp: ElectronZoo) {
|
||||
await toolbar.loadButton.click()
|
||||
await cmdBar.selectOption({ name: 'Local Drive' }).click()
|
||||
await cmdBar.expectState({
|
||||
commandName: 'Load external model',
|
||||
currentArgKey: 'source',
|
||||
commandName: 'Add file to project',
|
||||
currentArgKey: 'pathOpen file',
|
||||
currentArgValue: '',
|
||||
headerArguments: {
|
||||
Method: 'newFile',
|
||||
Sample: '',
|
||||
Source: '',
|
||||
Method: 'Existing project',
|
||||
Path: '',
|
||||
Source: 'local',
|
||||
ProjectName: 'testDefault',
|
||||
},
|
||||
highlightedHeaderArg: 'source',
|
||||
highlightedHeaderArg: 'path',
|
||||
stage: 'arguments',
|
||||
})
|
||||
await cmdBar.selectOption({ name: 'Local Drive' }).click()
|
||||
|
||||
// Mock the file picker selection
|
||||
const handleFile = tronApp.electron.evaluate(
|
||||
@ -251,14 +228,18 @@ test.describe('Testing loading external models', () => {
|
||||
await page.getByTestId('cmd-bar-arg-file-button').click()
|
||||
await handleFile
|
||||
|
||||
await cmdBar.progressCmdBar()
|
||||
await cmdBar.expectState({
|
||||
commandName: 'Load external model',
|
||||
commandName: 'Add file to project',
|
||||
currentArgKey: 'pathOpen file',
|
||||
currentArgValue: '',
|
||||
headerArguments: {
|
||||
Method: 'Existing project',
|
||||
Path: '',
|
||||
Source: 'local',
|
||||
Path: modelName,
|
||||
ProjectName: 'testDefault',
|
||||
},
|
||||
stage: 'review',
|
||||
highlightedHeaderArg: 'path',
|
||||
stage: 'arguments',
|
||||
})
|
||||
await cmdBar.progressCmdBar()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user