From 81abcc05ced753d1485c55dba92152271d815a53 Mon Sep 17 00:00:00 2001 From: Zackary Santana <64446617+ZackarySantana@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:30:05 -0500 Subject: [PATCH] feat: add some tests --- .../relevantCommits/RelevantCommits.test.tsx | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/src/pages/task/actionButtons/relevantCommits/RelevantCommits.test.tsx b/src/pages/task/actionButtons/relevantCommits/RelevantCommits.test.tsx index 452a13e4cc..bf751c6a6a 100644 --- a/src/pages/task/actionButtons/relevantCommits/RelevantCommits.test.tsx +++ b/src/pages/task/actionButtons/relevantCommits/RelevantCommits.test.tsx @@ -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( { 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( { 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( { getPatchTaskWithRunningBaseTask, getLastPassingVersion, getLastExecutedVersion, + getBreakingCommit, ]} > @@ -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"); }); }); @@ -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