diff --git a/changelogs/unreleased/6154-autolayout-bug.yml b/changelogs/unreleased/6154-autolayout-bug.yml new file mode 100644 index 000000000..622be311c --- /dev/null +++ b/changelogs/unreleased/6154-autolayout-bug.yml @@ -0,0 +1,6 @@ +description: Resolved the issue of cells overlapping in the instance composer +issue-nr: 6154 +change-type: patch +destination-branches: [master, iso8] +sections: + bugfix: "{{description}}" diff --git a/changelogs/unreleased/buildmaster-env-config-scenario.yml b/changelogs/unreleased/buildmaster-env-config-scenario.yml new file mode 100644 index 000000000..877de1358 --- /dev/null +++ b/changelogs/unreleased/buildmaster-env-config-scenario.yml @@ -0,0 +1,3 @@ +description: Fix env 1.6 scenario to take in account all env settings +change-type: patch +destination-branches: [master, iso8] diff --git a/cypress/e2e/scenario-1-environment.cy.js b/cypress/e2e/scenario-1-environment.cy.js index 6ddbfb816..8dd66a6ec 100644 --- a/cypress/e2e/scenario-1-environment.cy.js +++ b/cypress/e2e/scenario-1-environment.cy.js @@ -271,7 +271,7 @@ describe("Environment", () => { }); } - xit("1.6 Edit environment configuration", function () { + it("1.6 Edit environment configuration", function () { cy.visit("/console/environment/create"); fillCreateEnvForm({ envName: testName(6), @@ -362,6 +362,39 @@ describe("Environment", () => { // specific to ISO if (Cypress.env("edition") === "iso") { + // Change enable_batched_partial_compiles + cy.get('[aria-label="Row-enable_batched_partial_compiles"]') + .find(".pf-v6-c-switch") + .click(); + + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-enable_batched_partial_compiles"]') + .find('[aria-label="SaveAction"]') + .click(); + cy.get('[data-testid="Warning"]').should("not.exist"); + + // Change lsm_expert_mode + cy.get('[aria-label="Row-enable_lsm_expert_mode"]') + .find(".pf-v6-c-switch") + .click(); + + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-enable_lsm_expert_mode"]') + .find('[aria-label="SaveAction"]') + .click(); + cy.get('[data-testid="Warning"]').should("not.exist"); + + // Change enable_lsm_transfer_optimization + cy.get('[aria-label="Row-enable_lsm_transfer_optimization"]') + .find(".pf-v6-c-switch") + .click(); + + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-enable_lsm_transfer_optimization"]') + .find('[aria-label="SaveAction"]') + .click(); + cy.get('[data-testid="Warning"]').should("not.exist"); + // Change lsm_partial_compile cy.get('[aria-label="Row-lsm_partial_compile"]') .find(".pf-v6-c-switch") @@ -374,6 +407,15 @@ describe("Environment", () => { cy.get('[data-testid="Warning"]').should("not.exist"); } + //change environment_metrics_retention + cy.get('[aria-label="Row-environment_metrics_retention"]') + .find(".pf-v6-c-form-control") + .type("{selectAll}375"); + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-environment_metrics_retention"]') + .find('[aria-label="SaveAction"]') + .click(); + //change notification_retention cy.get('[aria-label="Row-notification_retention"]') .find(".pf-v6-c-form-control") @@ -397,6 +439,29 @@ describe("Environment", () => { .click(); cy.get('[data-testid="Warning"]').should("not.exist"); + //Change recompile_backoff + cy.get('[aria-label="Row-recompile_backoff"]') + .find(".pf-v6-c-form-control") + .type("{selectAll}2"); + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-recompile_backoff"]') + .find('[aria-label="SaveAction"]') + .click(); + cy.get('[data-testid="Warning"]').should("not.exist"); + cy.get('[aria-label="Row-recompile_backoff"]') + .find(".pf-v6-c-form-control input") + .should("have.value", "2"); + + //Change reset_deploy_progress_on_start + cy.get('[aria-label="Row-reset_deploy_progress_on_start"]') + .find(".pf-v6-c-switch") + .click(); + cy.get('[data-testid="Warning"]').should("exist"); + cy.get('[aria-label="Row-reset_deploy_progress_on_start"]') + .find('[aria-label="SaveAction"]') + .click(); + cy.get('[data-testid="Warning"]').should("not.exist"); + //Change resource_action_logs_retention cy.get('[aria-label="Row-resource_action_logs_retention"]') .find(".pf-v6-c-form-control") diff --git a/cypress/e2e/scenario-2.1-basic-service.cy.js b/cypress/e2e/scenario-2.1-basic-service.cy.js index 966e0b11a..bcc3b423b 100644 --- a/cypress/e2e/scenario-2.1-basic-service.cy.js +++ b/cypress/e2e/scenario-2.1-basic-service.cy.js @@ -186,7 +186,11 @@ if (Cypress.env("edition") === "iso") { cy.get('[aria-label="History-Row"]').eq(0).should("contain", "up"); // Selecting a version in the table should change the tags in the heading of the page. - cy.get('[aria-label="History-Row"]').eq(1).click(); + cy.get('[aria-label="History-Row"]') + .eq(1) + .within(() => { + cy.get('[data-label="version"]').click(); //it's done to avoid flake where the tooltip comes in a way and click ins't triggered + }); cy.get('[data-testid="selected-version"]').should( "have.text", "Version: 2", @@ -490,7 +494,11 @@ if (Cypress.env("edition") === "iso") { .click(); // change version and go to events page. The second version should contain a validation report. - cy.get('[aria-label="History-Row"]').eq(7).click(); + cy.get('[aria-label="History-Row"]') + .eq(7) + .within(() => { + cy.get('[data-label="version"]').click(); //it's done to avoid flake where the tooltip comes in a way and click ins't triggered + }); cy.get('[data-testid="selected-version"]').should( "have.text", "Version: 2", diff --git a/src/UI/Components/Diagram/helpers/visual.test.ts b/src/UI/Components/Diagram/helpers/visual.test.ts index 7a45cf743..eced88499 100644 --- a/src/UI/Components/Diagram/helpers/visual.test.ts +++ b/src/UI/Components/Diagram/helpers/visual.test.ts @@ -18,6 +18,7 @@ import { updateLabelPosition, toggleLooseElement, showLinkTools, + moveCellsFromColliding, } from "./visual"; beforeAll(() => { @@ -338,3 +339,75 @@ describe("showLinkTools", () => { expect(linkView.hasTools()).toBeFalsy(); }); }); + +describe("moveCellsFromColliding", () => { + it("should move cells to avoid collision", () => { + const graph = new dia.Graph(); + + new dia.Paper({ + model: graph, + }); + + const entityA = createComposerEntity({ + serviceModel: Service.a, + isCore: false, + isEmbeddedEntity: false, + isInEditMode: false, + attributes: InstanceAttributesA, + }); + const entityB = createComposerEntity({ + serviceModel: Service.a, + isCore: false, + isEmbeddedEntity: false, + isInEditMode: false, + attributes: InstanceAttributesB, + }); + + graph.addCell(entityA); + graph.addCell(entityB); + + entityA.set("position", { x: 0, y: 0 }); + entityB.set("position", { x: 0, y: 0 }); + + moveCellsFromColliding(graph, graph.getCells()); + + const updatedCells = graph.getCells(); + + expect(updatedCells[0].position()).toEqual({ x: 0, y: 50 }); + expect(updatedCells[1].position()).toEqual({ x: 0, y: 0 }); + }); + + it("should not move cells if they are not colliding", () => { + const graph = new dia.Graph(); + + new dia.Paper({ + model: graph, + }); + const entityA = createComposerEntity({ + serviceModel: Service.a, + isCore: false, + isEmbeddedEntity: false, + isInEditMode: false, + attributes: InstanceAttributesA, + }); + const entityB = createComposerEntity({ + serviceModel: Service.a, + isCore: false, + isEmbeddedEntity: false, + isInEditMode: false, + attributes: InstanceAttributesB, + }); + + graph.addCell(entityA); + graph.addCell(entityB); + + entityA.set("position", { x: 0, y: 0 }); + entityB.set("position", { x: 200, y: 200 }); + + moveCellsFromColliding(graph, graph.getCells()); + const updatedCells = graph.getCells(); + + expect(updatedCells[0].position()).toEqual({ x: 0, y: 0 }); + expect(updatedCells[1].position()).toEqual({ x: 200, y: 200 }); + }); +}); diff --git a/src/UI/Components/Diagram/helpers/visual.ts b/src/UI/Components/Diagram/helpers/visual.ts index dd1eb3845..b9eba9e9d 100644 --- a/src/UI/Components/Diagram/helpers/visual.ts +++ b/src/UI/Components/Diagram/helpers/visual.ts @@ -265,3 +265,34 @@ const removeConnectionData = ( dispatchUpdateServiceOrderItems(elementCell, ActionEnum.UPDATE); } }; + +/** + * Function that checks if the cells are colliding and moves them if they are + * + * @param {dia.Graph} graph - The jointJS graph to which entities are be added. + * @param {dia.Cell[]} cells - the array of cells to check for collisions + */ +export const moveCellsFromColliding = (graph: dia.Graph, cells: dia.Cell[]) => { + cells.map((cell) => { + let isColliding = false; + + do { + const overlappingCells = graph + .findModelsInArea(cell.getBBox()) + .filter((el) => el.id !== cell.id); + + if (overlappingCells.length > 0) { + isColliding = true; + // an overlap found, change the position + const coordinates = cell.position(); + + cell.set("position", { + x: coordinates.x, + y: coordinates.y + 50, + }); + } else { + isColliding = false; + } + } while (isColliding); + }); +}; diff --git a/src/UI/Components/Diagram/init.ts b/src/UI/Components/Diagram/init.ts index 63e788b50..8f0363416 100644 --- a/src/UI/Components/Diagram/init.ts +++ b/src/UI/Components/Diagram/init.ts @@ -10,6 +10,7 @@ import { applyCoordinatesToCells, getCellsCoordinates, getKeyAttributesNames, + moveCellsFromColliding, } from "./helpers"; import { toggleLooseElement } from "./helpers"; import { @@ -170,6 +171,9 @@ export function diagramInit( if (parsedCoordinates.version === "v2") { applyCoordinatesToCells(graph, parsedCoordinates.data); } + + // check for overlapping cells and adjust the position - this is the case when some cells are added through regular forms + moveCellsFromColliding(graph, cells); } }