Skip to content

Commit

Permalink
Merge branch 'main' into franknoirot/fix-file-deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
jtran authored Aug 22, 2024
2 parents c17ebcd + acbe92d commit 2404480
Show file tree
Hide file tree
Showing 26 changed files with 762 additions and 340 deletions.
6 changes: 3 additions & 3 deletions e2e/playwright/command-bar-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const extrude001 = extrude(-10, sketch001)`
await expect(cmdSearchBar).not.toBeVisible()

// Now try the same, but with the keyboard shortcut, check focus
await page.keyboard.press('Meta+K')
await page.keyboard.press('ControlOrMeta+K')
await expect(cmdSearchBar).toBeVisible()
await expect(cmdSearchBar).toBeFocused()

Expand Down Expand Up @@ -185,7 +185,7 @@ const extrude001 = extrude(-10, sketch001)`
await page.locator('.cm-content').click()

// Now try the same, but with the keyboard shortcut, check focus
await page.keyboard.press('Meta+K')
await page.keyboard.press('ControlOrMeta+K')

let cmdSearchBar = page.getByPlaceholder('Search commands')
await expect(cmdSearchBar).toBeVisible()
Expand Down Expand Up @@ -250,7 +250,7 @@ const extrude001 = extrude(-10, sketch001)`
await page.getByRole('button', { name: 'Extrude' }).isEnabled()

let cmdSearchBar = page.getByPlaceholder('Search commands')
await page.keyboard.press('Meta+K')
await page.keyboard.press('ControlOrMeta+K')
await expect(cmdSearchBar).toBeVisible()

// Search for extrude command and choose it
Expand Down
23 changes: 10 additions & 13 deletions e2e/playwright/copilot-ghost-test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ test.describe('Copilot ghost text', () => {
await page.setViewportSize({ width: 1200, height: 500 })

await u.waitForAuthSkipAppStart()
const CtrlKey = process.platform === 'darwin' ? 'Meta' : 'Control'

await u.codeLocator.click()
await expect(page.locator('.cm-content')).toHaveText(``)
Expand All @@ -349,10 +348,10 @@ test.describe('Copilot ghost text', () => {
)

// Going elsewhere in the code should hide the ghost text.
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.down('Shift')
await page.keyboard.press('KeyZ')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')
await page.keyboard.up('Shift')
await expect(page.locator('.cm-ghostText').first()).not.toBeVisible()

Expand All @@ -368,8 +367,6 @@ test.describe('Copilot ghost text', () => {

await u.waitForAuthSkipAppStart()

const CtrlKey = process.platform === 'darwin' ? 'Meta' : 'Control'

await page.waitForTimeout(800)
await u.codeLocator.click()
await expect(page.locator('.cm-content')).toHaveText(``)
Expand All @@ -382,17 +379,17 @@ test.describe('Copilot ghost text', () => {
await page.waitForTimeout(800)

// Ctrl+z
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')

await expect(page.locator('.cm-content')).toHaveText(``)

// Ctrl+shift+z
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.down('Shift')
await page.keyboard.press('KeyZ')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')
await page.keyboard.up('Shift')

await expect(page.locator('.cm-content')).toHaveText(`{thing: "blah"}`)
Expand All @@ -411,14 +408,14 @@ test.describe('Copilot ghost text', () => {
)

// Once for the enter.
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')

// Once for the text.
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyZ')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')

await expect(page.locator('.cm-ghostText').first()).not.toBeVisible()

Expand Down
13 changes: 5 additions & 8 deletions e2e/playwright/editor-tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ test.describe('Editor tests', () => {
await page.setViewportSize({ width: 1000, height: 500 })

await u.waitForAuthSkipAppStart()
const CtrlKey = process.platform === 'darwin' ? 'Meta' : 'Control'

// check no error to begin with
await expect(page.locator('.cm-lint-marker-error')).not.toBeVisible()
Expand All @@ -29,9 +28,9 @@ test.describe('Editor tests', () => {
|> line([-20, 0], %)
|> close(%)`)

await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('/')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')

await expect(page.locator('.cm-content'))
.toHaveText(`const sketch001 = startSketchOn('XY')
Expand All @@ -42,9 +41,9 @@ test.describe('Editor tests', () => {
// |> close(%)`)

// uncomment the code
await page.keyboard.down(CtrlKey)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('/')
await page.keyboard.up(CtrlKey)
await page.keyboard.up('ControlOrMeta')

await expect(page.locator('.cm-content'))
.toHaveText(`const sketch001 = startSketchOn('XY')
Expand Down Expand Up @@ -148,9 +147,7 @@ test.describe('Editor tests', () => {
// Delete all the code.
await page.locator('.cm-content').click()
// Select all
await page.keyboard.press('Control+A')
await page.keyboard.press('Backspace')
await page.keyboard.press('Meta+A')
await page.keyboard.press('ControlOrMeta+A')
await page.keyboard.press('Backspace')

await expect(page.locator('.cm-content')).toHaveText(``)
Expand Down
132 changes: 76 additions & 56 deletions e2e/playwright/projects.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { test, expect } from '@playwright/test'
import { test, expect, Page } from '@playwright/test'
import {
doExport,
getUtils,
isOutOfViewInScrollContainer,
Paths,
setupElectron,
tearDown,
createProjectAndRenameIt,
} from './test-utils'
import fsp from 'fs/promises'
import fs from 'fs'
Expand Down Expand Up @@ -531,33 +532,23 @@ test(

page.on('console', console.log)

const createProjectAndRenameIt = async (name: string) =>
test.step(`Create and rename project ${name}`, async () => {
await page.getByRole('button', { name: 'New project' }).click()
await expect(page.getByText('Successfully created')).toBeVisible()
await expect(page.getByText('Successfully created')).not.toBeVisible()

await expect(page.getByText(`project-000`)).toBeVisible()
await page.getByText(`project-000`).hover()
await page.getByText(`project-000`).focus()

await page.getByLabel('sketch').first().click()

await page.waitForTimeout(100)

// type "updated project name"
await page.keyboard.press('Backspace')
await page.keyboard.type(name)

await page.getByLabel('checkmark').last().click()
const createProjectAndRenameItTest = async ({
name,
page,
}: {
name: string
page: Page
}) => {
await test.step(`Create and rename project ${name}`, async () => {
await createProjectAndRenameIt({ name, page })
})
}

// we need to create the folders so that the order is correct
// creating them ahead of time with fs tools means they all have the same timestamp
await createProjectAndRenameIt('router-template-slate')
// await createProjectAndRenameIt('focusrite_scarlett_mounting_braket')
await createProjectAndRenameIt('bracket')
await createProjectAndRenameIt('lego')
await createProjectAndRenameItTest({ name: 'router-template-slate', page })
await createProjectAndRenameItTest({ name: 'bracket', page })
await createProjectAndRenameItTest({ name: 'lego', page })

await test.step('delete the middle project, i.e. the bracket project', async () => {
const project = page.getByText('bracket')
Expand Down Expand Up @@ -627,33 +618,23 @@ test(

page.on('console', console.log)

const createProjectAndRenameIt = async (name: string) =>
test.step(`Create and rename project ${name}`, async () => {
await page.getByRole('button', { name: 'New project' }).click()
await expect(page.getByText('Successfully created')).toBeVisible()
await expect(page.getByText('Successfully created')).not.toBeVisible()

await expect(page.getByText(`project-000`)).toBeVisible()
await page.getByText(`project-000`).hover()
await page.getByText(`project-000`).focus()

await page.getByLabel('sketch').first().click()

await page.waitForTimeout(100)

// type "updated project name"
await page.keyboard.press('Backspace')
await page.keyboard.type(name)

await page.getByLabel('checkmark').last().click()
const createProjectAndRenameItTest = async ({
name,
page,
}: {
name: string
page: Page
}) => {
await test.step(`Create and rename project ${name}`, async () => {
await createProjectAndRenameIt({ name, page })
})
}

// we need to create the folders so that the order is correct
// creating them ahead of time with fs tools means they all have the same timestamp
await createProjectAndRenameIt('router-template-slate')
// await createProjectAndRenameIt('focusrite_scarlett_mounting_braket')
await createProjectAndRenameIt('bracket')
await createProjectAndRenameIt('lego')
await createProjectAndRenameItTest({ name: 'router-template-slate', page })
await createProjectAndRenameItTest({ name: 'bracket', page })
await createProjectAndRenameItTest({ name: 'lego', page })

await test.step('should be shorted by modified initially', async () => {
const lastModifiedButton = page.getByRole('button', {
Expand Down Expand Up @@ -1252,18 +1233,13 @@ test(

await page.getByText('mike_stress_test').click()

const modifier =
process.platform === 'win32' || process.platform === 'linux'
? 'Control'
: 'Meta'

await test.step('select all in code editor, check its length', async () => {
await u.codeLocator.click()
// expect u.codeLocator to have some text
await expect(u.codeLocator).toContainText('line(')
await page.keyboard.down(modifier)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyA')
await page.keyboard.up(modifier)
await page.keyboard.up('ControlOrMeta')

// check the length of the selected text
const selectedText = await page.evaluate(() => {
Expand All @@ -1279,9 +1255,9 @@ test(
await test.step('delete all the text, select again and verify there are no characters left', async () => {
await page.keyboard.press('Backspace')

await page.keyboard.down(modifier)
await page.keyboard.down('ControlOrMeta')
await page.keyboard.press('KeyA')
await page.keyboard.up(modifier)
await page.keyboard.up('ControlOrMeta')

// check the length of the selected text
const selectedText = await page.evaluate(() => {
Expand Down Expand Up @@ -1777,3 +1753,47 @@ test.describe('Deleting files from the file pane', () => {

test.fixme('TODO - when main.kcl does not exist', async () => {})
})

test(
'Original project name persist after onboarding',
{ tag: '@electron' },
async ({ browserName }, testInfo) => {
const { electronApp, page } = await setupElectron({
testInfo,
})
await page.setViewportSize({ width: 1200, height: 500 })

const getAllProjects = () => page.getByTestId('project-link').all()
page.on('console', console.log)

await test.step('Should create and name a project called wrist brace', async () => {
await createProjectAndRenameIt({ name: 'wrist brace', page })
})

await test.step('Should go through onboarding', async () => {
await page.getByTestId('user-sidebar-toggle').click()
await page.getByTestId('user-settings').click()
await page.getByRole('button', { name: 'Replay Onboarding' }).click()

const numberOfOnboardingSteps = 12
for (let clicks = 0; clicks < numberOfOnboardingSteps; clicks++) {
await page.getByTestId('onboarding-next').click()
}

await page.getByTestId('project-sidebar-toggle').click()
})

await test.step('Should go home after onboarding is completed', async () => {
await page.getByRole('button', { name: 'Go to Home' }).click()
})

await test.step('Should show the original project called wrist brace', async () => {
const projectNames = ['Tutorial Project 00', 'wrist brace']
for (const [index, projectLink] of (await getAllProjects()).entries()) {
await expect(projectLink).toContainText(projectNames[index])
}
})

await electronApp.close()
}
)
Loading

0 comments on commit 2404480

Please sign in to comment.