Skip to content

Commit

Permalink
[2785] Provide cypress tests for Gantt
Browse files Browse the repository at this point in the history
It also consumes gant-task-react 0.4.5 version and bring some minor
changes.

Bug: #2785
Signed-off-by: Laurent Fasani <laurent.fasani@obeo.fr>
  • Loading branch information
lfasani committed Mar 11, 2024
1 parent cac15ac commit 478e3db
Show file tree
Hide file tree
Showing 20 changed files with 1,150 additions and 233 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Expand Up @@ -166,6 +166,7 @@ Thanks to this capability, a specifier can easily retrieve a variable overriden
image:doc/screenshots/borderNodeCreationArea.png[BorderNode creation area,50%]
+
In other scenarios, the default creation position border remains the eastern one.
- https://github.com/eclipse-sirius/sirius-web/issues/2785[#2785] [gantt] Add cypress tests

== v2024.1.0

Expand Down
79 changes: 79 additions & 0 deletions integration-tests/cypress/e2e/project/gantt/gantt-task.cy.ts
@@ -0,0 +1,79 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

import { Details } from '../../../workbench/Details';
import { GanttTestHelper } from '../../../workbench/Gantt';

describe('Verify the Gantt Task actions', () => {
let studioProjectId: string = '';
let taskProjectId: string = '';
before(() => {
// We create the Gantt View from the stereotype before executing the tests
new GanttTestHelper().initGanttView().then((projectId) => {
studioProjectId = projectId;
});

new GanttTestHelper()
.createTaskProjectAndGanttRepresentation('Project Dev', 'New Gantt Representation')
.then((projectId) => {
taskProjectId = projectId;
});
});
after(() => {
cy.deleteProject(studioProjectId);
cy.deleteProject(taskProjectId);
});

beforeEach(() => {
new GanttTestHelper().openGanttRepresentation(taskProjectId, 'Project Dev', 'New Gantt Representation');
});

it('can select a task and see its attributes in Details', () => {
const ganttHelper = new GanttTestHelper();
ganttHelper.getTask('Specification').click();
const details = new Details();
details.getTextField('Name').should('have.value', 'Specification');
details.getTextField('Description').should('have.value', 'Description of the Specification');
details.getTextField('Progress').should('have.value', '50');
details.getDetailsView().findByTestId('Compute Start/End Dynamically').should('not.exist');
// details.getCheckBox('Compute Start/End Dynamically').should('not.exist');

ganttHelper.getProjectTask('Development').click();
details.getCheckBox('Compute Start/End Dynamically').should('exist');
});

it('can change task characteristics from detail with effect in gantt', () => {
const ganttHelper = new GanttTestHelper();
const details = new Details();
ganttHelper.getTask('Specification').click();

details.getTextField('Name').type('Renamed{Enter}');
ganttHelper.getTask('Specification').should('not.exist');
ganttHelper.getTask('SpecificationRenamed').should('exist');

ganttHelper.checkSVGAttributeInTask(ganttHelper.getTask('SpecificationRenamed'), 'rect', 'width', '82.5');
details.getTextField('End Time').type('{selectall}{backspace}2023-12-13T17:30:00Z{Enter}');
ganttHelper.checkSVGAttributeInTask(ganttHelper.getTask('SpecificationRenamed'), 'rect', 'width', '142.5');
});

it('can create and delete a new task', () => {
const ganttHelper = new GanttTestHelper();
ganttHelper.getTask('Front').click();
ganttHelper.getGanttRepresentation().getByTestId('create-task').click();
ganttHelper.getTask('New Task').should('exist');

ganttHelper.getTask('New Task').click();
ganttHelper.getGanttRepresentation().getByTestId('delete-task').click();
ganttHelper.getTask('New Task').should('not.exist');
});
});
209 changes: 209 additions & 0 deletions integration-tests/cypress/e2e/project/gantt/gantt.cy.ts
@@ -0,0 +1,209 @@
/*******************************************************************************
* Copyright (c) 2024 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/

import { Explorer } from '../../../workbench/Explorer';
import { GanttTestHelper } from '../../../workbench/Gantt';

describe('Verify the Gantt Representation', () => {
let studioProjectId: string = '';
before(() => {
// We create the Gantt View from the stereotype before executing the tests
new GanttTestHelper().initGanttView().then((projectId) => {
studioProjectId = projectId;
});
});
after(() => {
// We delete the created studio once all tests have been executed
cy.deleteProject(studioProjectId);
});

context('We new verify the Gantt Creation, Deletion and renaming', () => {
let taskProjectId: string;
before(() => {
new GanttTestHelper()
.createTaskProjectAndGanttRepresentation('Project Dev', 'New Gantt Representation')
.then((projectId) => {
taskProjectId = projectId;
});
});

beforeEach(() => {
new GanttTestHelper().openGanttRepresentation(taskProjectId, 'Project Dev', 'New Gantt Representation');
});

after(() => {
cy.deleteProject(taskProjectId);
});

it('can create the Gantt Representation', () => {
new Explorer().getSelectedTreeItems().contains('New Gantt Representation').should('exist');
new GanttTestHelper().getGanttRepresentation().should('exist');
});

it('can verify the Gantt Representation on the Dev project', () => {
new Explorer().getSelectedTreeItems().contains('New Gantt Representation').should('exist');

const gantt = new GanttTestHelper();
//We verify that all tasks are present.
const taskTitles: string[] = ['Idea', 'Specification', 'Front', 'Back', 'Review'];
taskTitles.forEach((title) => {
gantt.getTask(title).should('exist');
});
const projectTitles: string[] = ['Development', 'Code Development'];
projectTitles.forEach((title) => {
gantt.getProjectTask(title).should('exist');
});
gantt.getMilestone('Release').should('exist');
});

it('can rename the Gantt Representation', () => {
const explorer = new Explorer();
explorer.getTreeItemByLabel('New Gantt Representation').should('exist');
new GanttTestHelper().getGanttRepresentation().should('exist');
explorer.rename('New Gantt Representation', 'renamed');
explorer.getTreeItemByLabel('New Gantt Representation').should('not.exist');
explorer.getTreeItemByLabel('renamed').should('exist');

cy.getByTestId('representation-tab-renamed').should('exist');
explorer.rename('renamed', 'New Gantt Representation');
});

it('can remove the Gantt Representation', () => {
const explorer = new Explorer();
explorer.getTreeItemByLabel('New Gantt Representation').should('exist');
new GanttTestHelper().getGanttRepresentation().should('exist');
explorer.delete('New Gantt Representation');
explorer.getTreeItemByLabel('New Gantt Representation').should('not.exist');
cy.getByTestId('representation-area').find('h5').should('have.text', 'The Gantt does not exist anymore');
});
});

context('We verify the Gantt table columns', () => {
let taskProjectId: string;
before(() => {
new GanttTestHelper()
.createTaskProjectAndGanttRepresentation('Project Dev', 'New Gantt Representation')
.then((projectId) => {
taskProjectId = projectId;
});
});

beforeEach(() => {
new GanttTestHelper().openGanttRepresentation(taskProjectId, 'Project Dev', 'New Gantt Representation');
});

after(() => {
console.log('cy.deleteProject(taskProjectId)');
cy.deleteProject(taskProjectId);
});
it('can display the table columns', () => {
const ganttHelper = new GanttTestHelper();
const columnTitles = ['Name', 'Date of start', 'Date of start', 'Progress'];
columnTitles.forEach((title) => {
ganttHelper.getColumnHeader(title).should('exist');
});
ganttHelper.getGanttRepresentation().findByTestId('display-task-list-columns').click();
columnTitles.forEach((title) => {
ganttHelper.getColumnHeader(title).should('not.exist');
});
ganttHelper.getGanttRepresentation().findByTestId('display-task-list-columns').click();
columnTitles.forEach((title) => {
ganttHelper.getColumnHeader(title).should('exist');
});

//hide one column
ganttHelper.getGanttRepresentation().findByTestId('columns-select').click();
cy.getByTestId('columnType-From').click();
ganttHelper.getColumnHeader('Date of start').should('not.exist');
cy.getByTestId('columnType-From').click();
ganttHelper.getColumnHeader('Date of start').should('exist');
cy.get('body').click(0, 0);

// hide all columns
ganttHelper.getGanttRepresentation().findByTestId('display-task-list-columns').click();
columnTitles.forEach((title) => {
ganttHelper.getColumnHeader(title).should('not.exist');
});
ganttHelper.getGanttRepresentation().findByTestId('display-task-list-columns').click();
columnTitles.forEach((title) => {
ganttHelper.getColumnHeader(title).should('exist');
});
ganttHelper.getGanttRepresentation().findByTestId('columns-select').click();
cy.getByTestId('columnType-From').click();
cy.get('body').click(0, 0);
ganttHelper.getGanttRepresentation().findByTestId('display-task-list-columns').click();
ganttHelper.getColumnHeader('Date of start').should('not.exist');
});

it('can change the columns width', () => {
const ganttHelper = new GanttTestHelper();

ganttHelper.getColumnHeader('Name').then((header) => {
expect(header.width()).eq(200);
});
ganttHelper
.getGanttRepresentation()
.findByTestId('table-column-header-resize-handle-Name')
.trigger('mousedown')
.trigger('mousemove', { clientX: 450 })
.trigger('mouseup');

ganttHelper.getColumnHeader('Name').then((header) => {
expect(header.width()).eq(140);
});
ganttHelper.getColumnHeader('Date of start').then((header) => {
expect(header.width()).eq(140);
});
});
});

context('We verify the Gantt toolbar', () => {
let taskProjectId: string;
before(() => {
new GanttTestHelper()
.createTaskProjectAndGanttRepresentation('Project Dev', 'New Gantt Representation')
.then((projectId) => {
taskProjectId = projectId;
});
});

beforeEach(() => {
new GanttTestHelper().openGanttRepresentation(taskProjectId, 'Project Dev', 'New Gantt Representation');
});

after(() => {
cy.deleteProject(taskProjectId);
});

it('can change the zoom level', () => {
cy.getByTestId('zoom-level').get('input').should('have.value', 'Day');
cy.getByTestId('representation-area').findByTestId('zoom-level').click();
cy.getByTestId('zoom-level-Hour').click();
cy.getByTestId('zoom-level-Hour').should('exist');
cy.getByTestId('fit-to-screen').click();
cy.getByTestId('zoom-level').get('input').should('have.value', 'Day');
});

it('can share the representation', () => {
cy.getByTestId('representation-area').findByTestId('share').click();

cy.url().then((url) => {
cy.window().then((win) => {
win.navigator.clipboard.readText().then((text) => {
expect(text).to.eq(url);
});
});
});
});
});
});

0 comments on commit 478e3db

Please sign in to comment.