From ebed10bc766664c58118df8858336cefa79caae9 Mon Sep 17 00:00:00 2001 From: Frank Noirot Date: Thu, 22 Aug 2024 19:42:21 -0400 Subject: [PATCH] Franknoirot/fix file deletion (#3569) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Don't chop off file name from file path * Add a test to confirm file deletion works (as long as you have a main.kcl) * Add TODO test for when main.kcl doesn't exist * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Make the bad prompt test generate a new prompt each run --------- Co-authored-by: github-actions[bot] Co-authored-by: Jess Frazelle Co-authored-by: Jonathan Tran Co-authored-by: 49fl --- e2e/playwright/projects.spec.ts | 72 +++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/e2e/playwright/projects.spec.ts b/e2e/playwright/projects.spec.ts index 1fcc86867..51cf72c1a 100644 --- a/e2e/playwright/projects.spec.ts +++ b/e2e/playwright/projects.spec.ts @@ -1682,6 +1682,78 @@ test.describe('Renaming in the file tree', () => { ) }) +test.describe('Deleting files from the file pane', () => { + test( + `when main.kcl exists, navigate to main.kcl`, + { tag: '@electron' }, + async ({ browserName }, testInfo) => { + test.skip( + process.platform === 'win32', + 'TODO: remove this skip https://github.com/KittyCAD/modeling-app/issues/3557' + ) + const { electronApp, page } = await setupElectron({ + testInfo, + folderSetupFn: async (dir) => { + await fsp.mkdir(`${dir}/testProject`, { recursive: true }) + await fsp.copyFile( + 'src/wasm-lib/tests/executor/inputs/cylinder.kcl', + `${dir}/testProject/main.kcl` + ) + await fsp.copyFile( + 'src/wasm-lib/tests/executor/inputs/basic_fillet_cube_end.kcl', + `${dir}/testProject/fileToDelete.kcl` + ) + }, + }) + const u = await getUtils(page) + await page.setViewportSize({ width: 1200, height: 500 }) + page.on('console', console.log) + + // Constants and locators + const projectCard = page.getByText('testProject') + const projectMenuButton = page.getByTestId('project-sidebar-toggle') + const fileToDelete = page + .getByRole('listitem') + .filter({ has: page.getByRole('button', { name: 'fileToDelete.kcl' }) }) + const deleteMenuItem = page.getByRole('button', { name: 'Delete' }) + const deleteConfirmation = page.getByTestId('delete-confirmation') + + await test.step('Open project and navigate to fileToDelete.kcl', async () => { + await projectCard.click() + await u.waitForPageLoad() + await u.openFilePanel() + + await fileToDelete.click() + await u.waitForPageLoad() + await u.openKclCodePanel() + await expect(u.codeLocator).toContainText('getOppositeEdge(thing)') + await u.closeKclCodePanel() + }) + + await test.step('Delete fileToDelete.kcl', async () => { + await fileToDelete.click({ button: 'right' }) + await expect(deleteMenuItem).toBeVisible() + await deleteMenuItem.click() + await expect(deleteConfirmation).toBeVisible() + await deleteConfirmation.click() + }) + + await test.step('Check deletion and navigation', async () => { + await u.waitForPageLoad() + await expect(fileToDelete).not.toBeVisible() + await u.closeFilePanel() + await u.openKclCodePanel() + await expect(u.codeLocator).toContainText('circle(') + await expect(projectMenuButton).toContainText('main.kcl') + }) + + await electronApp.close() + } + ) + + test.fixme('TODO - when main.kcl does not exist', async () => {}) +}) + test( 'Original project name persist after onboarding', { tag: '@electron' },