Skip to content

Commit

Permalink
[3480] Fix an error that prevents border color to be properly applied
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#3480
Signed-off-by: Florian ROUËNÉ <[email protected]>
  • Loading branch information
frouene authored and mcharfadi committed Jun 5, 2024
1 parent 22b9da0 commit ae5ae42
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- https://github.com/eclipse-sirius/sirius-web/issues/3517[#3517] [diagram] Prevent edge path for rotatable border node to be inconsistent
- https://github.com/eclipse-sirius/sirius-web/issues/2908[#2908] [diagram] Homogenize delete icon
- https://github.com/eclipse-sirius/sirius-web/issues/3485[#3485] [diagram] Add a validation error message when background value is missing
- https://github.com/eclipse-sirius/sirius-web/issues/3480[#3480] [diagram] Fix an error that prevents border color to be properly applied

=== New Features

Expand Down
82 changes: 82 additions & 0 deletions integration-tests/cypress/e2e/project/diagrams/node-style.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* 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 { Project } from '../../../pages/Project';
import { Studio } from '../../../usecases/Studio';
import { Explorer } from '../../../workbench/Explorer';
import { Details } from '../../../workbench/Details';

describe('Diagram - node style', () => {
context('Given a studio template', () => {
let studioProjectId: string = '';
let domainName: string = '';

before(() =>
new Studio().createStudioProject().then((createdProjectData) => {
studioProjectId = createdProjectData.projectId;
const project = new Project();
project.visit(createdProjectData.projectId);
project.disableDeletionConfirmationDialog();
const explorer = new Explorer();
explorer.expand('DomainNewModel');
cy.get('[title="domain::Domain"]').then(($div) => {
domainName = $div.data().testid;
const details = new Details();
explorer.expand('ViewNewModel');
explorer.expand('View');
explorer.expand(`${domainName} Diagram Description`);
explorer.expand('Entity1 Node');
explorer.select('RectangularNodeStyleDescription');
details.openReferenceWidgetOptions('Border Color');
details.selectReferenceWidgetOption('orange 500');
explorer.collapse('Entity1 Node');
explorer.expand('Entity2 Node');
explorer.delete('RectangularNodeStyleDescription');
explorer.createObject('Entity2 Node', 'Style Image');
explorer.select('ImageNodeStyleDescription');
details.selectValue('Shape', 'fan');
details.openReferenceWidgetOptions('Border Color');
details.selectReferenceWidgetOption('cyan 500');
});
})
);

after(() => cy.deleteProject(studioProjectId));
context('When we create a new instance project', () => {
let instanceProjectId: string = '';

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');
});
});

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

it('Then check color border is properly applied', () => {
const explorer = new Explorer();
const details = new Details();

explorer.createObject('Root', 'Entity1s Entity1');
details.getTextField('Name').type('Entity1{Enter}');
explorer.createObject('Root', 'Entity2s Entity2');
details.getTextField('Name').should('have.value', '');
details.getTextField('Name').type('Entity2{Enter}');
explorer.select('diagram');
cy.getByTestId('FreeForm - Entity1').invoke('css', 'border-color').should('eq', 'rgb(255, 152, 0)');
cy.getByTestId('FreeForm - Entity2').invoke('css', 'border-color').should('eq', 'rgb(0, 188, 212)');
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ const freeFormNodeStyle = (
height: '100%',
opacity: faded ? '0.4' : '',
...style,
borderColor: getCSSColor(String(style.borderColor), theme),
};
if (selected || hovered) {
freeFormNodeStyle.outline = `${theme.palette.selected} solid 1px`;
}
return freeFormNodeStyle;
};

const imageNodeStyle = (
const backgroundNodeStyle = (
theme: Theme,
style: React.CSSProperties,
rotation: string | undefined,
Expand Down Expand Up @@ -105,7 +106,7 @@ export const FreeFormNode = memo(({ data, id, selected, dragging }: NodeProps<Fr
[data.style, selected, data.isHovered, data.faded]
);
const backgroundStyle = useMemo(
() => imageNodeStyle(theme, data.style, rotation, imageURL),
() => backgroundNodeStyle(theme, data.style, rotation, imageURL),
[data.style, rotation, imageURL]
);

Expand Down

0 comments on commit ae5ae42

Please sign in to comment.