Skip to content

Commit

Permalink
#1333 Graph view not visible
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Jul 22, 2024
1 parent 98ccad2 commit b97041e
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 11 deletions.
1 change: 1 addition & 0 deletions ontrack-web-core/components/links/BuildNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function BuildNode({data}) {
<>
<Handle type="target" position={Position.Left}/>
<Card
data-testid={`ot-build-link-node-${build.id}`}
title={undefined}
size="small"
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export default function DependencyLinksModeButton({icon, selectedMode, mode, act
{
selectedMode && selectedMode !== mode &&
<FloatButton
className="ot-build-links-mode-button"
data-testid={`build-links-mode-${mode}`}
icon={icon}
onClick={() => action(mode)}
tooltip={title}
Expand Down
25 changes: 14 additions & 11 deletions ontrack-web-core/components/promotionRuns/PromotionRun.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ export default function PromotionRun({
}) {
return (
<>
<PromotionLevel
promotionLevel={promotionRun.promotionLevel}
size={size}
displayTooltip={displayDetails}
displayText={displayPromotionLevelName}
displayDescription={displayPromotionLevelDescription}
details={
displayDetails ?
<Timestamp prefix="Promoted on " value={promotionRun.creation.time}/> : undefined
}
/>
{
promotionRun &&
<PromotionLevel
promotionLevel={promotionRun.promotionLevel}
size={size}
displayTooltip={displayDetails}
displayText={displayPromotionLevelName}
displayDescription={displayPromotionLevelDescription}
details={
displayDetails ?
<Timestamp prefix="Promoted on " value={promotionRun.creation.time}/> : undefined
}
/>
}
</>
)
}
7 changes: 7 additions & 0 deletions ontrack-web-tests/tests/core/builds/build.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {BuildLinksPage} from "./buildLinks";

const {ui} = require("@ontrack/connection");
const {expect} = require("@playwright/test");

Expand All @@ -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)
}

}
40 changes: 40 additions & 0 deletions ontrack-web-tests/tests/core/builds/build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
35 changes: 35 additions & 0 deletions ontrack-web-tests/tests/core/builds/buildLinks.js
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit b97041e

Please sign in to comment.