Skip to content

AXON-462 I can start work on a Jira #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions e2e/page-objects/JiraIssuePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ export class JiraIssuePage {
async saveChanges() {
await this.frame.getByRole('button', { name: 'Save' }).click();
}

startWork() {
const startWorkButton = this.frame.getByTestId('issue.start-work-button');
return startWorkButton.click();
}
}
26 changes: 26 additions & 0 deletions e2e/page-objects/StartWorkPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Frame, Locator } from 'playwright/test';

export class StartWorkPage {
readonly issueFrame: Frame;

readonly startButton: Locator;
readonly gitBranchCheckbox: Locator;

constructor(frame: Frame) {
this.issueFrame = frame;
this.startButton = this.issueFrame.getByTestId('start-work.start-button');
this.gitBranchCheckbox = this.issueFrame.getByTestId('start-work.setup-git-branch-checkbox');
}

async startWork() {
await this.startButton.click();
}

async setupGitBranch(isEnabled: boolean) {
const checkbox = this.gitBranchCheckbox.locator('input[type="checkbox"]');
const isChecked = await checkbox.isChecked();
if (isChecked !== isEnabled) {
await checkbox.click();
}
}
}
1 change: 1 addition & 0 deletions e2e/page-objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { AtlascodeDrawer } from './AtlascodeDrawer';
export { JiraIssuePage } from './JiraIssuePage';
export { AtlassianSettings } from './AtlassianSettings';
export { CreateIssuePage } from './CreateIssuePage';
export { StartWorkPage } from './StartWorkPage';
49 changes: 49 additions & 0 deletions e2e/tests/jira/startWorkFlow.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { expect, test } from '@playwright/test';
import { authenticateWithJira, getIssueFrame, setupIssueMock, setupSearchMock } from 'e2e/helpers';
import { AtlascodeDrawer, JiraIssuePage, StartWorkPage } from 'e2e/page-objects';

const ISSUE_NAME = 'BTS-1 - User Interface Bugs';
const CURRENT_STATUS = 'To Do';
const NEXT_STATUS = 'In Progress';

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

const atlascodeDrawer = new AtlascodeDrawer(page);
await atlascodeDrawer.jira.openIssue(ISSUE_NAME);

const issueFrame = await getIssueFrame(page);
const jiraIssuePage = new JiraIssuePage(issueFrame);
await jiraIssuePage.status.expectEqual(CURRENT_STATUS);

await jiraIssuePage.startWork();

await page.getByRole('tab', { name: 'BTS-1', exact: true }).getByLabel(/close/i).click();
await page.waitForTimeout(2_000);

const startWorkFrame = await getIssueFrame(page);
const startWorkPage = new StartWorkPage(startWorkFrame);
await startWorkPage.setupGitBranch(false);
await startWorkPage.startWork();
await page.waitForTimeout(2_000);

expect(startWorkFrame.getByText(new RegExp('Assigned the issue to you', 'i'))).toBeVisible();
expect(startWorkFrame.getByText(new RegExp(`Transitioned status to ${NEXT_STATUS}`, 'i'))).toBeVisible();

// setup mocks for next status
const cleanupIssueMock = await setupIssueMock(request, { status: NEXT_STATUS });
const cleanupSearchMock = await setupSearchMock(request, NEXT_STATUS);

await page.getByRole('tab', { name: 'Start work on BTS-1', exact: true }).getByLabel(/close/i).click();

await atlascodeDrawer.jira.openIssue(ISSUE_NAME);
const updatedIssueFrame = await getIssueFrame(page);
const updatedIssuePage = new JiraIssuePage(updatedIssueFrame);

await updatedIssuePage.status.expectEqual(NEXT_STATUS);
await atlascodeDrawer.jira.openIssue(ISSUE_NAME);

await cleanupIssueMock();
await cleanupSearchMock();
});
12 changes: 12 additions & 0 deletions e2e/wiremock-mappings/mockedteams/assignee.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"request": {
"method": "PUT",
"urlPath": "/rest/api/2/issue/BTS-1/assignee"
},
"response": {
"status": 204,
"headers": {
"Content-Type": "application/json"
}
}
}
2 changes: 2 additions & 0 deletions src/react/atlascode/startwork/StartWorkPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ const StartWorkPage: React.FunctionComponent = () => {
<Grid container spacing={1} direction="row">
<Grid item>
<Switch
data-testid="start-work.setup-git-branch-checkbox"
color="primary"
size="small"
checked={branchSetupEnabled}
Expand Down Expand Up @@ -748,6 +749,7 @@ const StartWorkPage: React.FunctionComponent = () => {
</Grid>
<Grid item hidden={submitState === 'submit-success'}>
<Button
data-testid="start-work.start-button"
variant="contained"
color="primary"
disabled={submitState === 'submitting'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const IssueSidebarButtonGroup: React.FC<Props> = ({
<Tooltip content="Create a branch and transition this issue">
<LoadingButton
className="ac-button"
testId="issue.start-work-button"
onClick={handleStartWork}
iconBefore={<AssetsSchemaIcon label="Start work" />}
isLoading={false}
Expand Down
Loading