Skip to content

Commit

Permalink
style(workflow): u#2859 t#4101 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mavalroot committed Nov 23, 2023
1 parent a62113e commit fb7d4a3
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 6 deletions.
140 changes: 140 additions & 0 deletions javascript/apps/taiga-e2e/src/e2e/project/workflows/workflows.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright (c) 2023-present Kaleidos INC
*/

import { randProductName } from '@ngneat/falso';
import { Project, ProjectMockFactory, WorkspaceMockFactory } from '@taiga/data';
import {
createStory,
createWorkflow,
} from '@test/support/helpers/kanban.helper';
import {
createFullProjectInWSRequest,
createStoryRequest,
getProjectWorkflows,
} from '@test/support/helpers/project.helpers';
import { createWorkspaceRequest } from '@test/support/helpers/workspace.helpers';

const workspace = WorkspaceMockFactory();
const projectMock = ProjectMockFactory();

describe('Kanban', () => {
let project!: Project;

before(() => {
cy.login();

createWorkspaceRequest(workspace.name)
.then((request) => {
void createFullProjectInWSRequest(
request.body.id,
projectMock.name
).then((response) => {
project = response.body;
void getProjectWorkflows(project.id).then((response) => {
const workflows = response.body;
void createStoryRequest(
'main',
project.id,
{
title: 'test',
},
workflows[0].statuses[0].id
);
});

// Clean main workflow statuses
cy.visit(`/project/${project.id}/${project.slug}/kanban`);
for (let i = 0; i < 3; i++) {
cy.getBySel('status-options').last().click();
cy.getBySel('delete-status-btn').click();
}
});
})
.catch(console.error);
});

beforeEach(() => {
cy.login();
cy.visit(`/project/${project.id}/${project.slug}/overview`);
});

it('create new workflow', () => {
const title = randProductName();

createWorkflow(title);
createStory('New', randProductName());

cy.getBySel('workflow-list').find('li').should('have.length', 2);
});

it('edit workflow', () => {
const title = randProductName();

cy.getBySel('workflow-list').find('li').last().click();
cy.getBySel('workflow-options').click();
cy.getBySel('edit-workflow-btn').click();
cy.getBySel('create-workflow-input').type(title);
cy.getBySel('workflow-create').click();

cy.get('tg-ui-breadcrumb').find('.accent').first().contains(title);
cy.getBySel('workflow-list').find('li').last().contains(title);
});

it('delete workflow without stories', () => {
const title = randProductName();

createWorkflow(title);

cy.getBySel('workflow-list').find('li').should('have.length', 3);

cy.getBySel('workflow-options').click();
cy.getBySel('delete-workflow-btn').click();

cy.getBySel('workflow-list').find('li').should('have.length', 2);
});

it('delete workflow with stories', () => {
const title = randProductName();

createWorkflow(title);
createStory('New', randProductName());

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500); // wait for the story to be created

cy.getBySel('workflow-list').find('li').should('have.length', 3);

cy.getBySel('workflow-options', { timeout: 500 }).click();
cy.getBySel('delete-workflow-btn').click();
cy.get('#radio-delete-workflow-all').check();
cy.getBySel('submit-delete-workflow').click();

cy.getBySel('workflow-list').find('li').should('have.length', 2);
});

it('delete workflow with stories and move them', () => {
const title = randProductName();
const storyTitle = randProductName();

createWorkflow(title);
createStory('New', storyTitle);

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(500); // wait for the story to be created

cy.getBySel('workflow-list').find('li').should('have.length', 3);

cy.getBySel('workflow-options').click();
cy.getBySel('delete-workflow-btn').click();
cy.getBySel('submit-delete-workflow').click();

cy.getBySel('workflow-list').find('li').should('have.length', 2);
cy.getBySel('kanban-story').contains(storyTitle);
cy.getBySel('kanban-story').should('have.length', 2);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ export const createStory = (statusName: string, title: string) => {
cy.getBySel('story-ref').should('be.visible');
});
};

export const createWorkflow = (title: string) => {
cy.getBySel('create-workflow').click();
cy.getBySel('create-workflow-input').type(title);
cy.getBySel('workflow-create').click();
};
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{{ t('kanban.delete_workflow_modal.cancel') }}
</button>
<button
data-test="submit-delete-status"
data-test="submit-delete-workflow"
tuiButton
icon="trash"
(click)="submit()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
t('kanban.status_options_tooltip', { name: workflow.name })
"
icon="more-vertical"
data-test="status-options"
data-test="workflow-options"
class="status-options-menu-button"
appearance="action-button-2"
tuiIconButton
Expand All @@ -54,7 +54,7 @@
<tui-data-list class="view-options-list">
<button
class="option-btn"
data-test="edit-status-btn"
data-test="edit-workflow-btn"
tuiOption
type="button"
(click)="toggleEditWorkflowForm()">
Expand All @@ -70,7 +70,7 @@
<button
(click)="openDeleteWorkflowModal()"
class="option-btn option-delete"
data-test="delete-status-btn"
data-test="delete-workflow-btn"
tuiOption
type="button">
<div class="option-container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
</div>
<ol
[attr.aria-label]="t('common_project.workflow.workflow_list')"
data-test="workflow-list"
class="submenu"
*ngIf="!collapsed">
<li
Expand Down Expand Up @@ -403,6 +404,7 @@
[routerLink]="['/project', project.id, project.slug, 'new-workflow']"
*ngIf="project.userIsAdmin"
class="create-workflow"
data-test="create-workflow"
size="m"
appearance="action-button-2"
variant="dark"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@

<button
tuiButton
data-test="status-create"
data-test="workflow-create"
appearance="primary"
type="submit">
{{ workflow ? t('commons.save') : t('kanban.create_workflow.save') }}
</button>
<button
(click)="cancelEdit()"
data-test="cancel-edit-status"
data-test="cancel-edit-workflow"
tuiButton
type="button"
appearance="tertiary">
Expand Down

0 comments on commit fb7d4a3

Please sign in to comment.