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

Commit

Permalink
Merge branch 'main' into DEVPROD-942
Browse files Browse the repository at this point in the history
  • Loading branch information
khelif96 committed Nov 6, 2023
2 parents a14ec69 + 1fd137f commit 6c75c9f
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 584 deletions.
4 changes: 2 additions & 2 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,8 @@ buildvariants:
- ubuntu2204-large
expansions:
goroot: /opt/golang/go1.20
mongodb_url_2204: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-6.0.6.tgz
mongosh_url_2204: https://downloads.mongodb.com/compass/mongosh-1.9.0-linux-x64.tgz
mongodb_url_2204: https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu2204-7.0.2.tgz
mongosh_url_2204: https://downloads.mongodb.com/compass/mongosh-2.0.2-linux-x64.tgz
node_version: 16.17.0
modules:
- evergreen
Expand Down
6 changes: 5 additions & 1 deletion cypress/integration/version/task_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ describe("Task table", () => {
it("Updates the url when column headers are clicked", () => {
cy.visit(pathTasks);
waitForTaskTable();
// TODO: Remove wait in DEVPROD-597.
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(200);
cy.location("search").should(
"contain",
"sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC"
Expand Down Expand Up @@ -83,7 +86,8 @@ describe("Task table", () => {
});

["NAME", "STATUS", "BASE_STATUS", "VARIANT"].forEach((sortBy) => {
// TODO: This test doesn't work bc of issues with assertCorrectRequestVariables
// TODO: This test doesn't work bc of issues with assertCorrectRequestVariables.
// Remove skip in DEVPROD-597.
it.skip(`Fetches tasks sorted by ${sortBy} when ${sortBy} header is clicked`, () => {
// clickSorterAndAssertTasksAreFetched(sortBy);
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.166",
"version": "3.0.167",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand Down
13 changes: 1 addition & 12 deletions src/components/Header/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Cookies from "js-cookie";
import { Link, useParams } from "react-router-dom";
import { useNavbarAnalytics } from "analytics";
import Icon from "components/Icon";
import HalloweenTree from "components/Icon/icons/Halloween.svg";
import { CURRENT_PROJECT } from "constants/cookies";
import { wikiUrl } from "constants/externalResources";
import { getCommitsRoute, getUserPatchesRoute, routes } from "constants/routes";
Expand Down Expand Up @@ -61,10 +60,7 @@ export const Navbar: React.FC = () => {
to={routes.myPatches}
onClick={() => sendEvent({ name: "Click Logo Link" })}
>
<HalloweenTreeIcon
src={HalloweenTree}
alt="Evergreen Logo with Halloween Decorations"
/>
<Icon glyph="EvergreenLogo" size={32} />
</LogoLink>
<PrimaryLink
data-cy="project-health-link"
Expand Down Expand Up @@ -176,10 +172,3 @@ const secondaryStyle = css`
const SecondaryLink = styled.a`
${secondaryStyle}
`;

const HalloweenTreeIcon = styled.img`
height: 46px;
width: 46px;
position: relative;
bottom: 4px;
`;
26 changes: 0 additions & 26 deletions src/components/Icon/icons/Halloween.svg

This file was deleted.

192 changes: 72 additions & 120 deletions src/pages/task/actionButtons/previousCommits/PreviousCommits.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,28 @@ import { renderWithRouterMatch, screen, userEvent, waitFor } from "test_utils";
import { ApolloMock } from "types/gql";
import { PreviousCommits } from ".";

const goButton = { name: "Go" };
const select = { name: "Previous commits for this task" };

describe("previous commits", () => {
// Patch and mainline commit behavior only have a significant difference when it comes to determining
// the base or previous task. Patch gets the base task directly from BASE_VERSION_AND_TASK, while
// mainline commits needs to run another query LAST_MAINLINE_COMMIT to get previous task.
describe("patch specific", () => {
it("the GO button is disabled when there is no base task", async () => {
it("the button is disabled when there is no base task", async () => {
const { Component } = RenderFakeToastContext(
<MockedProvider mocks={[getPatchTaskWithNoBaseTask]}>
<PreviousCommits taskId="t1" />
</MockedProvider>
);
renderWithRouterMatch(<Component />);
await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"aria-disabled",
"true"
);
});
// Select won't be disabled because baseVersion exists
await waitFor(() => {
expect(screen.getByRole("button", select)).toHaveAttribute(
"aria-disabled",
"false"
);
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "true");
});
// Should say "base" for patches
expect(screen.getByText("Go to base commit")).toBeInTheDocument();
});
});

describe("mainline commits specific", () => {
it("the GO button is disabled when getParentTask returns null", async () => {
it("the button is disabled when getParentTask returns null", async () => {
const { Component } = RenderFakeToastContext(
<MockedProvider
mocks={[getMainlineTaskWithBaseVersion, getNullParentTask]}
Expand All @@ -56,23 +43,13 @@ describe("previous commits", () => {
renderWithRouterMatch(<Component />);

await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"aria-disabled",
"true"
);
});
// Select won't be disabled because baseVersion exists
await waitFor(() => {
expect(screen.getByRole("button", select)).toHaveAttribute(
"aria-disabled",
"false"
);
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "true");
});
// Should say "previous" for versions
expect(screen.getByText("Go to previous commit")).toBeInTheDocument();
});

it("the GO button is disabled when getParentTask returns an error", async () => {
it("the button is disabled when getParentTask returns an error", async () => {
const { Component } = RenderFakeToastContext(
<MockedProvider
mocks={[getMainlineTaskWithBaseVersion, getParentTaskWithError]}
Expand All @@ -83,24 +60,14 @@ describe("previous commits", () => {
renderWithRouterMatch(<Component />);

await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"aria-disabled",
"true"
);
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "true");
});
// Select won't be disabled because baseVersion exists
await waitFor(() => {
expect(screen.getByRole("button", select)).toHaveAttribute(
"aria-disabled",
"false"
);
});
// Should say "previous" for versions
expect(screen.getByText("Go to previous commit")).toBeInTheDocument();
});
});

it("the select & GO button are disabled when no base version exists", async () => {
it("the button is disabled when no base version exists", async () => {
const { Component } = RenderFakeToastContext(
<MockedProvider mocks={[getPatchTaskWithNoBaseVersion]}>
<PreviousCommits taskId="t3" />
Expand All @@ -109,50 +76,45 @@ describe("previous commits", () => {
renderWithRouterMatch(<Component />);

await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"aria-disabled",
"true"
);
});
await waitFor(() => {
expect(screen.getByRole("button", select)).toHaveAttribute(
"aria-disabled",
"true"
);
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "true");
});
});

it("when base task is passing, all dropdown items generate the same link.", async () => {
it("when base task is passing, all dropdown items generate the same link", async () => {
const user = userEvent.setup();
const { Component } = RenderFakeToastContext(
<MockedProvider mocks={[getPatchTaskWithSuccessfulBaseTask]}>
<MockedProvider
mocks={[
getPatchTaskWithSuccessfulBaseTask,
getLastPassingVersion,
getLastExecutedVersion,
]}
>
<PreviousCommits taskId="t1" />
</MockedProvider>
);
renderWithRouterMatch(<Component />);

await screen.findByRole("button", { name: "Previous commits" });
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "false");
await user.click(screen.getByRole("button", { name: "Previous commits" }));
await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);
expect(screen.getByRole("menu")).toBeVisible();
});
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last passing version" })
);
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last executed version" })
);
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);

expect(
screen.getByRole("menuitem", { name: "Go to base commit" })
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to last passing version" })
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" })
).toHaveAttribute("href", baseTaskHref);
});

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 () => {
Expand All @@ -166,30 +128,24 @@ describe("previous commits", () => {
);
renderWithRouterMatch(<Component />);

await screen.findByRole("button", { name: "Previous commits" });
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "false");
await user.click(screen.getByRole("button", { name: "Previous commits" }));
await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);
});
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last executed version" })
);
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last passing version" })
);
await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
"/task/last_passing_task"
);
expect(screen.getByRole("menu")).toBeVisible();
});

expect(
screen.getByRole("menuitem", { name: "Go to base commit" })
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to last passing version" })
).toHaveAttribute("href", "/task/last_passing_task");
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" })
).toHaveAttribute("href", baseTaskHref);
});

it("when base task is not in a finished state, the last executed & passing task is not the same as the base commit", async () => {
Expand All @@ -207,28 +163,24 @@ describe("previous commits", () => {
);
renderWithRouterMatch(<Component />);

await screen.findByRole("button", { name: "Previous commits" });
expect(
screen.getByRole("button", { name: "Previous commits" })
).toHaveAttribute("aria-disabled", "false");
await user.click(screen.getByRole("button", { name: "Previous commits" }));
await waitFor(() => {
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
baseTaskHref
);
expect(screen.getByRole("menu")).toBeVisible();
});
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last executed version" })
);
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
"/task/last_executed_task"
);
await user.click(screen.getByRole("button", select));
await user.click(
screen.getByRole("option", { name: "Go to last passing version" })
);
expect(screen.getByRole("link", goButton)).toHaveAttribute(
"href",
"/task/last_passing_task"
);

expect(
screen.getByRole("menuitem", { name: "Go to base commit" })
).toHaveAttribute("href", baseTaskHref);
expect(
screen.getByRole("menuitem", { name: "Go to last passing version" })
).toHaveAttribute("href", "/task/last_passing_task");
expect(
screen.getByRole("menuitem", { name: "Go to last executed version" })
).toHaveAttribute("href", "/task/last_executed_task");
});
});

Expand Down
Loading

0 comments on commit 6c75c9f

Please sign in to comment.