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

EVG-6867: Support searching by git hash on commit history #2073

Merged
merged 13 commits into from
Nov 16, 2023
206 changes: 73 additions & 133 deletions cypress/integration/projectHealth/commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,43 @@ describe("commits page", () => {
beforeEach(() => {
cy.visit("/commits/spruce");
});
it("should present a default view with only failing task icons visible", () => {
cy.dataCy("waterfall-task-status-icon").should("exist");
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 2);
cy.dataCy("waterfall-task-status-icon").should(
"have.attr",
"aria-label",
"failed icon"
);
cy.dataCy("grouped-task-status-badge").should("not.exist");
});

it("shows all icons and no badges when the view is toggled", () => {
cy.dataCy("waterfall-task-status-icon").should("exist");
describe("view", () => {
it("should present a default view with only failing task icons visible", () => {
cy.dataCy("waterfall-task-status-icon").should("exist");
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 2);
cy.dataCy("waterfall-task-status-icon").should(
"have.attr",
"aria-label",
"failed icon"
);
cy.dataCy("grouped-task-status-badge").should("not.exist");
});

cy.dataCy("view-all").click();
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 50);
cy.dataCy("grouped-task-status-badge").should("have.length", 0);
cy.location("search").should("contain", "view=ALL");
it("shows all icons and no badges when the view is toggled", () => {
cy.dataCy("waterfall-task-status-icon").should("exist");

cy.dataCy("view-failed").click();
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 2);
});
cy.dataCy("view-all").click();
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 50);
cy.dataCy("grouped-task-status-badge").should("have.length", 0);
cy.location("search").should("contain", "view=ALL");

cy.dataCy("view-failed").click();
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 2);
});

it("shows all icons when loaded with the view all query param", () => {
cy.visit(`/commits/spruce?view=ALL`);
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 50);
it("shows all icons when loaded with the view all query param", () => {
cy.visit(`/commits/spruce?view=ALL`);
cy.dataCy("waterfall-task-status-icon")
.should("be.visible")
.should("have.length", 50);
});
});

it("should be able to collapse/expand commit graph which retains state when paginating", () => {
Expand Down Expand Up @@ -97,21 +100,7 @@ describe("commits page", () => {
cy.dataCy("prev-page-button").click();
cy.dataCy("prev-page-button").should("have.attr", "aria-disabled", "true");
});
it("should only show matching requester filters", () => {
cy.dataCy("requester-select").click();
cy.dataCy("requester-select-options").should("be.visible");
cy.dataCy("requester-select-options").within(() => {
cy.getInputByLabel("Git Tag").should("exist");
cy.getInputByLabel("Git Tag").should("not.be.checked");
cy.getInputByLabel("Git Tag").check({ force: true });
});
cy.dataCy("requester-select").click();
cy.dataCy("requester-select-options").should("not.exist");
cy.dataCy("commit-label").should("exist");
cy.dataCy("commit-label").each(($el) => {
cy.wrap($el).should("contain.text", "Git Tag");
});
});

it("resizing the page adjusts the number of commits rendered", () => {
cy.visit("/commits/spruce");
cy.dataCy("commit-chart-container").should("have.length", 9);
Expand All @@ -120,94 +109,7 @@ describe("commits page", () => {
cy.viewport(1280, 1024);
cy.dataCy("commit-chart-container").should("have.length", 6);
});
describe("task filtering", () => {
beforeEach(() => {
cy.visit("/commits/spruce");
});
it("applying an `all` status filter should show all matching tasks with non failing tasks grouped", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("All").should("exist");
cy.getInputByLabel("All").should("not.be.checked");
cy.getInputByLabel("All").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("waterfall-task-status-icon").should("have.length", 2);
});
it("applying a status filter should only show matching tasks", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("Succeeded").should("exist");
cy.getInputByLabel("Succeeded").should("not.be.checked");
cy.getInputByLabel("Succeeded").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("grouped-task-status-badge").should(
"contain.text",
"Succeeded"
);
cy.dataCy("waterfall-task-status-icon").should("not.exist");
});
it("applying a build variant filter should show all task statuses by default", () => {
cy.getInputByLabel("Add New Filter").type("Ubuntu").type("{enter}");
cy.dataCy("filter-badge").should("have.length", 1);
cy.dataCy("filter-badge").should("have.text", "buildVariants: Ubuntu");
cy.location("search").should("contain", "?buildVariants=Ubuntu");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("waterfall-task-status-icon").should("have.length", 2);
cy.dataCy("waterfall-task-status-icon").should(
"have.attr",
"aria-label",
"failed icon"
);
});
it("applying a task filter should show all task icons instead of groupings", () => {
cy.contains("button", "Build Variant").should("exist");
cy.contains("button", "Build Variant").click({ force: true });
cy.get("li").contains("Task").should("be.visible");
cy.get("li").contains("Task").click();
cy.getInputByLabel("Add New Filter").type(".").type("{enter}");
cy.dataCy("grouped-task-status-badge").should("not.exist");
cy.dataCy("waterfall-task-status-icon").should("have.length", 51);
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='failed icon']")
.should("exist");
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='failed icon']")
.should("have.length", 2);
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='success icon']")
.should("exist");
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='success icon']")
.should("have.length", 49);
});
it("should hide commits that don't match applied filters", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("Failed").should("exist");
cy.getInputByLabel("Failed").should("not.be.checked");
cy.getInputByLabel("Failed").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("not.exist");
cy.dataCy("inactive-commits-button").should("have.length", 5);
cy.dataCy("inactive-commits-button").each(($el) => {
cy.wrap($el).should("contain.text", "Unmatching");
});
});
});

describe("inactive / unmatching commit tooltips", () => {
beforeEach(() => {
cy.visit("/commits/spruce");
Expand Down Expand Up @@ -295,4 +197,42 @@ describe("commits page", () => {
});
});
});

describe("search by git commit", () => {
const revision = "aac24c894994e44a2dadc6db40b46eb82e41f2cc";

beforeEach(() => {
cy.visit("/commits/spruce");
cy.dataCy("waterfall-menu").click();
cy.dataCy("git-commit-search").click();
cy.dataCy("git-commit-search-modal").should("be.visible");
cy.getInputByLabel("Git Commit Hash").type(revision);
cy.contains("button", "Submit").click();
cy.location("search").should("contain", `revision=${revision}`);
});

it("should jump to the given commit", () => {
cy.get("[data-selected='true']").should("be.visible");
cy.get("[data-selected='true']").should(
"contain.text",
revision.substring(0, 7)
);
});

it("should be possible to paginate from the given commit", () => {
cy.get("[data-selected='true']").should("be.visible");

cy.dataCy("next-page-button").click();
cy.get("[data-selected='true']").should("not.exist");
cy.dataCy("prev-page-button").click();

cy.get("[data-selected='true']").should("be.visible");

cy.dataCy("prev-page-button").click();
cy.get("[data-selected='true']").should("not.exist");
cy.dataCy("next-page-button").click();

cy.get("[data-selected='true']").should("be.visible");
});
});
});
107 changes: 107 additions & 0 deletions cypress/integration/projectHealth/filtering.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
describe("filtering", () => {
beforeEach(() => {
cy.visit("/commits/spruce");
});

it("should only show matching requester filters", () => {
cy.dataCy("requester-select").click();
cy.dataCy("requester-select-options").should("be.visible");
cy.dataCy("requester-select-options").within(() => {
cy.getInputByLabel("Git Tag").should("exist");
cy.getInputByLabel("Git Tag").should("not.be.checked");
cy.getInputByLabel("Git Tag").check({ force: true });
});
cy.dataCy("requester-select").click();
cy.dataCy("requester-select-options").should("not.exist");
cy.dataCy("commit-label").should("exist");
cy.dataCy("commit-label").each(($el) => {
cy.wrap($el).should("contain.text", "Git Tag");
});
});

describe("task filtering", () => {
it("applying an `all` status filter should show all matching tasks with non failing tasks grouped", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("All").should("exist");
cy.getInputByLabel("All").should("not.be.checked");
cy.getInputByLabel("All").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("waterfall-task-status-icon").should("have.length", 2);
});
it("applying a status filter should only show matching tasks", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("Succeeded").should("exist");
cy.getInputByLabel("Succeeded").should("not.be.checked");
cy.getInputByLabel("Succeeded").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("grouped-task-status-badge").should(
"contain.text",
"Succeeded"
);
cy.dataCy("waterfall-task-status-icon").should("not.exist");
});
it("applying a build variant filter should show all task statuses by default", () => {
cy.getInputByLabel("Add New Filter").type("Ubuntu{enter}");
cy.dataCy("filter-badge").should("have.length", 1);
cy.dataCy("filter-badge").should("have.text", "buildVariants: Ubuntu");
cy.location("search").should("contain", "?buildVariants=Ubuntu");
cy.dataCy("grouped-task-status-badge").should("have.length", 9);
cy.dataCy("waterfall-task-status-icon").should("have.length", 2);
cy.dataCy("waterfall-task-status-icon").should(
"have.attr",
"aria-label",
"failed icon"
);
});
it("applying a task filter should show all task icons instead of groupings", () => {
cy.contains("button", "Build Variant").should("exist");
cy.contains("button", "Build Variant").click({ force: true });
cy.get("li").contains("Task").should("be.visible");
cy.get("li").contains("Task").click();
cy.getInputByLabel("Add New Filter").type(".{enter}");
cy.dataCy("grouped-task-status-badge").should("not.exist");
cy.dataCy("waterfall-task-status-icon").should("have.length", 51);
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='failed icon']")
.should("exist");
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='failed icon']")
.should("have.length", 2);
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='success icon']")
.should("exist");
cy.dataCy("waterfall-task-status-icon")
.get("[aria-label='success icon']")
.should("have.length", 49);
});
it("should hide commits that don't match applied filters", () => {
cy.dataCy("project-task-status-select").should("exist");
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("be.visible");
cy.dataCy("project-task-status-select-options").within(() => {
cy.getInputByLabel("Failed").should("exist");
cy.getInputByLabel("Failed").should("not.be.checked");
cy.getInputByLabel("Failed").check({ force: true });
});
cy.dataCy("project-task-status-select").click();
cy.dataCy("project-task-status-select-options").should("not.exist");
cy.dataCy("grouped-task-status-badge").should("not.exist");
cy.dataCy("inactive-commits-button").should("have.length", 5);
cy.dataCy("inactive-commits-button").each(($el) => {
cy.wrap($el).should("contain.text", "Unmatching");
});
});
});
});
2 changes: 2 additions & 0 deletions src/analytics/projectHealth/useProjectHealthAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Action =
name: "Toggle commit chart label tooltip";
}
| { name: "Open Notification Modal" }
| { name: "Open Git Commit Search Modal" }
| { name: "Search for commit"; commit: string }
| {
name: "Add Notification";
subscription: SaveSubscriptionForUserMutationVariables["subscription"];
Expand Down
6 changes: 6 additions & 0 deletions src/components/ButtonDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ interface Props {
dropdownItems: JSX.Element[];
size?: "default" | "small" | "large";
"data-cy"?: string;
open?: boolean;
setOpen?: (open: boolean) => void;
}

export const ButtonDropdown: React.FC<Props> = ({
"data-cy": dataCy = "ellipsis-btn",
disabled = false,
dropdownItems,
loading = false,
open = undefined,
setOpen = undefined,
size = "small",
}) => (
<Menu
Expand All @@ -32,6 +36,8 @@ export const ButtonDropdown: React.FC<Props> = ({
data-cy="card-dropdown"
popoverZIndex={zIndex.popover}
adjustOnMutation
open={open}
setOpen={setOpen}
>
{dropdownItems}
</Menu>
Expand Down
1 change: 1 addition & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,7 @@ export type MainlineCommitsOptions = {
limit?: InputMaybe<Scalars["Int"]["input"]>;
projectIdentifier: Scalars["String"]["input"];
requesters?: InputMaybe<Array<Scalars["String"]["input"]>>;
revision?: InputMaybe<Scalars["String"]["input"]>;
shouldCollapse?: InputMaybe<Scalars["Boolean"]["input"]>;
skipOrderNumber?: InputMaybe<Scalars["Int"]["input"]>;
};
Expand Down
Loading