Skip to content

Commit 4658313

Browse files
committed
Upstream integration: e2e tests
Add a test for upstream integration - Conflicting branch - Integrated branch
1 parent fffae2f commit 4658313

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
echo "GIT CONFIG $GIT_CONFIG_GLOBAL"
4+
echo "DATA DIR $GITBUTLER_CLI_DATA_DIR"
5+
echo "BUT_TESTING $BUT_TESTING"
6+
echo "BRANCH TO APPLY: $1"
7+
# Apply remote branch to the workspace.
8+
pushd remote-project
9+
git checkout master
10+
git merge --no-ff -m "Merging upstream branch $1 into base" "$1"
11+
popd
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import { getBaseURL, type GitButler, startGitButler } from '../src/setup.ts';
2+
import { clickByTestId, getByTestId, waitForTestId, waitForTestIdToNotExist } from '../src/util.ts';
3+
import { expect, test } from '@playwright/test';
4+
5+
let gitbutler: GitButler;
6+
7+
test.use({
8+
baseURL: getBaseURL()
9+
});
10+
11+
test.afterEach(async () => {
12+
gitbutler?.destroy();
13+
});
14+
15+
test('should handle the update of workspace with one conflicting branch gracefully', async ({
16+
page,
17+
context
18+
}, testInfo) => {
19+
const workdir = testInfo.outputPath('workdir');
20+
const configdir = testInfo.outputPath('config');
21+
gitbutler = await startGitButler(workdir, configdir, context);
22+
23+
await gitbutler.runScript('project-with-remote-branches.sh');
24+
// Apply branch1
25+
await gitbutler.runScript('apply-upstream-branch.sh', ['branch1', 'local-clone']);
26+
27+
await page.goto('/');
28+
29+
// Should load the workspace
30+
await waitForTestId(page, 'workspace-view');
31+
32+
// There are remote changes in the base branch
33+
await gitbutler.runScript('project-with-remote-branches__add-commit-to-base.sh');
34+
35+
// Click the sync button
36+
await clickByTestId(page, 'sync-button');
37+
38+
// Update the workspace
39+
await clickByTestId(page, 'integrate-upstream-commits-button');
40+
await clickByTestId(page, 'integrate-upstream-action-button');
41+
42+
// There should be one stack
43+
const stacks = getByTestId(page, 'stack');
44+
await expect(stacks).toHaveCount(1);
45+
});
46+
47+
test('should handle the update of workspace with integrated branch gracefully', async ({
48+
page,
49+
context
50+
}, testInfo) => {
51+
const workdir = testInfo.outputPath('workdir');
52+
const configdir = testInfo.outputPath('config');
53+
gitbutler = await startGitButler(workdir, configdir, context);
54+
55+
await gitbutler.runScript('project-with-remote-branches.sh');
56+
// Apply branch1
57+
await gitbutler.runScript('apply-upstream-branch.sh', ['branch1', 'local-clone']);
58+
59+
await page.goto('/');
60+
61+
// Should load the workspace
62+
await waitForTestId(page, 'workspace-view');
63+
64+
// There should be one stack applied
65+
const stacks = getByTestId(page, 'stack');
66+
await expect(stacks).toHaveCount(1);
67+
68+
// Branch one was merged in the forge
69+
await gitbutler.runScript('merge-upstream-branch-to-base.sh', ['branch1']);
70+
71+
// Click the sync button
72+
await clickByTestId(page, 'sync-button');
73+
74+
// Update the workspace
75+
await clickByTestId(page, 'integrate-upstream-commits-button');
76+
await clickByTestId(page, 'integrate-upstream-action-button');
77+
78+
// There should be no stacks
79+
await waitForTestIdToNotExist(page, 'stack');
80+
});
81+
82+
test('should handle the update of the workspace with multiple stacks gracefully', async ({
83+
page,
84+
context
85+
}, testInfo) => {
86+
const workdir = testInfo.outputPath('workdir');
87+
const configdir = testInfo.outputPath('config');
88+
gitbutler = await startGitButler(workdir, configdir, context);
89+
90+
await gitbutler.runScript('project-with-stacks.sh');
91+
await gitbutler.runScript('apply-upstream-branch.sh', ['branch1', 'local-clone']);
92+
await gitbutler.runScript('apply-upstream-branch.sh', ['branch2', 'local-clone']);
93+
94+
await page.goto('/');
95+
96+
// Should load the workspace
97+
await waitForTestId(page, 'workspace-view');
98+
99+
// There should be one stack applied
100+
let stacks = getByTestId(page, 'stack');
101+
await expect(stacks).toHaveCount(2);
102+
103+
// Branch one was merged in the forge
104+
await gitbutler.runScript('merge-upstream-branch-to-base.sh', ['branch1']);
105+
106+
// Click the sync button
107+
await clickByTestId(page, 'sync-button');
108+
109+
// Update the workspace
110+
await clickByTestId(page, 'integrate-upstream-commits-button');
111+
await clickByTestId(page, 'integrate-upstream-action-button');
112+
113+
// There should be one stack left
114+
stacks = getByTestId(page, 'stack');
115+
await expect(stacks).toHaveCount(1);
116+
});

0 commit comments

Comments
 (0)