diff --git a/ontrack-web-core/components/links/BuildNode.js b/ontrack-web-core/components/links/BuildNode.js index 0a7654dbba..de0a0f3c08 100644 --- a/ontrack-web-core/components/links/BuildNode.js +++ b/ontrack-web-core/components/links/BuildNode.js @@ -14,6 +14,7 @@ export default function BuildNode({data}) { <> action(mode)} tooltip={title} diff --git a/ontrack-web-core/components/promotionRuns/PromotionRun.js b/ontrack-web-core/components/promotionRuns/PromotionRun.js index 5cfad53977..66f4f5e056 100644 --- a/ontrack-web-core/components/promotionRuns/PromotionRun.js +++ b/ontrack-web-core/components/promotionRuns/PromotionRun.js @@ -9,17 +9,20 @@ export default function PromotionRun({ }) { return ( <> - : undefined - } - /> + { + promotionRun && + : undefined + } + /> + } ) } \ No newline at end of file diff --git a/ontrack-web-tests/tests/core/builds/build.js b/ontrack-web-tests/tests/core/builds/build.js index f0aa5bbc97..145dee020d 100644 --- a/ontrack-web-tests/tests/core/builds/build.js +++ b/ontrack-web-tests/tests/core/builds/build.js @@ -1,3 +1,5 @@ +import {BuildLinksPage} from "./buildLinks"; + const {ui} = require("@ontrack/connection"); const {expect} = require("@playwright/test"); @@ -18,4 +20,9 @@ export class BuildPage { await expect(this.page.getByText("Upstream links")).toBeVisible() } + async goToLinks() { + await this.page.getByRole("button", {name: "Links"}).click() + return new BuildLinksPage(this.page) + } + } \ No newline at end of file diff --git a/ontrack-web-tests/tests/core/builds/build.spec.js b/ontrack-web-tests/tests/core/builds/build.spec.js index 739ffc867e..07c3a7ca9c 100644 --- a/ontrack-web-tests/tests/core/builds/build.spec.js +++ b/ontrack-web-tests/tests/core/builds/build.spec.js @@ -47,4 +47,44 @@ test('build page with validations without a type', async ({page}) => { // Navigating to the build const buildPage = new BuildPage(page, build) await buildPage.goTo() +}) + +test('graph of links between builds', async ({page}) => { + // Provisioning + const project = await ontrack().createProject() + const branch = await project.createBranch() + const build = await branch.createBuild() + + // Link + const targetProject = await ontrack().createProject() + const targetBranch = await targetProject.createBranch() + const target = await targetBranch.createBuild() + await build.linkTo(target) + + // Login + await login(page) + + // Navigating to the build + const buildPage = new BuildPage(page, build) + await buildPage.goTo() + + // Navigating to the links + const buildLinks = await buildPage.goToLinks() + + // We expect the graph view + await buildLinks.expectOnGraphView() + await buildLinks.expectBuildGraphNodeVisible(build) + await buildLinks.expectBuildGraphNodeVisible(target) + + // Switching to the tree view + await buildLinks.switchView() + await buildLinks.expectOnTreeView() + await buildLinks.expectBuildTreeNodeVisible(build) + await buildLinks.expectBuildTreeNodeVisible(target) + + // Switching to the graph view again + await buildLinks.switchView() + await buildLinks.expectOnGraphView() + await buildLinks.expectBuildGraphNodeVisible(build) + await buildLinks.expectBuildGraphNodeVisible(target) }) \ No newline at end of file diff --git a/ontrack-web-tests/tests/core/builds/buildLinks.js b/ontrack-web-tests/tests/core/builds/buildLinks.js new file mode 100644 index 0000000000..d8a8b531e8 --- /dev/null +++ b/ontrack-web-tests/tests/core/builds/buildLinks.js @@ -0,0 +1,35 @@ +import {expect} from "@playwright/test"; + +export class BuildLinksPage { + constructor(page) { + this.page = page + } + + async expectOnGraphView() { + // We expect the switch to the opposite view ("tree") to be available + await expect(this.page.getByTestId("build-links-mode-tree")).toBeVisible() + } + + async expectOnTreeView() { + // We expect the switch to the opposite view ("graph") to be available + await expect(this.page.getByTestId("build-links-mode-graph")).toBeVisible() + } + + async expectBuildGraphNodeVisible(build) { + await expect(this.page + .getByTestId(`ot-build-link-node-${build.id}`) + .getByRole("link", {name: build.name}) + ).toBeVisible() + } + + async expectBuildTreeNodeVisible(build) { + await expect(this.page + .getByRole('tree') + .getByRole("link", {name: build.name}) + ).toBeVisible() + } + + async switchView() { + await this.page.locator(".ot-build-links-mode-button").click() + } +} \ No newline at end of file