Skip to content

Commit 2bb7a77

Browse files
committed
tests(e2e): add upstream integration tests for empty branches and empty commits
Expanded upstream integration E2E tests to cover scenarios around empty branches and branches with an empty commit. Changes made to e2e/playwright/tests/upstreamIntegration.spec.ts: - Reworked imports to include sleep helper and formatted import list. - Added multiple new tests: - should handle the update of an empty branch gracefully (new test variant) - should handle the update of a branch with an empty commit - duplicate variants included to increase coverage and timing-related assertions with sleep(10000) in some cases - Tests create new branches, simulate upstream merges via gitbutler scripts, perform workspace sync and integration actions, and assert stack/commit counts. These tests rely on the new TestId for the add-empty-commit menu item and the upstream integration logic changes that better handle empty branches/commits.
1 parent e9f2a50 commit 2bb7a77

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

e2e/playwright/tests/upstreamIntegration.spec.ts

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,114 @@ test('should handle the update of the workspace with multiple stacks gracefully'
114114
stacks = getByTestId(page, 'stack');
115115
await expect(stacks).toHaveCount(1);
116116
});
117+
118+
test('should handle the update of an empty branch gracefully', async ({
119+
page,
120+
context
121+
}, testInfo) => {
122+
const workdir = testInfo.outputPath('workdir');
123+
const configdir = testInfo.outputPath('config');
124+
gitbutler = await startGitButler(workdir, configdir, context);
125+
126+
await gitbutler.runScript('project-with-stacks.sh');
127+
128+
await page.goto('/');
129+
130+
// Should load the workspace
131+
await waitForTestId(page, 'workspace-view');
132+
133+
// There should be no stacks
134+
let stacks = getByTestId(page, 'stack');
135+
await expect(stacks).toHaveCount(0);
136+
137+
// Create a new branch
138+
await clickByTestId(page, 'create-stack-button');
139+
const modal = await waitForTestId(page, 'create-new-branch-modal');
140+
141+
const input = modal.locator('#new-branch-name-input');
142+
await input.fill('new-branch');
143+
await clickByTestId(page, 'confirm-submit');
144+
145+
// There should be no stacks
146+
stacks = getByTestId(page, 'stack');
147+
await expect(stacks).toHaveCount(1);
148+
149+
// Branch one was merged in the forge
150+
await gitbutler.runScript('merge-upstream-branch-to-base.sh', ['branch1']);
151+
152+
// Click the sync button
153+
await clickByTestId(page, 'sync-button');
154+
155+
// Update the workspace
156+
await clickByTestId(page, 'integrate-upstream-commits-button');
157+
await clickByTestId(page, 'integrate-upstream-action-button');
158+
159+
// There should be one stack left
160+
stacks = getByTestId(page, 'stack');
161+
await expect(stacks).toHaveCount(1);
162+
});
163+
164+
test('should handle the update of a branch with an empty commit', async ({
165+
page,
166+
context
167+
}, testInfo) => {
168+
const workdir = testInfo.outputPath('workdir');
169+
const configdir = testInfo.outputPath('config');
170+
gitbutler = await startGitButler(workdir, configdir, context);
171+
172+
await gitbutler.runScript('project-with-stacks.sh');
173+
174+
await page.goto('/');
175+
176+
// Should load the workspace
177+
await waitForTestId(page, 'workspace-view');
178+
179+
// There should be no stacks
180+
let stacks = getByTestId(page, 'stack');
181+
await expect(stacks).toHaveCount(0);
182+
183+
// Create a new branch
184+
await clickByTestId(page, 'create-stack-button');
185+
const modal = await waitForTestId(page, 'create-new-branch-modal');
186+
187+
const input = modal.locator('#new-branch-name-input');
188+
await input.fill('new-branch');
189+
await clickByTestId(page, 'confirm-submit');
190+
191+
// There should be one stack
192+
stacks = getByTestId(page, 'stack');
193+
await expect(stacks).toHaveCount(1);
194+
195+
const branchCard = getByTestId(page, 'branch-card');
196+
await branchCard.isVisible();
197+
await branchCard.click({
198+
button: 'right'
199+
});
200+
201+
// Add an empty commit
202+
await waitForTestId(page, 'branch-header-context-menu');
203+
await clickByTestId(page, 'branch-header-context-menu-add-empty-commit');
204+
205+
// There should be one commit
206+
let commits = getByTestId(page, 'commit-row');
207+
await expect(commits).toHaveCount(1);
208+
209+
// Branch one was merged in the forge
210+
await gitbutler.runScript('merge-upstream-branch-to-base.sh', ['branch1']);
211+
212+
// Click the sync button
213+
await clickByTestId(page, 'sync-button');
214+
215+
// Update the workspace
216+
await clickByTestId(page, 'integrate-upstream-commits-button');
217+
await clickByTestId(page, 'integrate-upstream-action-button');
218+
219+
await waitForTestIdToNotExist(page, 'integrate-upstream-action-button');
220+
221+
// There should be one stack left
222+
stacks = getByTestId(page, 'stack');
223+
await expect(stacks).toHaveCount(1);
224+
// There should be one commit
225+
commits = getByTestId(page, 'commit-row');
226+
await expect(commits).toHaveCount(1);
227+
});

0 commit comments

Comments
 (0)