Skip to content

Commit

Permalink
Fix/integration test workflow terminate (#302)
Browse files Browse the repository at this point in the history
* added ROUTE_PARAMS_DOMAIN getter

* moved update query into helper and added support for omitting empty query params.

* fix lint

* increase test timeout to avoid failure

* increasing delay before checking element exists

* check that button is enabled before clicking it

* adding enabled check to similiar tests

* fix lint

* moving delay before the button appears

* reducing delay. removing timeout

* removing delay

* copying code from passing test

* adding assertion for element to not be disabled.

* fix lint

* trying to allow test runner to retry multiple times before failing

* adjusting selector

* trying to add check on element in a retry

* making similar tests more resiliant

* forcing diff change

* adding options to summaryTest and withFullHistory and withHistory helpers

* fix lint

* make options specific to history

* fixed issue with handler option set to false explicitly.

* adding API delay for termination tests

* fix lint

* reverting README change

* reverting files unrelated to integration test changes
  • Loading branch information
just-at-uber authored May 3, 2021
1 parent 035fe99 commit a83ccff
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 23 deletions.
16 changes: 10 additions & 6 deletions client/test/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,11 @@ Scenario.prototype.withWorkflow = function withWorkflow(
return this;
};

Scenario.prototype.withHistory = function withHistory(events, hasMorePages) {
Scenario.prototype.withHistory = function withHistory(
events,
hasMorePages,
options = {}
) {
if (!this.historyNpt) {
this.historyNpt = {};
}
Expand All @@ -338,20 +342,20 @@ Scenario.prototype.withHistory = function withHistory(events, hasMorePages) {
response.nextPageToken = makeToken();
}

this.api.getOnce(url, response, { delay: 100 });
this.api.getOnce(url, response, { delay: 100, ...options });

return this;
};

Scenario.prototype.withFullHistory = function withFullHistory(events) {
Scenario.prototype.withFullHistory = function withFullHistory(events, options) {
const parsedEvents = JSON.parse(
JSON.stringify(events || fixtures.history.emailRun1)
);
const third = Math.floor(parsedEvents.length / 3);

return this.withHistory(parsedEvents.slice(0, third), true)
.withHistory(parsedEvents.slice(third, third + third), true)
.withHistory(parsedEvents.slice(third + third));
return this.withHistory(parsedEvents.slice(0, third), true, options)
.withHistory(parsedEvents.slice(third, third + third), true, options)
.withHistory(parsedEvents.slice(third + third), false, options);
};

Scenario.prototype.withQuery = function withQuery(query) {
Expand Down
56 changes: 39 additions & 17 deletions client/test/workflow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ describe('Workflow', () => {
];
}

async function summaryTest(mochaTest, o) {
async function summaryTest(mochaTest, options = {}) {
const [scenario, opts] = workflowTest(mochaTest, {
view: 'summary',
...o,
...options,
});

scenario.withFullHistory(opts.events);
scenario.withFullHistory(opts.events, options.history);
const summaryEl = await scenario
.render(opts.attach)
.waitUntilExists('section.execution section.workflow-summary dl');
Expand Down Expand Up @@ -337,14 +337,17 @@ describe('Workflow', () => {

describe('Actions', () => {
it('should offer the user to terminate a running workflow, prompting the user for a termination reason', async function test() {
const [summaryEl] = await summaryTest(this.test);
const [summaryEl] = await summaryTest(this.test, {
history: { delay: 250 },
});

const terminateEl = await summaryEl.waitUntilExists(
'aside.actions button'
);

terminateEl.trigger('click');
await retry(() => terminateEl.should.not.have.attr('disabled'));

await Promise.delay(1000);
terminateEl.trigger('click');

const confirmTerminateEl = await summaryEl.waitUntilExists(
'[data-modal="confirm-termination"]'
Expand All @@ -360,12 +363,18 @@ describe('Workflow', () => {
});

it('should terminate the workflow with the provided reason', async function test() {
const [summaryEl, scenario] = await summaryTest(this.test);
const [summaryEl, scenario] = await summaryTest(this.test, {
history: { delay: 250 },
});

(await summaryEl.waitUntilExists('aside.actions button')).trigger(
'click'
const terminateEl = await summaryEl.waitUntilExists(
'aside.actions button'
);

await retry(() => terminateEl.should.not.have.attr('disabled'));

terminateEl.trigger('click');

const confirmTerminateEl = await summaryEl.waitUntilExists(
'[data-modal="confirm-termination"]'
);
Expand All @@ -385,31 +394,43 @@ describe('Workflow', () => {
});

it('should terminate the workflow without a reason', async function test() {
const [summaryEl, scenario] = await summaryTest(this.test);
const [summaryEl, scenario] = await summaryTest(this.test, {
history: { delay: 250 },
});

(await summaryEl.waitUntilExists('aside.actions button')).trigger(
'click'
const terminateEl = await summaryEl.waitUntilExists(
'aside.actions button'
);

const terminateEl = await summaryEl.waitUntilExists(
await retry(() => terminateEl.should.not.have.attr('disabled'));

terminateEl.trigger('click');

const terminateConfirmEl = await summaryEl.waitUntilExists(
'[data-modal="confirm-termination"] button[name="button-terminate"]'
);

scenario.withWorkflowTermination();
terminateEl.trigger('click');
terminateConfirmEl.trigger('click');

await retry(() =>
summaryEl.should.not.contain('[data-modal="confirm-termination"]')
);
});

it('should allow the user to cancel the termination prompt, doing nothing', async function test() {
const [summaryEl] = await summaryTest(this.test);
const [summaryEl] = await summaryTest(this.test, {
history: { delay: 250 },
});

(await summaryEl.waitUntilExists('aside.actions button')).trigger(
'click'
const terminateEl = await summaryEl.waitUntilExists(
'aside.actions button'
);

await retry(() => terminateEl.should.not.have.attr('disabled'));

terminateEl.trigger('click');

const cancelDialog = await summaryEl.waitUntilExists(
'[data-modal="confirm-termination"] button[name="button-cancel"]'
);
Expand All @@ -424,6 +445,7 @@ describe('Workflow', () => {
it('should not offer the user the ability to terminate completed workflows', async function test() {
const [summaryEl] = await summaryTest(this.test, {
execution: closedWorkflowExecution,
history: { delay: 250 },
});

await retry(() =>
Expand Down

0 comments on commit a83ccff

Please sign in to comment.