Skip to content

Commit

Permalink
DT-143 - batch cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Tideman authored and rossedfort committed Nov 30, 2022
1 parent 1da464a commit 1575971
Show file tree
Hide file tree
Showing 59 changed files with 2,254 additions and 748 deletions.
3 changes: 0 additions & 3 deletions cypress/fixtures/count.json

This file was deleted.

3 changes: 3 additions & 0 deletions cypress/fixtures/workflows-count.json
@@ -0,0 +1,3 @@
{
"count": "15"
}
2 changes: 1 addition & 1 deletion cypress/integration/namespaces-archival.spec.js
Expand Up @@ -10,7 +10,7 @@ describe('Archival disabled page', () => {
it('have the correct title on page', () => {
cy.get('[data-cy="archived-disabled-title"]').should(
'contain',
'This namespace is currently not enabled for archival.',
'This Namespace is currently not enabled for archival.',
);
});
});
Expand Down
8 changes: 6 additions & 2 deletions cypress/integration/namespaces.spec.js
Expand Up @@ -74,12 +74,16 @@ describe('Namespace Select', () => {

it('have the correct namespaces in the dropdown when using navigation header', () => {
cy.get('@namespace-select-button').click({ wait: 1000 });
cy.get('.prose > .text-2xl').contains('Select a namespace');
cy.get('[data-cy="namespace-select-header"]').contains(
'Select a Namespace',
);
});

it('navigates to the correct namespaces in the dropdown when using navigation header', () => {
cy.get('@namespace-select-button').click({ wait: 1000 });
cy.get('.prose > .text-2xl').contains('Select a namespace');
cy.get('[data-cy="namespace-select-header"]').contains(
'Select a Namespace',
);
cy.get('[data-cy="namespace-list"] > :nth-child(2)').click();
cy.get('[data-cy="namespace-name"]').contains(namespaces[1]);
});
Expand Down
89 changes: 68 additions & 21 deletions cypress/integration/workflow-bulk-actions.spec.js
@@ -1,34 +1,81 @@
/// <reference types="cypress" />

describe('Bulk Termination', () => {
it("disallows bulk actions for cluster that doesn't have elasticsearch enabled", () => {
cy.interceptApi();
describe('Batch and Bulk Workflow Actions', () => {
describe('when advanced visibility is disabled', () => {
it('disallows bulk and batch actions', () => {
cy.interceptApi();

cy.visit('/namespaces/default/workflows');
cy.visit('/namespaces/default/workflows');

cy.wait('@workflows-api');
cy.wait('@cluster-api');
cy.wait('@cluster-api');
cy.wait('@workflows-api');

cy.get('#workflows-table-with-bulk-actions').should('not.exist');
cy.get('#workflows-table-with-bulk-actions').should('not.exist');
});
});

it('allows running workflows to be terminated for cluster that does have elasticsearch enabled', () => {
cy.interceptApi();
cy.intercept(Cypress.env('VITE_API_HOST') + '/api/v1/cluster*', {
fixture: 'cluster-with-elasticsearch.json',
}).as('cluster-api-elasticsearch');
describe('when advanced visibility is enabled', () => {
beforeEach(() => {
cy.interceptApi();

cy.visit('/namespaces/default/workflows');
cy.intercept(Cypress.env('VITE_API_HOST') + '/api/v1/cluster*', {
fixture: 'cluster-with-elasticsearch.json',
}).as('cluster-api-elasticsearch');

cy.wait('@workflows-api');
cy.wait('@cluster-api-elasticsearch');
cy.visit('/namespaces/default/workflows');

cy.get('#workflows-table-with-bulk-actions').should('exist');
cy.wait('@cluster-api-elasticsearch');
cy.wait('@workflows-api');
});

cy.get('th.selectable > label.checkbox > span.label').click();
cy.get('[data-cy="bulk-terminate-button"]').click();
cy.get('#bulk-terminate-reason').type('Sarah Connor');
cy.get('div.modal button.destructive').click();
cy.get('#batch-terminate-success-toast');
it('allows running workflows to be terminated by ID', () => {
cy.get('#workflows-table-with-bulk-actions').should('exist');

cy.get('#select-visible-workflows').click({ force: true });
cy.get('[data-cy="bulk-terminate-button"]').click();
cy.get('#bulk-action-reason').type('Sarah Connor');
cy.get('div.modal button.destructive').click();
cy.get('#batch-terminate-success-toast');
});

it('allows running workflows to be terminated by a query', () => {
cy.get('#workflows-table-with-bulk-actions').should('exist');

cy.get('#select-visible-workflows').click({ force: true });
cy.get('[data-cy="select-all-workflows"]').click();
cy.get('[data-cy="bulk-terminate-button"]').click();
cy.get('[data-cy="batch-action-workflows-query"]').should(
'have.text',
'ExecutionStatus="Running"',
);
cy.get('#bulk-action-reason').type('Sarah Connor');
cy.get('div.modal button.destructive').click();
cy.get('#batch-terminate-success-toast');
});

it('allows running workflows to be cancelled by ID', () => {
cy.get('#workflows-table-with-bulk-actions').should('exist');

cy.get('#select-visible-workflows').click({ force: true });
cy.get('[data-cy="bulk-cancel-button"]').click();
cy.get('#bulk-action-reason').type('Sarah Connor');
cy.get('div.modal button.destructive').click();
cy.get('#batch-cancel-success-toast');
});

it('allows running workflows to be cancelled by a query', () => {
cy.get('#workflows-table-with-bulk-actions').should('exist');

cy.get('#select-visible-workflows').click({ force: true });
cy.get('[data-cy="select-all-workflows"]').click();
cy.get('[data-cy="bulk-cancel-button"]').click();
cy.get('[data-cy="batch-action-workflows-query"]').should(
'have.text',
'ExecutionStatus="Running"',
);
cy.get('#bulk-action-reason').type('Sarah Connor');
cy.get('div.modal button.destructive').click();
cy.get('#batch-cancel-success-toast');
});
});
});
29 changes: 13 additions & 16 deletions cypress/integration/workflow-executions-with-new-search.spec.js
Expand Up @@ -5,19 +5,18 @@ import workflowsFixture from '../fixtures/workflows.json';
const workflowRunningFixture = workflowsFixture.executions[0];
const { workflowId, runId } = workflowRunningFixture.execution;

describe.skip('Workflow Executions List With Search', () => {
describe('Workflow Executions List With Search', () => {
beforeEach(() => {
cy.interceptApi();
cy.intercept(Cypress.env('VITE_API_HOST') + '/api/v1/cluster*', {
fixture: 'cluster-with-elasticsearch.json',
}).as('cluster-api-elasticsearch');

cy.visit('/namespaces/default/workflows');

cy.wait('@workflows-api');
cy.wait('@workflows-count-api');
cy.wait('@cluster-api-elasticsearch');
cy.wait('@namespaces-api');
});

it('should show count of workflows', () => {
cy.get('[data-cy="workflow-count"]').should('contain', '15 workflows');
cy.wait('@workflows-api');
});

it('should default to All for the time range', () => {
Expand All @@ -36,7 +35,7 @@ describe.skip('Workflow Executions List With Search', () => {
cy.get('#workflowType').should('have.value', 'ImportantWorkflowType');

cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);
});
Expand All @@ -56,7 +55,7 @@ describe.skip('Workflow Executions List With Search', () => {
);

cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);

Expand All @@ -65,7 +64,6 @@ describe.skip('Workflow Executions List With Search', () => {
).click();

cy.url().should('not.contain', result);
cy.get('[data-cy="workflow-count"]').should('contain', '15 workflows');
});

it('should send the correct query for Workflow ID, autocomplete manual search and be clearable', () => {
Expand All @@ -80,7 +78,7 @@ describe.skip('Workflow Executions List With Search', () => {
'WorkflowId="002c98_Running"',
);
cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);

Expand All @@ -89,7 +87,6 @@ describe.skip('Workflow Executions List With Search', () => {
).click();

cy.url().should('not.contain', result);
cy.get('[data-cy="workflow-count"]').should('contain', '15 workflows');
});

it('should change url on single Execution Status change', () => {
Expand All @@ -103,7 +100,7 @@ describe.skip('Workflow Executions List With Search', () => {
'ExecutionStatus="Running"',
);
cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);
});
Expand Down Expand Up @@ -160,7 +157,7 @@ describe.skip('Workflow Executions List With Search', () => {

cy.url().should('contain', 'StartTime+BETWEEN');
cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);
});
Expand All @@ -172,7 +169,7 @@ describe.skip('Workflow Executions List With Search', () => {

cy.url().should('contain', 'CloseTime+BETWEEN');
cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);
});
Expand Down Expand Up @@ -216,7 +213,7 @@ describe.skip('Workflow Executions List With Search', () => {
encodeURIComponent(`ExecutionStatus="Running"`),
);
cy.get('[data-cy="workflow-count"]').should(
'contain',
'have.text',
'Results 15 of 15 workflows',
);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/commands.js
Expand Up @@ -56,7 +56,7 @@ Cypress.Commands.add('interceptWorkflowsCountApi', () => {
cy.intercept(
Cypress.env('VITE_API_HOST') +
`/api/v1/namespaces/*/workflows/count?query=*`,
{ fixture: 'count.json' },
{ fixture: 'workflows-count.json' },
).as('workflows-count-api');
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@temporalio/ui",
"version": "2.1.86",
"version": "2.1.87",
"type": "module",
"description": "Temporal.io UI",
"keywords": [
Expand Down
11 changes: 7 additions & 4 deletions src/api.d.ts
@@ -1,9 +1,7 @@
type WorkflowsAPIRoutePath =
| 'workflows'
| 'workflows.archived'
| 'workflows.count'
| 'workflows.batch.terminate'
| 'workflows.batch.describe';
| 'workflows.count';

type WorkflowAPIRoutePath =
| 'workflow'
Expand All @@ -13,6 +11,8 @@ type WorkflowAPIRoutePath =
| 'events.descending'
| 'query';

type BatchAPIRoutePath = 'batch-operations' | 'batch-operation.describe';

type NamespaceAPIRoutePath = 'namespace';

type TaskQueueAPIRoutePath = 'task-queue';
Expand All @@ -29,7 +29,8 @@ type APIRoutePath =
| TaskQueueAPIRoutePath
| WorkflowAPIRoutePath
| WorkflowsAPIRoutePath
| NamespaceAPIRoutePath;
| NamespaceAPIRoutePath
| BatchAPIRoutePath;

type APIRouteParameters = {
namespace: string;
Expand All @@ -49,6 +50,8 @@ type WorkflowRouteParameters = Pick<
'namespace' | 'workflowId' | 'runId'
>;

type BatchRouteParameters = Pick<APIRouteParameters, 'namespace'>;

type TaskQueueRouteParameters = Pick<APIRouteParameters, 'namespace' | 'queue'>;

type ValidWorkflowEndpoints = WorkflowsAPIRoutePath;
Expand Down

0 comments on commit 1575971

Please sign in to comment.