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

Commit

Permalink
test cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon committed Oct 16, 2023
1 parent e3381b1 commit 70bcc3c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
14 changes: 14 additions & 0 deletions cypress/integration/myPatches/patchCard/dropdown_menu.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { INCLUDE_HIDDEN_PATCHES } from "constants/cookies";

const patchWithoutVersion = "test meee";
const patchWithVersion = "main: EVG-7823 add a commit queue message (#4048)";
const patchWithVersionOnCommitQueue =
Expand Down Expand Up @@ -100,8 +102,10 @@ describe("Dropdown Menu of Patch Actions", { testIsolation: false }, () => {
});
cy.dataCy("enqueue-patch").should("be.disabled");
});

it("Toggle patch visibility", () => {
// "Include hidden" checkbox is not checked and patch is visible
cy.getCookie(INCLUDE_HIDDEN_PATCHES).should("not.exist");
cy.getInputByLabel("Include hidden").should("not.be.checked");
cy.location("search").should("not.contain", "hidden=true");
getPatchCardByDescription("testtest")
Expand All @@ -116,6 +120,11 @@ describe("Dropdown Menu of Patch Actions", { testIsolation: false }, () => {
cy.get("@targetPatchCard").should("not.exist");
// Check "Include hidden" checkbox and unhide patch card
cy.dataCy("include-hidden-checkbox").check({ force: true });
cy.getCookie(INCLUDE_HIDDEN_PATCHES).should(
"have.property",
"value",
"true"
);
cy.location("search").should("contain", "hidden=true");
cy.get("@targetPatchCard")
.should("be.visible")
Expand All @@ -127,6 +136,11 @@ describe("Dropdown Menu of Patch Actions", { testIsolation: false }, () => {
cy.get("@targetPatchCard").should("be.visible");
// Uncheck "Include hidden" and verify patch card is visible
cy.dataCy("include-hidden-checkbox").uncheck({ force: true });
cy.getCookie(INCLUDE_HIDDEN_PATCHES).should(
"have.property",
"value",
"false"
);
cy.location("search").should("contain", "hidden=false");
cy.get("@targetPatchCard").should("be.visible");
});
Expand Down
7 changes: 6 additions & 1 deletion src/components/PatchesPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { PageWrapper, FiltersWrapper, PageTitle } from "components/styles";
import {
INCLUDE_COMMIT_QUEUE_PROJECT_PATCHES,
INCLUDE_COMMIT_QUEUE_USER_PATCHES,
INCLUDE_HIDDEN_PATCHES,
} from "constants/cookies";
import { size } from "constants/tokens";
import { PatchesPagePatchesFragment, PatchesInput } from "gql/generated/types";
Expand Down Expand Up @@ -63,7 +64,10 @@ export const PatchesPage: React.FC<Props> = ({
Cookies.get(cookie) === "true"
);
const [includeHiddenCheckboxChecked, setIsIncludeHiddenCheckboxChecked] =
useQueryParam(PatchPageQueryParams.Hidden, false);
useQueryParam(
PatchPageQueryParams.Hidden,
Cookies.get(INCLUDE_HIDDEN_PATCHES) === "true"
);
const { limit, page } = usePatchesInputFromSearch(search);
const { inputValue, setAndSubmitInputValue } = useFilterInputChangeHandler({
urlParam: PatchPageQueryParams.PatchName,
Expand All @@ -86,6 +90,7 @@ export const PatchesPage: React.FC<Props> = ({
e: React.ChangeEvent<HTMLInputElement>
): void => {
setIsIncludeHiddenCheckboxChecked(e.target.checked);
Cookies.set(INCLUDE_HIDDEN_PATCHES, e.target.checked ? "true" : "false");
// eslint-disable-next-line no-unused-expressions
analyticsObject.sendEvent({ name: "Filter Hidden" });
};
Expand Down
25 changes: 13 additions & 12 deletions src/constants/cookies.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
export const HIDE_FEEDBACK = "HIDE_FEEDBACK";
export const ANNOUNCEMENT_TOAST = "announcement-toast";
export const SUBSCRIPTION_METHOD = "subscription-method";
export const getNotificationTriggerCookie = (type: string) =>
`${type}-notification-trigger`;
export const SLACK_NOTIFICATION_BANNER = "has-closed-slack-banner";
export const CURRENT_PROJECT = "mci-project-cookie";
export const COMMIT_CHART_TYPE_VIEW_OPTIONS_ACCORDION =
"commit-chart-view-options-accordion";
export const CURRENT_PROJECT = "mci-project-cookie";
export const CY_DISABLE_COMMITS_WELCOME_MODAL =
"cy-disable-commits-welcome-modal";
export const CY_DISABLE_NEW_USER_WELCOME_MODAL =
"cy-disable-new-user-welcome-modal";
export const DISABLE_QUERY_POLLING = "disable-query-polling";
export const SEEN_MIGRATE_GUIDE_CUE = "seen-migrate-guide-cue";
export const SEEN_HONEYCOMB_GUIDE_CUE = "seen-honeycomb-guide-cue";
export const getNotificationTriggerCookie = (type: string) =>
`${type}-notification-trigger`;
export const HIDE_FEEDBACK = "HIDE_FEEDBACK";
export const INCLUDE_COMMIT_QUEUE_PROJECT_PATCHES =
"include-commit-queue-project-patches";
export const INCLUDE_COMMIT_QUEUE_USER_PATCHES =
"include-commit-queue-user-patches";
export const CY_DISABLE_NEW_USER_WELCOME_MODAL =
"cy-disable-new-user-welcome-modal";
export const CY_DISABLE_COMMITS_WELCOME_MODAL =
"cy-disable-commits-welcome-modal";
export const INCLUDE_HIDDEN_PATCHES = "include-hidden-patches";
export const SEEN_HONEYCOMB_GUIDE_CUE = "seen-honeycomb-guide-cue";
export const SEEN_MIGRATE_GUIDE_CUE = "seen-migrate-guide-cue";
export const SLACK_NOTIFICATION_BANNER = "has-closed-slack-banner";
export const SUBSCRIPTION_METHOD = "subscription-method";

0 comments on commit 70bcc3c

Please sign in to comment.