|
1 | 1 | import { getBaseURL, type GitButler, setCookie, startGitButler } from '../src/setup.ts'; |
2 | | -import { clickByTestId, waitForTestId, waitForTestIdToNotExist } from '../src/util.ts'; |
| 2 | +import { clickByTestId, sleep, waitForTestId, waitForTestIdToNotExist } from '../src/util.ts'; |
3 | 3 | import { test } from '@playwright/test'; |
4 | 4 |
|
5 | 5 | let gitbutler: GitButler; |
@@ -44,3 +44,42 @@ test('should be able to delete the last project gracefuly', async ({ page, conte |
44 | 44 |
|
45 | 45 | await waitForTestId(page, 'welcome-page'); |
46 | 46 | }); |
| 47 | + |
| 48 | +test('should be able to delete a project when multiple exist', async ({ |
| 49 | + page, |
| 50 | + context |
| 51 | +}, testInfo) => { |
| 52 | + const workdir = testInfo.outputPath('workdir'); |
| 53 | + const configdir = testInfo.outputPath('config'); |
| 54 | + gitbutler = await startGitButler(workdir, configdir, context); |
| 55 | + |
| 56 | + // Override the analytics confirmation so we don't see the page later |
| 57 | + await setCookie('disk-store-override:appAnalyticsConfirmed', 'true', context); |
| 58 | + |
| 59 | + await gitbutler.runScript('two-projects-with-remote-branches.sh'); |
| 60 | + |
| 61 | + await page.goto('/'); |
| 62 | + |
| 63 | + // Should load the workspace |
| 64 | + await waitForTestId(page, 'workspace-view'); |
| 65 | + |
| 66 | + // Open project settings |
| 67 | + await clickByTestId(page, 'chrome-sidebar-project-settings-button'); |
| 68 | + |
| 69 | + await waitForTestId(page, 'project-settings-modal'); |
| 70 | + |
| 71 | + const deleteProjectButton = await waitForTestId(page, 'project-delete-button'); |
| 72 | + await deleteProjectButton.scrollIntoViewIfNeeded(); |
| 73 | + await deleteProjectButton.click(); |
| 74 | + |
| 75 | + await clickByTestId(page, 'project-delete-modal-confirm'); |
| 76 | + |
| 77 | + await waitForTestIdToNotExist(page, 'project-delete-modal-confirm'); |
| 78 | + await waitForTestIdToNotExist(page, 'project-delete-button'); |
| 79 | + await waitForTestIdToNotExist(page, 'project-settings-modal'); |
| 80 | + |
| 81 | + // Should still be in the workspace |
| 82 | + await waitForTestId(page, 'workspace-view'); |
| 83 | + |
| 84 | + await sleep(10000); // Wait for the project list to update |
| 85 | +}); |
0 commit comments