Skip to content

Commit

Permalink
#1236 Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoraboeuf committed Dec 15, 2024
1 parent be53f6e commit bf0d094
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion ontrack-web-core/components/common/Breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ export function promotionLevelBreadcrumbs(promotionLevel) {
}

export function validationStampBreadcrumbs(validationStamp) {
return downToBranchBreadcrumbs(validationStamp)
return validationStamp ? downToBranchBreadcrumbs(validationStamp) : []
}
2 changes: 1 addition & 1 deletion ontrack-web-core/components/common/Titles.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function validationStampTitleName(validationStamp, what) {
}

export function validationStampTitle(validationStamp) {
return title(validationStampTitleName(validationStamp))
return validationStamp ? title(validationStampTitleName(validationStamp)) : ''
}

export function title(text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import {useReloadState} from "@components/common/StateUtils";
import PageSection from "@components/common/PageSection";
import SlotPipelineWorkflowsTable from "@components/extension/environments/SlotPipelineWorkflowsTable";

export default function SlotPipelineDeploymentStatus({pipeline}) {
export default function SlotPipelineDeploymentStatus({pipeline, onChange}) {

const client = useGraphQLClient()

const [reloadState, reload] = useReloadState()
const [reloadState, reload] = useReloadState({callback: onChange})

const [loading, setLoading] = useState(true)
const [items, setItems] = useState([])
Expand Down Expand Up @@ -70,7 +70,7 @@ export default function SlotPipelineDeploymentStatus({pipeline}) {
info={true}
linkInfo={false}
actions={true}
// TODO Refreshes the page on change
onChange={reload}
/>,
span: 4,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {
import {slotBreadcrumbs, slotTitle, slotUri} from "@components/extension/environments/EnvironmentsLinksUtils";
import {CloseCommand} from "@components/common/Commands";
import SlotPipelineDeploymentStatus from "@components/extension/environments/SlotPipelineDeploymentStatus";
import {useReloadState} from "@components/common/StateUtils";

export default function SlotPipelineView({id}) {

const client = useGraphQLClient()

const [reloadState, reload] = useReloadState()
const [loading, setLoading] = useState(true)
const [title, setTitle] = useState('')
const [pipelinePageTitle, setPipelinePageTitle] = useState('')
Expand Down Expand Up @@ -64,7 +66,7 @@ export default function SlotPipelineView({id}) {
setLoading(false)
})
}
}, [client, id])
}, [client, id, reloadState])

return (
<>
Expand All @@ -81,6 +83,7 @@ export default function SlotPipelineView({id}) {
pipeline &&
<SlotPipelineDeploymentStatus
pipeline={pipeline}
onChange={reload}
/>
}
</LoadingContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function ValidationStampView({id}) {
const client = useGraphQLClient()

const [loading, setLoading] = useState(true)
const [validationStamp, setValidationStamp] = useState({branch: {project: {}}})
const [validationStamp, setValidationStamp] = useState()
const [commands, setCommands] = useState([])

const chartLeadTime = "chart-lead-time"
Expand Down Expand Up @@ -191,7 +191,7 @@ export default function ValidationStampView({id}) {
commands={commands}
description={
<Space direction="vertical">
{validationStamp.description}
{validationStamp?.description}
{/* Validation stamp data config */}
{
validationStamp && validationStamp.dataType &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ export default function ValidationStampViewTitle({validationStamp, link = false}
return (
<>
{
link && <ValidationStampLink validationStamp={validationStamp}/>
}
{
!link &&
<Space>
<ValidationStampImage validationStamp={validationStamp}/>
{validationStamp.name}
</Space>
validationStamp && <>
{
link && <ValidationStampLink validationStamp={validationStamp}/>
}
{
!link &&
<Space>
<ValidationStampImage validationStamp={validationStamp}/>
{validationStamp.name}
</Space>
}
</>
}
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class PromotionsPage {
}

async checkPromotionLevel({name}) {
await expect(this.page.getByRole('link', {name: name, exact: true})).toBeVisible()
await expect(this.page.getByRole('link', {name: name})).toBeVisible()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ValidationRunHistoryDialog {
}

async waitFor() {
await expect(this.page.getByText(`Runs for ${this.run.validationStamp.name} in build ${this.run.build.name}`)).toBeVisible()
await expect(this.page.getByText(`${this.run.validationStamp.name} in build ${this.run.build.name}`)).toBeVisible()
}

async selectStatus(status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class EnvironmentsPage {
}

async checkSlotIsVisible(environment, projectName, qualifier) {
const row = this.page.getByTestId(`environment-row-${environment.id}`)
const row = this.page.getByTestId(`environment-${environment.id}`)
await expect(row.getByText(projectName, {exact: true})).toBeVisible()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {ontrack} from "@ontrack/ontrack";
import {login} from "../../core/login";
import {EnvironmentsPage} from "./Environments";
import {expect} from "@playwright/test";
import {createSlot} from "./slotFixtures";
import {PipelinePage} from "./PipelinePage";

export const manualApprovalInEnvironmentsPage = async (page) => {
export const manualApprovalInPipelinePage = async (page) => {
const {project, slot} = await createSlot(ontrack())
await ontrack().environments.addManualApproval({slot})

Expand All @@ -15,10 +15,10 @@ export const manualApprovalInEnvironmentsPage = async (page) => {

await login(page)

const environmentsPage = new EnvironmentsPage(page)
await environmentsPage.goTo()
const pipelinePage = new PipelinePage(page, pipeline)
await pipelinePage.goTo()

const {pipelineActions} = await environmentsPage.checkPipelineCard(pipeline)
const pipelineActions = await pipelinePage.checkPipelineActions()
await pipelineActions.expectManualInputButton()
await pipelineActions.expectStatusProgress({value: 0})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ import {test} from "@playwright/test";
import {ontrack} from "@ontrack/ontrack";
import {login} from "../../core/login";
import {PipelinePage} from "./PipelinePage";
import {manualApprovalInEnvironmentsPage} from "./manualApprovalFixtures";
import {createSlot} from "./slotFixtures";

test('manual approval on the environments page', async ({page}) => {
await manualApprovalInEnvironmentsPage(page)
})

test('manual approval on the pipeline page', async ({page}) => {
const {project, slot} = await createSlot(ontrack())
await ontrack().environments.addManualApproval({slot})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {test} from "@playwright/test";
import {manualApprovalInEnvironmentsPage} from "./manualApprovalFixtures";
import {manualApprovalInPipelinePage} from "./manualApprovalFixtures";

test('pipeline status refreshed when inputs completed', async ({page}) => {
await manualApprovalInEnvironmentsPage(page)
await manualApprovalInPipelinePage(page)
})

test('pipeline marked as deploying', async ({page}) => {
const {pipelineActions} = await manualApprovalInEnvironmentsPage(page)
const {pipelineActions} = await manualApprovalInPipelinePage(page)
// Pipeline is now ready to be set in "deploying" mode
await pipelineActions.checkDeployingAction()
await pipelineActions.deploying()
Expand Down

0 comments on commit bf0d094

Please sign in to comment.