Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
feat: add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackarySantana committed Feb 21, 2024
1 parent 7435611 commit 81abcc0
Showing 1 changed file with 61 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("relevant commits", () => {
});
});

it("when base task is passing, all dropdown items generate the same link", async () => {
it("when base task is passing, last passing, base commit, and last executed dropdown items generate the same link and breaking commit is disabled", async () => {
const user = userEvent.setup();
const { Component } = RenderFakeToastContext(
<MockedProvider
Expand Down Expand Up @@ -115,9 +115,12 @@ describe("relevant commits", () => {
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" }),
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to breaking commit" }),
).toHaveAttribute("aria-disabled", "true");
});

it("when base task is failing, 'Go to base commit' and 'Go to last executed' dropdown items generate the same link and 'Go to last passing version' will be different.", async () => {
it("when base task is failing, 'Go to base commit' and 'Go to last executed' dropdown items generate the same link and 'Go to last passing version' will be different and 'Go to breaking commit' will be disabled", async () => {
const user = userEvent.setup();
const { Component } = RenderFakeToastContext(
<MockedProvider
Expand Down Expand Up @@ -146,16 +149,20 @@ describe("relevant commits", () => {
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" }),
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to breaking commit" }),
).toHaveAttribute("aria-disabled", "true");
});

it("when base task is not in a finished state, the last executed & passing task is not the same as the base commit", async () => {
it("when base task is not in a finished state, the last executed, passing task, and breaking task is not the same as the base commit", async () => {
const user = userEvent.setup();
const { Component } = RenderFakeToastContext(
<MockedProvider
mocks={[
getPatchTaskWithRunningBaseTask,
getLastPassingVersion,
getLastExecutedVersion,
getBreakingCommit,
]}
>
<RelevantCommits taskId="t3" />
Expand All @@ -181,6 +188,9 @@ describe("relevant commits", () => {
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" }),
).toHaveAttribute("href", "/task/last_executed_task");
expect(
screen.getByRole("menuitem", { name: "Go to breaking commit" }),
).toHaveAttribute("href", "/task/breaking_commit");
});
});

Expand Down Expand Up @@ -343,6 +353,54 @@ const getPatchTaskWithNoBaseVersion: ApolloMock<
},
};

const getBreakingCommit: ApolloMock<
LastMainlineCommitQuery,
LastMainlineCommitQueryVariables
> = {
request: {
query: LAST_MAINLINE_COMMIT,
variables: {
projectIdentifier: "evergreen",
skipOrderNumber: 3678,
buildVariantOptions: {
tasks: ["^lint-agent$"],
variants: ["^lint$"],
statuses: ["failed"],
},
},
},
result: {
data: {
mainlineCommits: {
versions: [
{
version: {
id: "evergreen_44110b57c6977bf3557009193628c9389772163f2",
buildVariants: [
{
tasks: [
{
id: "breaking_commit",
execution: 0,
order: 3677,
status: "failed",
__typename: "Task",
},
],
__typename: "GroupedBuildVariant",
},
],
__typename: "Version",
},
__typename: "MainlineCommitVersion",
},
],
__typename: "MainlineCommits",
},
},
},
};

const getLastPassingVersion: ApolloMock<
LastMainlineCommitQuery,
LastMainlineCommitQueryVariables
Expand Down

0 comments on commit 81abcc0

Please sign in to comment.