Skip to content

Commit eddebb3

Browse files
committed
test: updated startWorkFlow
1 parent b0812eb commit eddebb3

File tree

5 files changed

+49
-25
lines changed

5 files changed

+49
-25
lines changed

e2e/page-objects/StartWorkPage.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ export class StartWorkPage {
44
readonly issueFrame: Frame;
55

66
readonly startButton: Locator;
7+
readonly gitBranchCheckbox: Locator;
78

89
constructor(frame: Frame) {
910
this.issueFrame = frame;
1011
this.startButton = this.issueFrame.getByTestId('start-work.start-button');
12+
this.gitBranchCheckbox = this.issueFrame.getByTestId('start-work.setup-git-branch-checkbox');
1113
}
1214

1315
async startWork() {
1416
await this.startButton.click();
1517
}
18+
19+
async setupGitBranch(isEnabled: boolean) {
20+
const checkbox = this.gitBranchCheckbox.locator('input[type="checkbox"]');
21+
const isChecked = await checkbox.isChecked();
22+
if (isChecked !== isEnabled) {
23+
await checkbox.click();
24+
}
25+
}
1626
}

e2e/tests/jira/startWorkFlow.spec.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
1-
import { test } from '@playwright/test';
2-
import {
3-
authenticateWithBitbucketCloud,
4-
authenticateWithJira,
5-
connectRepository,
6-
getIssueFrame,
7-
setupIssueMock,
8-
setupSearchMock,
9-
} from 'e2e/helpers';
1+
import { expect, test } from '@playwright/test';
2+
import { authenticateWithJira, getIssueFrame, setupIssueMock, setupSearchMock } from 'e2e/helpers';
103
import { AtlascodeDrawer, JiraIssuePage, StartWorkPage } from 'e2e/page-objects';
114

12-
test.only('I can start work on a Jira', async ({ page, request, context }) => {
13-
const issueName = 'BTS-1 - User Interface Bugs';
14-
const currentStatus = 'To Do';
15-
const nextStatus = 'In Progress';
5+
const ISSUE_NAME = 'BTS-1 - User Interface Bugs';
6+
const CURRENT_STATUS = 'To Do';
7+
const NEXT_STATUS = 'In Progress';
168

9+
test('I can start work on a Jira', async ({ page, request }) => {
1710
await authenticateWithJira(page);
1811
await page.getByRole('tab', { name: 'Atlassian Settings' }).getByLabel(/close/i).click();
1912

20-
await authenticateWithBitbucketCloud(page, context);
21-
await connectRepository(page);
22-
2313
const atlascodeDrawer = new AtlascodeDrawer(page);
24-
await atlascodeDrawer.jira.openIssue(issueName);
14+
await atlascodeDrawer.jira.openIssue(ISSUE_NAME);
2515

2616
const issueFrame = await getIssueFrame(page);
2717
const jiraIssuePage = new JiraIssuePage(issueFrame);
28-
await jiraIssuePage.status.expectEqual(currentStatus);
29-
30-
// setup mocks for next status
31-
const cleanupIssueMock = await setupIssueMock(request, { status: nextStatus });
32-
const cleanupSearchMock = await setupSearchMock(request, nextStatus);
18+
await jiraIssuePage.status.expectEqual(CURRENT_STATUS);
3319

3420
await jiraIssuePage.startWork();
3521

@@ -38,10 +24,25 @@ test.only('I can start work on a Jira', async ({ page, request, context }) => {
3824

3925
const startWorkFrame = await getIssueFrame(page);
4026
const startWorkPage = new StartWorkPage(startWorkFrame);
41-
27+
await startWorkPage.setupGitBranch(false);
4228
await startWorkPage.startWork();
4329
await page.waitForTimeout(2_000);
44-
await atlascodeDrawer.jira.expectIssueStatus(issueName, nextStatus);
30+
31+
expect(startWorkFrame.getByText(new RegExp('Assigned the issue to you', 'i'))).toBeVisible();
32+
expect(startWorkFrame.getByText(new RegExp(`Transitioned status to ${NEXT_STATUS}`, 'i'))).toBeVisible();
33+
34+
// setup mocks for next status
35+
const cleanupIssueMock = await setupIssueMock(request, { status: NEXT_STATUS });
36+
const cleanupSearchMock = await setupSearchMock(request, NEXT_STATUS);
37+
38+
await page.getByRole('tab', { name: 'Start work on BTS-1', exact: true }).getByLabel(/close/i).click();
39+
40+
await atlascodeDrawer.jira.openIssue(ISSUE_NAME);
41+
const updatedIssueFrame = await getIssueFrame(page);
42+
const updatedIssuePage = new JiraIssuePage(updatedIssueFrame);
43+
44+
await updatedIssuePage.status.expectEqual(NEXT_STATUS);
45+
await atlascodeDrawer.jira.openIssue(ISSUE_NAME);
4546

4647
await cleanupIssueMock();
4748
await cleanupSearchMock();
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"request": {
3+
"method": "PUT",
4+
"urlPath": "/rest/api/2/issue/BTS-1/assignee"
5+
},
6+
"response": {
7+
"status": 204,
8+
"headers": {
9+
"Content-Type": "application/json"
10+
}
11+
}
12+
}

src/react/atlascode/startwork/StartWorkPage.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ const StartWorkPage: React.FunctionComponent = () => {
497497
<Grid container spacing={1} direction="row">
498498
<Grid item>
499499
<Switch
500+
data-testid="start-work.setup-git-branch-checkbox"
500501
color="primary"
501502
size="small"
502503
checked={branchSetupEnabled}

src/webviews/components/issue/view-issue-screen/sidebar/IssueSidebarButtonGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const IssueSidebarButtonGroup: React.FC<Props> = ({
8787
<Tooltip content="Create a branch and transition this issue">
8888
<LoadingButton
8989
className="ac-button"
90-
data-testId="issue.start-work-button"
90+
testId="issue.start-work-button"
9191
onClick={handleStartWork}
9292
iconBefore={<AssetsSchemaIcon label="Start work" />}
9393
isLoading={false}

0 commit comments

Comments
 (0)