diff --git a/e2e/playwright/fixtures/cmdBarFixture.ts b/e2e/playwright/fixtures/cmdBarFixture.ts
index 8754f879b..a51562e60 100644
--- a/e2e/playwright/fixtures/cmdBarFixture.ts
+++ b/e2e/playwright/fixtures/cmdBarFixture.ts
@@ -3,7 +3,7 @@ import { expect } from '@playwright/test'
import * as fs from 'fs'
import * as path from 'path'
-type CmdBarSerialised =
+export type CmdBarSerialised =
| {
stage: 'commandBarClosed'
}
diff --git a/e2e/playwright/fixtures/toolbarFixture.ts b/e2e/playwright/fixtures/toolbarFixture.ts
index 8b98af630..dbe5c9933 100644
--- a/e2e/playwright/fixtures/toolbarFixture.ts
+++ b/e2e/playwright/fixtures/toolbarFixture.ts
@@ -27,6 +27,7 @@ export class ToolbarFixture {
offsetPlaneButton!: Locator
helixButton!: Locator
startSketchBtn!: Locator
+ insertButton!: Locator
lineBtn!: Locator
tangentialArcBtn!: Locator
circleBtn!: Locator
@@ -44,7 +45,7 @@ export class ToolbarFixture {
featureTreePane!: Locator
gizmo!: Locator
gizmoDisabled!: Locator
- insertButton!: Locator
+ loadButton!: Locator
constructor(page: Page) {
this.page = page
@@ -59,6 +60,7 @@ export class ToolbarFixture {
this.offsetPlaneButton = page.getByTestId('plane-offset')
this.helixButton = page.getByTestId('helix')
this.startSketchBtn = page.getByTestId('sketch')
+ this.insertButton = page.getByTestId('insert')
this.lineBtn = page.getByTestId('line')
this.tangentialArcBtn = page.getByTestId('tangential-arc')
this.circleBtn = page.getByTestId('circle-center')
@@ -68,6 +70,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.filePane = page.locator('#files-pane')
this.featureTreePane = page.locator('#feature-tree-pane')
@@ -79,8 +82,6 @@ export class ToolbarFixture {
// element or two different elements can represent these states.
this.gizmo = page.getByTestId('gizmo')
this.gizmoDisabled = page.getByTestId('gizmo-disabled')
-
- this.insertButton = page.getByTestId('insert-pane-button')
}
get logoLink() {
diff --git a/e2e/playwright/native-file-menu.spec.ts b/e2e/playwright/native-file-menu.spec.ts
index 3b753794b..f8d571ac0 100644
--- a/e2e/playwright/native-file-menu.spec.ts
+++ b/e2e/playwright/native-file-menu.spec.ts
@@ -534,7 +534,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
const expected = 'Open project'
expect(actual).toBe(expected)
})
- test('Modeling.File.Load a sample model', async ({
+ test('Modeling.File.Load external model', async ({
tronApp,
cmdBar,
page,
@@ -555,10 +555,10 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
throw new Error('app or app.applicationMenu is missing')
}
const openProject = app.applicationMenu.getMenuItemById(
- 'File.Load a sample model'
+ 'File.Load external model'
)
if (!openProject) {
- throw new Error('File.Load a sample model')
+ throw new Error('File.Load external model')
}
openProject.click()
})
@@ -568,44 +568,7 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
const actual = await cmdBar.cmdBarElement
.getByTestId('command-name')
.textContent()
- const expected = 'Open sample'
- expect(actual).toBe(expected)
- })
- test('Modeling.File.Insert from project file', async ({
- tronApp,
- cmdBar,
- page,
- homePage,
- scene,
- }) => {
- if (!tronApp) {
- throwTronAppMissing()
- return
- }
- await homePage.goToModelingScene()
- await scene.settled(cmdBar)
-
- // Run electron snippet to find the Menu!
- await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
- await tronApp.electron.evaluate(async ({ app }) => {
- if (!app || !app.applicationMenu) {
- throw new Error('app or app.applicationMenu is missing')
- }
- const openProject = app.applicationMenu.getMenuItemById(
- 'File.Insert from project file'
- )
- if (!openProject) {
- throw new Error('File.Insert from project file')
- }
- openProject.click()
- })
- // Check that the command bar is opened
- await expect(cmdBar.cmdBarElement).toBeVisible()
- // Check the placeholder project name exists
- const actual = await cmdBar.cmdBarElement
- .getByTestId('command-name')
- .textContent()
- const expected = 'Insert'
+ const expected = 'Load external model'
expect(actual).toBe(expected)
})
test('Modeling.File.Export current part', async ({
@@ -2159,6 +2122,44 @@ test.describe('Native file menu', { tag: ['@electron'] }, () => {
expect(actual).toBe(expected)
})
+ test('Modeling.Design.Insert from project file', async ({
+ tronApp,
+ cmdBar,
+ page,
+ homePage,
+ scene,
+ }) => {
+ if (!tronApp) {
+ throwTronAppMissing()
+ return
+ }
+ await homePage.goToModelingScene()
+ await scene.settled(cmdBar)
+
+ // Run electron snippet to find the Menu!
+ await page.waitForTimeout(100) // wait for createModelingPageMenu() to run
+ await tronApp.electron.evaluate(async ({ app }) => {
+ if (!app || !app.applicationMenu) {
+ throw new Error('app or app.applicationMenu is missing')
+ }
+ const openProject = app.applicationMenu.getMenuItemById(
+ 'Design.Insert from project file'
+ )
+ if (!openProject) {
+ throw new Error('Design.Insert from project file')
+ }
+ openProject.click()
+ })
+ // Check that the command bar is opened
+ await expect(cmdBar.cmdBarElement).toBeVisible()
+ // Check the placeholder project name exists
+ const actual = await cmdBar.cmdBarElement
+ .getByTestId('command-name')
+ .textContent()
+ const expected = 'Insert'
+ expect(actual).toBe(expected)
+ })
+
test('Modeling.Design.Create with Zoo Text-To-CAD', async ({
tronApp,
cmdBar,
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png
index 5588d0291..8bb7bf691 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png
index 8caa73e91..2d7ddb690 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Inch-scale-2-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-1-Google-Chrome-linux.png
index 86a220ca1..482a2f052 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png
index d2912b374..7a663e105 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Client-side-scene-scale-should-match-engine-scale-Millimeter-scale-2-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png
index 1817c33ee..9e0b760c6 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-circle-should-look-right-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png
index 5d24a83cc..2f045e1a1 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-rectangles-should-look-right-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png
index f42dc8860..1167ae89e 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png
index 2e6cc3b82..1f8f5a15e 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-2-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png
index 4f7f6313b..01eccb71d 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-3-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png
index 3297d65f4..74f876f31 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-4-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-5-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-5-Google-Chrome-linux.png
index ec849f4f3..50215cecc 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-5-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Draft-segments-should-look-right-5-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png
index d2a9c2f82..0f7cd8d2c 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png
index 1335cd834..f17c6f989 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-off-to-on-via-command-bar-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-on-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-on-1-Google-Chrome-linux.png
index 6ea2e87f8..588b60b54 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-on-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Grid-visibility-Grid-turned-on-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png
index d1f647232..3f0a04d1a 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Sketch-on-face-with-none-z-up-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png
index 8d77007aa..f0e48e88c 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-2d-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png
index 99e959f14..7ba9823d4 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/Zoom-to-fit-on-load---solid-3d-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png
index fe71b9a65..df2538741 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png
index 0eac3e0e3..567fcf160 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/code-color-goober-code-color-goober-opening-window-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png
index 0e76ac3c0..18f2db487 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XY-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png
index 3f5064454..b3e371dac 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--XZ-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png
index 1191c202e..658af6c2c 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable--YZ-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png
index d1aa00dc8..a8370f56b 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XY-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png
index 65d7e48c7..47ccb5b9e 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-XZ-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png
index 9d7c655e5..0fdd83740 100644
Binary files a/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png and b/e2e/playwright/snapshot-tests.spec.ts-snapshots/extrude-on-default-planes-should-be-stable-YZ-1-Google-Chrome-linux.png differ
diff --git a/e2e/playwright/testing-samples-loading.spec.ts b/e2e/playwright/testing-samples-loading.spec.ts
index 4b54d117c..01cce02c1 100644
--- a/e2e/playwright/testing-samples-loading.spec.ts
+++ b/e2e/playwright/testing-samples-loading.spec.ts
@@ -3,14 +3,18 @@ import { FILE_EXT } from '@src/lib/constants'
import * as fsp from 'fs/promises'
import { join } from 'path'
+import type { CmdBarSerialised } from '@e2e/playwright/fixtures/cmdBarFixture'
+import type { ElectronZoo } from '@e2e/playwright/fixtures/fixtureSetup'
import {
+ executorInputPath,
getUtils,
orRunWhenFullSuiteEnabled,
runningOnWindows,
+ testsInputPath,
} from '@e2e/playwright/test-utils'
import { expect, test } from '@e2e/playwright/zoo-test'
-test.describe('Testing in-app sample loading', () => {
+test.describe('Testing loading external models', () => {
/**
* Note this test implicitly depends on the KCL sample "parametric-bearing-pillow-block",
* its title, and its units settings. https://github.com/KittyCAD/kcl-samples/blob/main/parametric-bearing-pillow-block/main.kcl
@@ -39,7 +43,7 @@ test.describe('Testing in-app sample loading', () => {
}
const commandBarButton = page.getByRole('button', { name: 'Commands' })
const samplesCommandOption = page.getByRole('option', {
- name: 'Open Sample',
+ name: 'Load external model',
})
const commandSampleOption = page.getByRole('option', {
name: newSample.title,
@@ -83,7 +87,7 @@ test.describe('Testing in-app sample loading', () => {
test(
'Desktop: should create new file by default, optionally overwrite',
{ tag: '@electron' },
- async ({ editor, context, page, scene, cmdBar }, testInfo) => {
+ async ({ editor, context, page, scene, cmdBar, toolbar }) => {
if (runningOnWindows()) {
test.fixme(orRunWhenFullSuiteEnabled())
}
@@ -106,20 +110,12 @@ test.describe('Testing in-app sample loading', () => {
title: '100mm Gear Rack',
}
const projectCard = page.getByRole('link', { name: 'bracket' })
- const commandBarButton = page.getByRole('button', { name: 'Commands' })
- const commandOption = page.getByRole('option', { name: 'Open Sample' })
- const commandSampleOption = (name: string) =>
- page.getByRole('option', {
- name,
- exact: true,
- })
const commandMethodArgButton = page.getByRole('button', {
name: 'Method',
})
const commandMethodOption = page.getByRole('option', {
name: 'Overwrite',
})
- const newFileWarning = page.getByText('Create a new file from sample?')
const overwriteWarning = page.getByText(
'Overwrite current file with sample?'
)
@@ -129,6 +125,18 @@ test.describe('Testing in-app sample loading', () => {
page.getByRole('listitem').filter({
has: page.getByRole('button', { name }),
})
+ const defaultLoadCmdBarState: CmdBarSerialised = {
+ commandName: 'Load external model',
+ currentArgKey: 'source',
+ currentArgValue: '',
+ headerArguments: {
+ Method: 'newFile',
+ Sample: '',
+ Source: '',
+ },
+ highlightedHeaderArg: 'source',
+ stage: 'arguments',
+ }
await test.step(`Test setup`, async () => {
await page.setBodyDimensions({ width: 1200, height: 500 })
@@ -147,14 +155,12 @@ test.describe('Testing in-app sample loading', () => {
})
await test.step(`Load a KCL sample with the command palette`, async () => {
- await commandBarButton.click()
- await page.waitForTimeout(1000)
- await commandOption.click()
- await page.waitForTimeout(1000)
- await commandSampleOption(sampleOne.title).click()
+ await toolbar.loadButton.click()
+ await cmdBar.expectState(defaultLoadCmdBarState)
+ await cmdBar.progressCmdBar()
+ await cmdBar.selectOption({ name: sampleOne.title }).click()
await expect(overwriteWarning).not.toBeVisible()
- await expect(newFileWarning).toBeVisible()
- await confirmButton.click()
+ await cmdBar.progressCmdBar()
await page.waitForTimeout(1000)
})
@@ -165,21 +171,15 @@ test.describe('Testing in-app sample loading', () => {
})
await test.step(`Now overwrite the current file`, async () => {
- await commandBarButton.click()
- await page.waitForTimeout(1000)
- await commandOption.click()
- await page.waitForTimeout(1000)
- await commandSampleOption(sampleTwo.title).click()
- await page.waitForTimeout(1000)
+ await toolbar.loadButton.click()
+ await cmdBar.expectState(defaultLoadCmdBarState)
+ await cmdBar.progressCmdBar()
+ await cmdBar.selectOption({ name: sampleTwo.title }).click()
await commandMethodArgButton.click()
- await page.waitForTimeout(1000)
await commandMethodOption.click()
- await page.waitForTimeout(1000)
await expect(commandMethodArgButton).toContainText('overwrite')
- await expect(newFileWarning).not.toBeVisible()
await expect(overwriteWarning).toBeVisible()
await confirmButton.click()
- await page.waitForTimeout(1000)
})
await test.step(`Ensure we overwrote the current file without navigating`, async () => {
@@ -200,4 +200,96 @@ test.describe('Testing in-app sample loading', () => {
})
}
)
+
+ const externalModelCases = [
+ {
+ modelName: 'cylinder.kcl',
+ deconflictedModelName: 'cylinder-1.kcl',
+ modelPath: executorInputPath('cylinder.kcl'),
+ },
+ {
+ modelName: 'cube.step',
+ deconflictedModelName: 'cube-1.step',
+ modelPath: testsInputPath('cube.step'),
+ },
+ ]
+ externalModelCases.map(({ modelName, deconflictedModelName, modelPath }) => {
+ test(
+ `Load external models from local drive - ${modelName}`,
+ { tag: ['@electron'] },
+ async ({ page, homePage, scene, toolbar, cmdBar, tronApp }) => {
+ if (!tronApp) {
+ fail()
+ }
+
+ await page.setBodyDimensions({ width: 1000, height: 500 })
+ await homePage.goToModelingScene()
+ await scene.settled(cmdBar)
+ const modelFileContent = await fsp.readFile(modelPath, 'utf-8')
+ const { editorTextMatches } = await getUtils(page, test)
+
+ async function loadExternalFileThroughCommandBar(tronApp: ElectronZoo) {
+ await toolbar.loadButton.click()
+ await cmdBar.expectState({
+ commandName: 'Load external model',
+ currentArgKey: 'source',
+ currentArgValue: '',
+ headerArguments: {
+ Method: 'newFile',
+ Sample: '',
+ Source: '',
+ },
+ highlightedHeaderArg: 'source',
+ stage: 'arguments',
+ })
+ await cmdBar.selectOption({ name: 'Local Drive' }).click()
+
+ // Mock the file picker selection
+ const handleFile = tronApp.electron.evaluate(
+ async ({ dialog }, filePaths) => {
+ dialog.showOpenDialog = () =>
+ Promise.resolve({ canceled: false, filePaths })
+ },
+ [modelPath]
+ )
+ await page.getByTestId('cmd-bar-arg-file-button').click()
+ await handleFile
+
+ await cmdBar.progressCmdBar()
+ await cmdBar.expectState({
+ commandName: 'Load external model',
+ headerArguments: {
+ Source: 'local',
+ Path: modelName,
+ },
+ stage: 'review',
+ })
+ await cmdBar.progressCmdBar()
+ }
+
+ await test.step('Load the external model from local drive', async () => {
+ await loadExternalFileThroughCommandBar(tronApp)
+ // TODO: I think the files pane should auto open?
+ await toolbar.openPane('files')
+ await toolbar.expectFileTreeState([modelName, 'main.kcl'])
+ if (modelName.endsWith('.kcl')) {
+ await editorTextMatches(modelFileContent)
+ }
+ })
+
+ await test.step('Load the same external model, except deconflicted name', async () => {
+ await loadExternalFileThroughCommandBar(tronApp)
+ await toolbar.openPane('files')
+ await toolbar.expectFileTreeState([
+ deconflictedModelName,
+ modelName,
+ 'main.kcl',
+ ])
+ if (modelName.endsWith('.kcl')) {
+ await editorTextMatches(modelFileContent)
+ }
+ })
+ }
+ )
+ })
})
diff --git a/src/components/CommandBar/CommandBarArgument.tsx b/src/components/CommandBar/CommandBarArgument.tsx
index 0418c3c95..6f15e9630 100644
--- a/src/components/CommandBar/CommandBarArgument.tsx
+++ b/src/components/CommandBar/CommandBarArgument.tsx
@@ -2,6 +2,7 @@ import CommandArgOptionInput from '@src/components/CommandBar/CommandArgOptionIn
import CommandBarBasicInput from '@src/components/CommandBar/CommandBarBasicInput'
import CommandBarHeader from '@src/components/CommandBar/CommandBarHeader'
import CommandBarKclInput from '@src/components/CommandBar/CommandBarKclInput'
+import CommandBarPathInput from '@src/components/CommandBar/CommandBarPathInput'
import CommandBarSelectionInput from '@src/components/CommandBar/CommandBarSelectionInput'
import CommandBarSelectionMixedInput from '@src/components/CommandBar/CommandBarSelectionMixedInput'
import CommandBarTextareaInput from '@src/components/CommandBar/CommandBarTextareaInput'
@@ -108,6 +109,14 @@ function ArgumentInput({
onSubmit={onSubmit}
/>
)
+ case 'path':
+ return (
+
+ )
default:
return (
) =>
+ snapshot?.context
+
+function CommandBarPathInput({
+ arg,
+ stepBack,
+ onSubmit,
+}: {
+ arg: CommandArgument & {
+ inputType: 'path'
+ name: string
+ }
+ stepBack: () => void
+ onSubmit: (event: unknown) => void
+}) {
+ const commandBarState = useCommandBarState()
+ useHotkeys('mod + k, mod + /', () => commandBarActor.send({ type: 'Close' }))
+ const inputRef = useRef(null)
+ const argMachineContext = useSelector(
+ arg.machineActor,
+ machineContextSelector
+ )
+ const defaultValue = useMemo(
+ () =>
+ arg.defaultValue
+ ? arg.defaultValue instanceof Function
+ ? arg.defaultValue(commandBarState.context, argMachineContext)
+ : arg.defaultValue
+ : '',
+ [arg.defaultValue, commandBarState.context, argMachineContext]
+ )
+
+ function handleSubmit(e: React.FormEvent) {
+ e.preventDefault()
+ onSubmit(inputRef.current?.value)
+ }
+
+ async function pickFileThroughNativeDialog() {
+ // In desktop end-to-end tests we can't control the file picker,
+ // so we seed the new directory value in the element's dataset
+ const inputRefVal = inputRef.current?.dataset.testValue
+ if (inputRef.current && inputRefVal && !isArray(inputRefVal)) {
+ inputRef.current.value = inputRefVal
+ } else if (inputRef.current) {
+ const newPath = await window.electron.open({
+ properties: ['openFile'],
+ title: 'Pick a file to load into the current project',
+ })
+ if (newPath.canceled) return
+ inputRef.current.value = newPath.filePaths[0]
+ } else {
+ return new Error("Couldn't find inputRef")
+ }
+ }
+
+ // Fire on component mount, if outside of e2e test context
+ useEffect(() => {
+ window.electron.process.env.IS_PLAYWRIGHT !== 'true' &&
+ toSync(pickFileThroughNativeDialog, reportRejection)()
+ }, [])
+
+ return (
+
+ )
+}
+
+export default CommandBarPathInput
diff --git a/src/components/CustomIcon.tsx b/src/components/CustomIcon.tsx
index b3179c9bf..49c0b3222 100644
--- a/src/components/CustomIcon.tsx
+++ b/src/components/CustomIcon.tsx
@@ -619,6 +619,22 @@ const CustomIconMap = {
/>
),
+ importFile: (
+
+ ),
'intersection-offset': (