-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
85 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,86 @@ | ||
import { render, screen } from '@testing-library/svelte'; | ||
import { describe, expect, it } from 'vitest'; | ||
import Pipeline from '../pipeline.svelte'; | ||
|
||
describe('pipeline test suite', () => { | ||
const pipeline = 'Pipeline #31'; | ||
it('displays a heading with the executed pipeline number', () => { | ||
render(Pipeline); | ||
const pipelineHeading = screen.getByRole('heading', { name: pipeline }); | ||
expect(pipelineHeading).toBeVisible(); | ||
}); | ||
import { render, cleanup, screen, within } from "@testing-library/svelte"; | ||
import { afterEach, beforeEach, describe, expect, it } from "vitest"; | ||
import { formatTime, formatDuration } from "$lib/utils"; | ||
import Pipeline from "$lib/components/pipeline.svelte"; | ||
import pipeline from "./fixtures/pipeline.json"; | ||
import type { CiRunMetadata } from "$lib/types/carenage"; | ||
|
||
describe("pipeline test suite", () => { | ||
beforeEach(() => render(Pipeline, { props: { pipeline: pipeline } })); | ||
afterEach(() => cleanup()); | ||
it("displays to the user a section with links to the project's page and pipeline's logs", () => { | ||
const pipelineMetadataLabel = `Pipeline #${pipeline.pipeline_repo_id} metadata`; | ||
const pipelineMetadataSection = screen.getByRole("region", { name: pipelineMetadataLabel }); | ||
const pipelineHeading = screen.getByRole("heading", { | ||
name: pipelineMetadataLabel | ||
}); | ||
const pipelineLink = within(pipelineMetadataSection).getByRole("link", { name: /1520057997/i }); | ||
const projectLink = within(pipelineMetadataSection).getByRole("link", { | ||
name: /hubblo\/carenage/i | ||
}); | ||
|
||
expect(pipelineMetadataSection).toBeVisible(); | ||
expect(pipelineHeading).toBeVisible(); | ||
expect(pipelineLink).toBeVisible(); | ||
expect(projectLink).toBeVisible(); | ||
}); | ||
it("displays to the user a selection of metadata related to the pipeline", () => { | ||
const pipelineMetadataLabel = `Pipeline #${pipeline.pipeline_repo_id} metadata`; | ||
const pipelineMetadataSection = screen.getByRole("region", { name: pipelineMetadataLabel }); | ||
const formattedPipelineDuration = formatDuration(pipeline.duration); | ||
const formattedPipelineStartDate = formatTime(pipeline.started_at); | ||
const formattedPipelineEndDate = formatTime(pipeline.finished_at); | ||
|
||
const pipelineDuration = within(pipelineMetadataSection).getByText( | ||
`Pipeline duration: ${formattedPipelineDuration}` | ||
); | ||
const pipelineStartDate = within(pipelineMetadataSection).getByText( | ||
`Pipeline started at: ${formattedPipelineStartDate}` | ||
); | ||
const pipelineEndDate = within(pipelineMetadataSection).getByText( | ||
`Pipeline finished at: ${formattedPipelineEndDate}` | ||
); | ||
expect(pipelineDuration).toBeVisible(); | ||
expect(pipelineStartDate).toBeVisible(); | ||
expect(pipelineEndDate).toBeVisible(); | ||
}); | ||
it("displays to the user a section with links to the executed runs for the given pipeline", () => { | ||
const runsTableLabel = `Executed runs for pipeline #${pipeline.pipeline_repo_id}`; | ||
const runsTableSection = screen.getByRole("region", { name: runsTableLabel }); | ||
const runsTableHeading = screen.getByRole("heading", { name: runsTableLabel }); | ||
|
||
const runsTable = within(runsTableSection).getByRole("table", { | ||
name: "List of executed CI runs for the pipeline" | ||
}); | ||
const runIdColumn = within(runsTable).getByRole("columnheader", { name: "Run ID" }); | ||
const runDateOfExecutionColumn = within(runsTable).getByRole("columnheader", { | ||
name: "Run start time of execution" | ||
}); | ||
expect(runsTableHeading).toBeVisible(); | ||
expect(runIdColumn).toBeVisible(); | ||
expect(runDateOfExecutionColumn).toBeVisible(); | ||
|
||
pipeline.runs.forEach((run: CiRunMetadata) => { | ||
const formattedPipelineStartTime = formatTime(run.started_at); | ||
const runIdCell = within(runsTable).getByRole("link", { | ||
name: `Run #${run.run_repo_id.toString()}` | ||
}); | ||
const runDateOfExecutionCell = within(runsTable).getByRole("cell", { | ||
name: formattedPipelineStartTime | ||
}); | ||
expect(runIdCell).toBeVisible(); | ||
expect(runDateOfExecutionCell).toBeVisible(); | ||
}); | ||
}); | ||
it("displays to the user a section with the aggregated metrics for the pipeline, where the user can choose a metric to be displayed", () => { | ||
const aggregatedMetricValuesLabel = "Pipeline aggregated metric values"; | ||
const aggregatedMetricValuesHeading = screen.getByRole("heading", { | ||
name: aggregatedMetricValuesLabel | ||
}); | ||
const aggregatedMetricValuesSection = screen.getByRole("region", { | ||
name: aggregatedMetricValuesLabel | ||
}); | ||
expect(aggregatedMetricValuesSection).toBeVisible(); | ||
expect(aggregatedMetricValuesHeading).toBeVisible(); | ||
}); | ||
}); |