Skip to content

Commit 4d19692

Browse files
committed
E2E: Add test for tearing off branch from stack into a new stack
Instrument and extend the e2e tests to probe for tearing off a branch from a stack
1 parent 1ca01cf commit 4d19692

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

apps/desktop/src/components/MultiStackOfflaneDropzone.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
88
import { UI_STATE } from '$lib/state/uiState.svelte';
99
import { inject } from '@gitbutler/core/context';
10+
import { TestId } from '@gitbutler/ui';
1011
import { focusable } from '@gitbutler/ui/focus/focusable';
1112
import { intersectionObserver } from '@gitbutler/ui/utils/intersectionObserver';
1213
import type { Snippet } from 'svelte';
@@ -32,6 +33,7 @@
3233

3334
<div
3435
class="hidden-dropzone"
36+
data-testid={TestId.StackOfflaneDropzone}
3537
use:focusable
3638
use:intersectionObserver={{
3739
callback: (entry) => {

e2e/playwright/tests/moveBranch.spec.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test.afterEach(async () => {
1212
gitbutler?.destroy();
1313
});
1414

15-
test('move branch to top of other stack', async ({ page, context }, testInfo) => {
15+
test('move branch to top of other stack and tear it off', async ({ page, context }, testInfo) => {
1616
const workdir = testInfo.outputPath('workdir');
1717
const configdir = testInfo.outputPath('config');
1818
gitbutler = await startGitButler(workdir, configdir, context);
@@ -51,6 +51,23 @@ test('move branch to top of other stack', async ({ page, context }, testInfo) =>
5151
await expect(stacks).toHaveCount(1);
5252
branchHeaders = page.getByTestId('branch-header');
5353
await expect(branchHeaders).toHaveCount(2);
54+
55+
// Now tear off branch2
56+
const updatedBranch1Locator = branchHeaders.filter({ hasText: 'branch2' });
57+
const stackDropzone = await waitForTestId(page, 'stack-offlane-dropzone');
58+
await dragAndDropByLocator(page, updatedBranch1Locator, stackDropzone, {
59+
force: true,
60+
position: {
61+
x: 10,
62+
y: 10
63+
}
64+
});
65+
66+
// Should have two stacks again
67+
stacks = page.getByTestId('stack');
68+
await expect(stacks).toHaveCount(2);
69+
branchHeaders = page.getByTestId('branch-header');
70+
await expect(branchHeaders).toHaveCount(2);
5471
});
5572

5673
test('move branch to the middle of other stack', async ({ page, context }, testInfo) => {

packages/ui/src/lib/utils/testIds.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export enum TestId {
6363
ToastInfoMessage = 'toast-info-message',
6464
Stack = 'stack',
6565
StackHeader = 'stack-header',
66+
StackOfflaneDropzone = 'stack-offlane-dropzone',
6667
BranchesViewApplyBranchButton = 'branches-view-apply-branch-button',
6768
BranchesViewDeleteLocalBranchButton = 'branches-view-delete-local-branch-button',
6869
BranchesViewApplyFromForkButton = 'branches-view-apply-from-fork-button',

0 commit comments

Comments
 (0)