Skip to content

Commit 7f25a84

Browse files
authored
Merge pull request #10965 from gitbutlerapp/testing-things
e2e: Fix running tests on chrome & delete project from multiple project setup
2 parents ee4d371 + bffd1f1 commit 7f25a84

File tree

5 files changed

+103
-58
lines changed

5 files changed

+103
-58
lines changed

e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@gitbutler/e2e",
33
"type": "module",
44
"devDependencies": {
5-
"@playwright/test": "1.47.0",
5+
"@playwright/test": "1.56.1",
66
"@types/node": "^24.3.0",
77
"@wdio/cli": "^9.18.4",
88
"@wdio/globals": "^9.17.0",

e2e/playwright/playwright.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ function projects() {
5656
}
5757

5858
projects.push({
59-
name: 'chromium',
59+
name: 'Chrome',
6060
use: {
6161
...devices['Desktop Chrome'],
62-
viewport: { width: 1920, height: 1080 }
62+
headless: false,
63+
channel: 'chrome'
6364
}
6465
});
6566

e2e/playwright/src/setup.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,9 @@ async function setProjectPathCookie(context: BrowserContext, workdir: string): P
226226
}
227227

228228
/**
229-
* Set the project path cookie in the browser context.
229+
* Set the butler server port cookie in the browser context.
230230
*
231-
* This is needed in order for the Frontend to be able to know the absolute paths of the
232-
* project files. The web file picker is not able to get absolute paths for security reasons.
231+
* This is needed in order for the Frontend to know which port to use to connect to the butler server.
233232
*/
234233
async function setButlerServerPort(context: BrowserContext): Promise<void> {
235234
// Set the information about the workdir

e2e/playwright/tests/projectOffboarding.spec.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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';
33
import { test } from '@playwright/test';
44

55
let gitbutler: GitButler;
@@ -44,3 +44,42 @@ test('should be able to delete the last project gracefuly', async ({ page, conte
4444

4545
await waitForTestId(page, 'welcome-page');
4646
});
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

Comments
 (0)