* Add back stream idle mode
* Shut up codespell
* Correct serialization; only expose at user level
* cargo fmt
* tsc lint fmt
* Move engineStreamMachine as a global actor; tons of more work
* Fix up everything after bumping kittycad/lib
* Remove camera sync
* Use pause/play iconology
* Add back better ping indicator
* wip
* Fix streamIdleMode checkbox being wonky
* yarn fmt
* Massive extinction event for waitForExecutionDone; try to stop projects view switching from crashing
* Clear diagnostics when unmounting code editor!
* wip
* Rework initial root projects dir + deflake many projects tests
* More e2e fixes
* Deflake revolve some revolve tests
* Fix the rest of the mfing tests
* yarn fmt
* yarn lint
* yarn tsc
* Fix tsc after rebase
* wip
* less flaky point and click
* wip
* Fixup after rebase
* Fix more tests
* Fix 2 more
* Fix up named-views tests
* yarn fmt lint tsc
* Fix up new changes
* Get rid of 1 cyclic dependency
* Fix another cyclic mfer!
* fmt
* fmt tsc
* Fix zoom to fit being frigged
* a new list of circular deps
* Remove NetworkHealthIndicator test that was shit
* Fix the bad reload repeat issue kevin started on
* Fix zoom to fit at the right moments...
* Fix cache count numbers in editor test
* Remove a test race - poll window info.
* Qualify fail function
* Try something
* Use scene.connectionEstablished
* Hopefully fix snapshots at least
* Add app console.log
* Fix native menu tests more
* tsc lint
* Fix camera failure
* Try again
* Test attempt number 15345203, action!
* Add back old window detection heuristic
* Remove firstWindow to complete the work of 2342d04fe2
* Tweak some tests for MacOS
* Tweak "set appearance" test for MacOS
Revert this if it messes up any other platform's color checks!
* Are you serious? This was all that needed formatting?
* More color tweaks
Local MacOS and CI MacOS don't agree
* Fixes on apperance e2e test for stream idle branch (#6168)
pierremtb/stream-idle-revamp-appearance-fixes
* Another apperance fix
* Skip one native menu test to make stream idle green (#6169)
* pierremtb/stream-idle-revamp-more-fixes
* Fix lint
* Update snapshot for test_generate_settings_docs
---------
Co-authored-by: lee-at-zoo-corp <lee@zoo.dev>
Co-authored-by: Frank Noirot <frankjohnson1993@gmail.com>
Co-authored-by: Pierre Jacquier <pierrejacquier39@gmail.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
197 lines
7.5 KiB
TypeScript
197 lines
7.5 KiB
TypeScript
import { FILE_EXT } from '@src/lib/constants'
|
|
import { bracket } from '@src/lib/exampleKcl'
|
|
import * as fsp from 'fs/promises'
|
|
import { join } from 'path'
|
|
|
|
import { getUtils } from '@e2e/playwright/test-utils'
|
|
import { expect, test } from '@e2e/playwright/zoo-test'
|
|
|
|
test.describe('Testing in-app sample loading', () => {
|
|
/**
|
|
* 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
|
|
*/
|
|
// We have no more web tests
|
|
test.skip('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)
|
|
}, bracket)
|
|
await page.setBodyDimensions({ width: 1200, height: 500 })
|
|
await homePage.goToModelingScene()
|
|
})
|
|
|
|
// Locators and constants
|
|
const newSample = {
|
|
file: 'parametric-bearing-pillow-block' + FILE_EXT,
|
|
title: 'Parametric Bearing Pillow Block',
|
|
}
|
|
const commandBarButton = page.getByRole('button', { name: 'Commands' })
|
|
const samplesCommandOption = page.getByRole('option', {
|
|
name: 'Open Sample',
|
|
})
|
|
const commandSampleOption = page.getByRole('option', {
|
|
name: newSample.title,
|
|
exact: true,
|
|
})
|
|
const commandMethodArgButton = page.getByRole('button', {
|
|
name: 'Method',
|
|
})
|
|
const commandMethodOption = (name: 'Overwrite' | 'Create new file') =>
|
|
page.getByRole('option', {
|
|
name,
|
|
})
|
|
const warningText = page.getByText('Overwrite current file with sample?')
|
|
const confirmButton = page.getByRole('button', { name: 'Submit command' })
|
|
|
|
await test.step(`Precondition: check the initial code`, async () => {
|
|
await u.openKclCodePanel()
|
|
await editor.scrollToText(bracket.split('\n')[0])
|
|
await editor.expectEditor.toContain(bracket.split('\n')[0])
|
|
})
|
|
|
|
await test.step(`Load a KCL sample with the command palette`, async () => {
|
|
await commandBarButton.click()
|
|
await samplesCommandOption.click()
|
|
await commandSampleOption.click()
|
|
await commandMethodArgButton.click()
|
|
await expect(commandMethodOption('Create new file')).not.toBeVisible()
|
|
await commandMethodOption('Overwrite').click()
|
|
await expect(warningText).toBeVisible()
|
|
await confirmButton.click()
|
|
|
|
await editor.expectEditor.toContain('// ' + newSample.title)
|
|
})
|
|
})
|
|
|
|
/**
|
|
* Note this test implicitly depends on the KCL samples:
|
|
* "parametric-bearing-pillow-block": https://github.com/KittyCAD/kcl-samples/blob/main/parametric-bearing-pillow-block/main.kcl
|
|
* "gear-rack": https://github.com/KittyCAD/kcl-samples/blob/main/gear-rack/main.kcl
|
|
*/
|
|
test(
|
|
'Desktop: should create new file by default, optionally overwrite',
|
|
{ tag: '@electron' },
|
|
async ({ editor, context, page, scene, cmdBar }, testInfo) => {
|
|
const { 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, {
|
|
encoding: 'utf-8',
|
|
})
|
|
})
|
|
const u = await getUtils(page)
|
|
|
|
// Locators and constants
|
|
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',
|
|
}
|
|
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?'
|
|
)
|
|
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 }),
|
|
})
|
|
|
|
await test.step(`Test setup`, async () => {
|
|
await page.setBodyDimensions({ width: 1200, height: 500 })
|
|
await projectCard.click()
|
|
await scene.settled(cmdBar)
|
|
})
|
|
|
|
await test.step(`Precondition: check the initial code`, async () => {
|
|
await u.openKclCodePanel()
|
|
await editor.scrollToText(bracket.split('\n')[0])
|
|
await editor.expectEditor.toContain(bracket.split('\n')[0])
|
|
await u.openFilePanel()
|
|
|
|
await expect(projectMenuButton).toContainText('main.kcl')
|
|
await expect(newlyCreatedFile(sampleOne.file)).not.toBeVisible()
|
|
})
|
|
|
|
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 expect(overwriteWarning).not.toBeVisible()
|
|
await expect(newFileWarning).toBeVisible()
|
|
await confirmButton.click()
|
|
await page.waitForTimeout(1000)
|
|
})
|
|
|
|
await test.step(`Ensure we made and opened a new file`, async () => {
|
|
await editor.expectEditor.toContain('// ' + sampleOne.title)
|
|
await expect(newlyCreatedFile(sampleOne.file)).toBeVisible()
|
|
await expect(projectMenuButton).toContainText(sampleOne.file)
|
|
})
|
|
|
|
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 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 () => {
|
|
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)
|
|
})
|
|
}
|
|
)
|
|
})
|