Skip to content

Commit

Permalink
[3754] Register view models in editing contexts at loading for e2e tests
Browse files Browse the repository at this point in the history
Make possible to register view models in the loading editing context when the "test" profile is active

Bug: #3754
Signed-off-by: Guillaume Coutable <guillaume.coutable@obeo.fr>
  • Loading branch information
gcoutable authored and sbegaudeau committed Sep 23, 2024
1 parent b11e364 commit 5f2fdc1
Show file tree
Hide file tree
Showing 35 changed files with 1,592 additions and 152 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ jobs:
working-directory: integration-tests

- name: Run end to end tests against the sirius-web application
if: startsWith(github.ref, 'refs/tags/v') == false && github.ref != 'refs/heads/master'
uses: cypress-io/github-action@v5
with:
build: docker compose -f ../packages/sirius-web/backend/sirius-web/docker-compose.yml up -d
Expand All @@ -203,6 +204,7 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}

- name: Store Cypress screenshots
if: always()
uses: actions/upload-artifact@v4
with:
name: cypress-screenshots
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ never, always and if_children (to display the separator only if children exist).
- https://github.com/eclipse-sirius/sirius-web/issues/4021[#4021] [sirius-web] Disable the _Rename_ and _Delete_ project menu actions when project is read-only
- https://github.com/eclipse-sirius/sirius-web/issues/3677[#3677] [diagram] Remove backend layouting code from the time the backend was computing the layout.
- https://github.com/eclipse-sirius/sirius-web/issues/3678[#3678] [core] Rely on representation id to retrieve representation metadata
- https://github.com/eclipse-sirius/sirius-web/issues/3754[#3754] [sirius-web] Activate cypress tests again
- https://github.com/eclipse-sirius/sirius-web/issues/3754[#3754] [sirius-web] Activate cypress tests again.
+ Make possible to register view models in the loading editing context when the "test" profile is active.
+ To activate the test profile add the value _test_ to the `SPRING_PROFILES_ACTIVE` environment variable.

== v2024.9.0

Expand Down
172 changes: 47 additions & 125 deletions integration-tests/cypress/e2e/project/diagrams/diagram-label.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,25 @@
* Obeo - initial API and implementation
*******************************************************************************/

import { Project } from '../../../pages/Project';
import { isCreateProjectFromTemplateSuccessPayload } from '../../../support/server/createProjectFromTemplateCommand';
import { Studio } from '../../../usecases/Studio';
import { Details } from '../../../workbench/Details';
import { Diagram } from '../../../workbench/Diagram';
import { Explorer } from '../../../workbench/Explorer';

describe('Diagram - inside outside labels', () => {
context.skip('Given a view with inside label on rectangular node with none strategy', () => {
let studioProjectId: string = '';
let domainName: string = '';

before(() => {
cy.createProjectFromTemplate('studio-template').then((res) => {
const payload = res.body.data.createProjectFromTemplate;
if (isCreateProjectFromTemplateSuccessPayload(payload)) {
const projectId = payload.project.id;
studioProjectId = projectId;

const project = new Project();
project.visit(projectId);
project.disableDeletionConfirmationDialog();

const explorer = new Explorer();
const details = new Details();
explorer.getTreeItemByLabel('DomainNewModel').dblclick();
cy.get('[title="domain::Domain"]').then(($div) => {
domainName = $div.data().testid;
explorer.expand('ViewNewModel');
explorer.expand('View');
explorer.expand(`${domainName} Diagram Description`);
explorer.expand('Entity1 Node');
explorer.select('aql:self.name');
details.getRadioOption('Overflow Strategy', 'NONE').click();
});
}
});
});

after(() => cy.deleteProject(studioProjectId));
let domainName: string = 'diagramLabel';
context('Given a view with inside label on rectangular node with none strategy', () => {
context('When we create a new instance project', () => {
let instanceProjectId: string = '';
const diagramDescriptionName = `${domainName} - Fully display the inside label Diagram`;
const diagramTitle = 'Fully display the inside label Diagram';

beforeEach(() => {
const studio = new Studio();
studio.createProjectFromDomain('Cypress - Studio Instance', domainName, 'Root').then((res) => {
instanceProjectId = res.projectId;

new Explorer().createRepresentation('Root', `${domainName} Diagram Description`, 'diagram');
new Explorer().createRepresentation('Root', diagramDescriptionName, diagramTitle);
});
});

Expand All @@ -69,26 +39,28 @@ describe('Diagram - inside outside labels', () => {
const explorer = new Explorer();
const diagram = new Diagram();
const details = new Details();
explorer.createObject('Root', 'Entity1s Entity1');
explorer.createObject('Root', 'entity1s-Entity1');
details.getTextField('Name').type('small{enter}');
diagram.fitToScreen();
let initialWidth: number;
let initialHeight: number;
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getNodeCssValue('diagram', 'small', 'width').then((nodeWidth) => {
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'width').then((nodeWidth) => {
initialWidth = nodeWidth / scale;
});
diagram.getNodeCssValue('diagram', 'small', 'height').then((nodeHeight) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'height').then((nodeHeight) => {
initialHeight = nodeHeight / scale;
});
});
details.getTextField('Name').type('{selectAll}very large label one line fully displayed{enter}');
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getNodeCssValue('diagram', 'very large label one line fully displayed', 'width').then((nodeWidth) => {
expect(nodeWidth / scale).to.greaterThan(initialWidth);
});
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram
.getNodeCssValue('diagram', 'very large label one line fully displayed', 'height')
.getNodeCssValue(diagramTitle, 'very large label one line fully displayed', 'width')
.then((nodeWidth) => {
expect(nodeWidth / scale).to.greaterThan(initialWidth);
});
diagram
.getNodeCssValue(diagramTitle, 'very large label one line fully displayed', 'height')
.then((nodeHeight) => {
expect(nodeHeight / scale).to.approximately(initialHeight, 2);
});
Expand All @@ -97,47 +69,18 @@ describe('Diagram - inside outside labels', () => {
});
});

context.skip('Given a view with inside label on rectangular node with wrap strategy', () => {
let studioProjectId: string = '';
let domainName: string = '';

before(() => {
cy.createProjectFromTemplate('studio-template').then((res) => {
const payload = res.body.data.createProjectFromTemplate;
if (isCreateProjectFromTemplateSuccessPayload(payload)) {
const projectId = payload.project.id;
studioProjectId = projectId;

const project = new Project();
project.visit(projectId);
project.disableDeletionConfirmationDialog();

const explorer = new Explorer();
const details = new Details();
explorer.getTreeItemByLabel('DomainNewModel').dblclick();
cy.get('[title="domain::Domain"]').then(($div) => {
domainName = $div.data().testid;
explorer.expand('ViewNewModel');
explorer.expand('View');
explorer.expand(`${domainName} Diagram Description`);
explorer.expand('Entity1 Node');
explorer.select('aql:self.name');
details.getRadioOption('Overflow Strategy', 'WRAP').click();
});
}
});
});

after(() => cy.deleteProject(studioProjectId));
context('Given a view with inside label on rectangular node with wrap strategy', () => {
context('When we create a new instance project', () => {
let instanceProjectId: string = '';
const diagramDescriptionName = `${domainName} - Wrap the label without changing the node width`;
const diagramTitle = 'Wrap the label without changing the node width';

beforeEach(() => {
const studio = new Studio();
studio.createProjectFromDomain('Cypress - Studio Instance', domainName, 'Root').then((res) => {
instanceProjectId = res.projectId;

new Explorer().createRepresentation('Root', `${domainName} Diagram Description`, 'diagram');
new Explorer().createRepresentation('Root', diagramDescriptionName, diagramTitle);
});
});

Expand All @@ -147,28 +90,33 @@ describe('Diagram - inside outside labels', () => {
const explorer = new Explorer();
const diagram = new Diagram();
const details = new Details();
explorer.createObject('Root', 'Entity1s Entity1');
explorer.createObject('Root', 'entity1s-Entity1');
details.getTextField('Name').type('small{enter}');
diagram.fitToScreen();
let initialWidth: number;
let initialHeight: number;
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getNodeCssValue('diagram', 'small', 'width').then((nodeWidth) => {
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'width').then((nodeWidth) => {
initialWidth = nodeWidth / scale;
});
diagram.getNodeCssValue('diagram', 'small', 'height').then((nodeHeight) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'height').then((nodeHeight) => {
initialHeight = nodeHeight / scale;
});
});
details.getTextField('Name').type('{selectAll}very large label one multi line after wrap{enter}');
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram
.getNodeCssValue('diagram', 'very large label one multi line after wrap', 'width')
.getNodeCssValue(diagramTitle, 'very large label one multi line after wrap', 'width')
.then((nodeWidth) => {
expect(nodeWidth / scale).to.approximately(initialWidth, 2);
diagram
.getLabelCssValue(diagramTitle, 'very large label one multi line after wrap', 'width')
.then((labelWidth) => {
expect(labelWidth / scale).to.be.below(nodeWidth / scale);
});
});
diagram
.getNodeCssValue('diagram', 'very large label one multi line after wrap', 'height')
.getNodeCssValue(diagramTitle, 'very large label one multi line after wrap', 'height')
.then((nodeHeight) => {
expect(nodeHeight / scale).to.greaterThan(initialHeight);
});
Expand All @@ -177,75 +125,49 @@ describe('Diagram - inside outside labels', () => {
});
});

context.skip('Given a view with inside label on rectangular node with ellipsis strategy', () => {
let studioProjectId: string = '';
let domainName: string = '';

before(() => {
cy.createProjectFromTemplate('studio-template').then((res) => {
const payload = res.body.data.createProjectFromTemplate;
if (isCreateProjectFromTemplateSuccessPayload(payload)) {
const projectId = payload.project.id;
studioProjectId = projectId;

const project = new Project();
project.visit(projectId);
project.disableDeletionConfirmationDialog();

const explorer = new Explorer();
const details = new Details();
explorer.getTreeItemByLabel('DomainNewModel').dblclick();
cy.get('[title="domain::Domain"]').then(($div) => {
domainName = $div.data().testid;
explorer.expand('ViewNewModel');
explorer.expand('View');
explorer.expand(`${domainName} Diagram Description`);
explorer.expand('Entity1 Node');
explorer.select('aql:self.name');
details.getRadioOption('Overflow Strategy', 'ELLIPSIS').click();
});
}
});
});

after(() => cy.deleteProject(studioProjectId));
context('Given a view with inside label on rectangular node with ellipsis strategy', () => {
context('When we create a new instance project', () => {
let instanceProjectId: string = '';
const diagramDescriptionName = `${domainName} - The label is truncated without changing the node width`;
const diagramTitle = 'The label is truncated without changing the node width';

beforeEach(() => {
const studio = new Studio();
studio.createProjectFromDomain('Cypress - Studio Instance', domainName, 'Root').then((res) => {
instanceProjectId = res.projectId;

new Explorer().createRepresentation('Root', `${domainName} Diagram Description`, 'diagram');
new Explorer().createRepresentation('Root', diagramDescriptionName, diagramTitle);
});
});

afterEach(() => cy.deleteProject(instanceProjectId));

it('Then inside label has an ellipsis and the node width is not updated', () => {
it.skip('Then inside label has an ellipsis and the node width is not updated', () => {
const explorer = new Explorer();
const diagram = new Diagram();
const details = new Details();
explorer.createObject('Root', 'Entity1s Entity1');
explorer.createObject('Root', 'entity1s-Entity1');
details.getTextField('Name').type('small{enter}');
diagram.fitToScreen();
let initialWidth: number;
let initialHeight: number;
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getNodeCssValue('diagram', 'small', 'width').then((nodeWidth) => {
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'width').then((nodeWidth) => {
initialWidth = nodeWidth / scale;
});
diagram.getNodeCssValue('diagram', 'small', 'height').then((nodeHeight) => {
diagram.getNodeCssValue(diagramTitle, 'small', 'height').then((nodeHeight) => {
initialHeight = nodeHeight / scale;
});
});
details.getTextField('Name').type('{selectAll}very large label with an ellipsis{enter}');
diagram.getDiagramScale('diagram').then((scale) => {
diagram.getNodeCssValue('diagram', 'very large label with an ellipsis', 'width').then((nodeWidth) => {
diagram.getDiagramScale(diagramTitle).then((scale) => {
diagram.getNodeCssValue(diagramTitle, 'very large label with an ellipsis', 'width').then((nodeWidth) => {
expect(nodeWidth / scale).to.approximately(initialWidth, 2);
diagram.getLabelCssValue(diagramTitle, 'very large label with an ellipsis', 'width').then((labelWidth) => {
expect(labelWidth / scale).to.be.below(nodeWidth / scale);
});
});
diagram.getNodeCssValue('diagram', 'very large label with an ellipsis', 'height').then((nodeHeight) => {
diagram.getNodeCssValue(diagramTitle, 'very large label with an ellipsis', 'height').then((nodeHeight) => {
expect(nodeHeight / scale).to.approximately(initialHeight, 2);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ describe('/projects/:projectId/edit - Diagram', () => {

afterEach(() => cy.deleteProject(projectId));

it('Then we can create views by Drag and Drop on an unsynchronized diagram', () => {
// See comments on Diagram#dropOnDiagram which does not work.
// We should look again at this test with a more recent cypress version.
it.skip('Then we can create views by Drag and Drop on an unsynchronized diagram', () => {
const explorer = new Explorer();
explorer.expand('robot');
explorer.createRepresentation('System', 'Topography unsynchronized', 'diagram');
Expand Down
24 changes: 7 additions & 17 deletions integration-tests/cypress/e2e/project/diagrams/group-palette.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,15 @@ describe('Diagram - group palette', () => {

afterEach(() => cy.deleteProject(projectId));

it('Then the group palette is displayed when using multi selection', () => {
const diagram = new Diagram();
const explorer = new Explorer();
diagram.getDiagram('diagram').should('exist');
explorer.select('Wifi');
explorer.select('Central_Unit', true);
diagram.fitToScreen();
diagram.getNodes('diagram', 'Wifi').click();
diagram.getPalette().should('not.exist');
diagram.getGroupPalette().should('exist');

diagram.getNodes('diagram', 'DSP').click();
diagram.getPalette().should('exist');
diagram.getGroupPalette().should('not.exist');
});

it('Then the last distribute elements tool used is memorized', () => {
const diagram = new Diagram();
const explorer = new Explorer();
diagram.getDiagram('diagram').should('exist');
diagram.fitToScreen();
explorer.select('Wifi');
explorer.select('Central_Unit', true);
diagram.fitToScreen();
diagram.getSelectedNodes('diagram', 'Wifi');
diagram.getSelectedNodes('diagram', 'Central_Unit');
diagram.getNodes('diagram', 'Wifi').click();
diagram.getGroupPalette().should('exist');
diagram.getGroupPalette().findByTestId('Align left').should('exist');
Expand All @@ -70,10 +56,14 @@ describe('Diagram - group palette', () => {
it('Then during multi selection the connection handles are not computed', () => {
const diagram = new Diagram();
const explorer = new Explorer();
diagram.getDiagram('diagram').should('exist');
diagram.fitToScreen();
explorer.select('Wifi');
diagram.getSelectedNodes('diagram', 'Wifi');
cy.getByTestId('creationhandle-top').should('exist');
explorer.select('Central_Unit', true);
diagram.getSelectedNodes('diagram', 'Wifi');
diagram.getSelectedNodes('diagram', 'Central_Unit');
cy.getByTestId('creationhandle-top').should('not.exist');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const createFormWithWidgetRef = (domainType: string, name: string, reference: st
details.getTextField('Title Expression').type(`{selectall}${name}{enter}`);
explorer.expand(name);
explorer.expand('PageDescription');
explorer.createObject('Group Description', 'children-ReferenceWidgetDescription');
explorer.createObject('GroupDescription', 'children-ReferenceWidgetDescription');
details.getTextField('Reference Name Expression').should('exist');
details.getTextField('Label Expression').type('Test Widget Reference');
details.getTextField('Reference Name Expression').type(`${reference}{enter}`);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/cypress/usecases/Studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Studio {
}

public createProjectFromDomain(name: string, domain: string, entity: string): Cypress.Chainable<CreatedProjectData> {
return cy.createProject(name, [Studio.STUDIO_NATURE]).then((res) => {
return cy.createProject(name, []).then((res) => {
const payload = res.body.data.createProject;
if (isCreateProjectSuccessPayload(payload)) {
const projectId = payload.project.id;
Expand Down
Loading

0 comments on commit 5f2fdc1

Please sign in to comment.