Skip to content

Commit

Permalink
#1236 Eligible & deployable builds
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Dec 15, 2024
1 parent 0d3e9d7 commit be53f6e
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function SlotEligibleBuildsSection({slot, onChange}) {
return (
<>
<PageSection
id="slotBuilds"
title="Builds"
padding={false}
extra={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function SlotEligibleBuildsTable({slot, onChange, showEligibleBui
$deployableOnly: Boolean!,
) {
slotById(id: $id) {
eligibleBuilds(size: 5, deployableOnly: $deployableOnly) {
eligibleBuilds(size: 5, deployable: $deployableOnly) {
pageInfo {
nextPage {
offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function SlotView({id}) {
<Row gutter={[16, 16]} wrap>
<Col span={24}>
<PageSection
title="Slot"
title="Slot details"
padding={true}
>
<SlotDetails slot={slot}/>
Expand Down
2 changes: 2 additions & 0 deletions ontrack-web-core/ontrack.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7074,6 +7074,8 @@ type Slot implements Authorizable {
eligibleBuild: Build
"Paginated list of eligible builds"
eligibleBuilds(
"If true, restricts the list of builds to the ones which can actually be deployed."
deployable: Boolean,
"Offset for the page"
offset: Int = 0,
"Size of the page"
Expand Down
35 changes: 35 additions & 0 deletions ontrack-web-tests/tests/extensions/environments/SlotBuilds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {expect} from "@playwright/test";

export class SlotBuilds {

constructor(page, slot) {
this.page = page
this.slot = slot
}

async selectAllBuilds() {
const section = this.#section()
const button = section.getByLabel("Show all eligible builds")
await expect(button).toBeVisible()
await button.click()
}

async checkBuildPresent(build) {
const link = this.#buildLink(build)
await expect(link).toBeVisible()
}

async checkBuildNotPresent(build) {
const link = this.#buildLink(build)
await expect(link).not.toBeVisible()
}

#section() {
return this.page.getByTestId('slotBuilds')
}

#buildLink(build) {
const section = this.#section()
return section.getByRole('link', {name: build.name})
}
}
7 changes: 7 additions & 0 deletions ontrack-web-tests/tests/extensions/environments/SlotPage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ui} from "@ontrack/connection";
import {expect} from "@playwright/test";
import {confirmBox} from "../../support/confirm";
import {SlotBuilds} from "./SlotBuilds";

export class SlotPage {
constructor(page, slot) {
Expand Down Expand Up @@ -43,4 +44,10 @@ export class SlotPage {
await button.click()
await confirmBox(this.page, "Deleting slot", {okText: "Delete"})
}

async getSlotBuilds() {
const slotBuildsSection = this.page.getByTestId("slotBuilds")
await expect(slotBuildsSection).toBeVisible()
return new SlotBuilds(this.page, this.slot)
}
}
28 changes: 28 additions & 0 deletions ontrack-web-tests/tests/extensions/environments/slots.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,31 @@ test('deleting a slot', async ({page}) => {
const environmentsPage = new EnvironmentsPage(page)
await environmentsPage.checkEnvironmentIsVisible(slot.environment.name)
})

test('eligible and deployable builds for a slot', async ({page}) => {
const {project, slot} = await createSlot(ontrack())
// Promotion admission rule
await ontrack().environments.addPromotionRule({slot, promotion: "BRONZE"})
// Branch for the project
const branch = await project.createBranch()
const bronze = await branch.createPromotionLevel("BRONZE")
// Build not promoted
const build1 = await branch.createBuild()
// Build, promoted
const build2 = await branch.createBuild()
await build2.promote(bronze)

// Login & going to the slot page
await login(page)
const slotPage = new SlotPage(page, slot)
await slotPage.goTo()

// Gets the section about builds
const slotBuilds = await slotPage.getSlotBuilds()
await slotBuilds.checkBuildPresent(build2)
await slotBuilds.checkBuildNotPresent(build1)
// Selecting all eligible builds
await slotBuilds.selectAllBuilds()
await slotBuilds.checkBuildPresent(build2)
await slotBuilds.checkBuildPresent(build1)
})

0 comments on commit be53f6e

Please sign in to comment.