Fix up little differences in file/dir creation logic for electron (#3498)

* Fix up little differences in file/dir creation logic for electron

* Fix typo

* A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)

* Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)"

This reverts commit 8e7212f5da.

* Text-to-cad test flakiness

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Frank Noirot
2024-08-19 08:08:07 -04:00
committed by GitHub
parent 73bbd3f5b7
commit 7f50294936
3 changed files with 17 additions and 21 deletions

View File

@ -353,7 +353,7 @@ test.describe('Text-to-CAD tests', () => {
const prompt = page.getByText('Prompt') const prompt = page.getByText('Prompt')
await expect(prompt.first()).toBeVisible() await expect(prompt.first()).toBeVisible()
const badPrompt = 'akjsndladf lajbhflauweyfa;wieufjn---4;' const badPrompt = 'akjsndladflajbhflauweyf15;'
// Type the prompt. // Type the prompt.
await page.keyboard.type(badPrompt) await page.keyboard.type(badPrompt)
@ -465,6 +465,8 @@ test.describe('Text-to-CAD tests', () => {
test('can do many at once and get many prompts back, and interact with many', async ({ test('can do many at once and get many prompts back, and interact with many', async ({
page, page,
}) => { }) => {
// Let this test run longer since we've seen it timeout.
test.setTimeout(180_000)
// skip on windows // skip on windows
test.skip( test.skip(
process.platform === 'win32', process.platform === 'win32',

View File

@ -49,7 +49,7 @@ export const FileMachineProvider = ({
if (event.data && 'name' in event.data) { if (event.data && 'name' in event.data) {
commandBarSend({ type: 'Close' }) commandBarSend({ type: 'Close' })
navigate( navigate(
`${PATHS.FILE}/${encodeURIComponent( `..${PATHS.FILE}/${encodeURIComponent(
context.selectedDirectory + context.selectedDirectory +
window.electron.path.sep + window.electron.path.sep +
event.data.name event.data.name
@ -61,7 +61,7 @@ export const FileMachineProvider = ({
event.data.path.endsWith(FILE_EXT) event.data.path.endsWith(FILE_EXT)
) { ) {
// Don't navigate to newly created directories // Don't navigate to newly created directories
navigate(`${PATHS.FILE}/${encodeURIComponent(event.data.path)}`) navigate(`..${PATHS.FILE}/${encodeURIComponent(event.data.path)}`)
} }
}, },
addFileToRenamingQueue: assign({ addFileToRenamingQueue: assign({
@ -100,7 +100,7 @@ export const FileMachineProvider = ({
let createdPath: string let createdPath: string
if (event.data.makeDir) { if (event.data.makeDir) {
let { name, path } = await getNextDirName({ let { name, path } = getNextDirName({
entryName: createdName, entryName: createdName,
baseDir: context.selectedDirectory.path, baseDir: context.selectedDirectory.path,
}) })
@ -108,16 +108,13 @@ export const FileMachineProvider = ({
createdPath = path createdPath = path
await window.electron.mkdir(createdPath) await window.electron.mkdir(createdPath)
} else { } else {
const { name, path } = await getNextFileName({ const { name, path } = getNextFileName({
entryName: createdName, entryName: createdName,
baseDir: context.selectedDirectory.path, baseDir: context.selectedDirectory.path,
}) })
createdName = name createdName = name
createdPath = path createdPath = path
await window.electron.mkdir(createdPath) await window.electron.writeFile(createdPath, event.data.content ?? '')
if (event.data.content) {
await window.electron.writeFile(createdPath, event.data.content)
}
} }
return { return {
@ -130,7 +127,7 @@ export const FileMachineProvider = ({
let createdPath: string let createdPath: string
if (event.data.makeDir) { if (event.data.makeDir) {
let { name, path } = await getNextDirName({ let { name, path } = getNextDirName({
entryName: createdName, entryName: createdName,
baseDir: context.selectedDirectory.path, baseDir: context.selectedDirectory.path,
}) })
@ -138,16 +135,13 @@ export const FileMachineProvider = ({
createdPath = path createdPath = path
await window.electron.mkdir(createdPath) await window.electron.mkdir(createdPath)
} else { } else {
const { name, path } = await getNextFileName({ const { name, path } = getNextFileName({
entryName: createdName, entryName: createdName,
baseDir: context.selectedDirectory.path, baseDir: context.selectedDirectory.path,
}) })
createdName = name createdName = name
createdPath = path createdPath = path
await window.electron.mkdir(createdPath) await window.electron.writeFile(createdPath, event.data.content ?? '')
if (event.data.content) {
await window.electron.writeFile(createdPath, '')
}
} }
return { return {
@ -180,13 +174,13 @@ export const FileMachineProvider = ({
const currentFilePath = window.electron.path.join(file.path, file.name) const currentFilePath = window.electron.path.join(file.path, file.name)
if (oldPath === currentFilePath && project?.path) { if (oldPath === currentFilePath && project?.path) {
// If we just renamed the current file, navigate to the new path // If we just renamed the current file, navigate to the new path
navigate(PATHS.FILE + '/' + encodeURIComponent(newPath)) navigate(`..${PATHS.FILE}/${encodeURIComponent(newPath)}`)
} else if (file?.path.includes(oldPath)) { } else if (file?.path.includes(oldPath)) {
// If we just renamed a directory that the current file is in, navigate to the new path // If we just renamed a directory that the current file is in, navigate to the new path
navigate( navigate(
PATHS.FILE + `..${PATHS.FILE}/${encodeURIComponent(
'/' + file.path.replace(oldPath, newDirPath)
encodeURIComponent(file.path.replace(oldPath, newDirPath)) )}`
) )
} }
@ -221,7 +215,7 @@ export const FileMachineProvider = ({
file?.path.includes(event.data.path)) && file?.path.includes(event.data.path)) &&
project?.path project?.path
) { ) {
navigate(PATHS.FILE + '/' + encodeURIComponent(project.path)) navigate(`../${PATHS.FILE}/${encodeURIComponent(project.path)}`)
} }
return `Successfully deleted ${isDir ? 'folder' : 'file'} "${ return `Successfully deleted ${isDir ? 'folder' : 'file'} "${

View File

@ -112,7 +112,7 @@ const Home = () => {
).trim() ).trim()
if (doesProjectNameNeedInterpolated(name)) { if (doesProjectNameNeedInterpolated(name)) {
const nextIndex = await getNextProjectIndex(name, projects) const nextIndex = getNextProjectIndex(name, projects)
name = interpolateProjectNameWithIndex(name, nextIndex) name = interpolateProjectNameWithIndex(name, nextIndex)
} }