Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e updates
Browse files Browse the repository at this point in the history
benjaminpkane committed Oct 21, 2024
1 parent 263b696 commit fb56e23
Showing 6 changed files with 23 additions and 19 deletions.
6 changes: 4 additions & 2 deletions app/packages/app/src/routing/RouterContext.ts
Original file line number Diff line number Diff line change
@@ -178,15 +178,17 @@ export const createRouter = <T extends OperationType>(
};
};

const SKIP_EVENTS = new Set(["modal", "slice"]);

const makeGetEntryResource = <T extends OperationType>() => {
let currentLocation: FiftyOneLocation;
let currentResource: Resource<Entry<T>>;

const isReusable = (location: FiftyOneLocation) => {
if (currentLocation) {
return (
location.state.event === "modal" ||
currentLocation?.state.event === "modal"
SKIP_EVENTS.has(location.state.event || "") ||
SKIP_EVENTS.has(currentLocation?.state.event || "")
);
}

2 changes: 1 addition & 1 deletion app/packages/app/src/routing/matchPath.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const compilePath = (path: string) =>
});

export type LocationState<T extends OperationType = OperationType> = {
event?: "modal";
event?: "modal" | "slice";
fieldVisibility?: State.FieldVisibilityStage;
groupSlice?: string;
modalSelector?: ModalSelector;
6 changes: 5 additions & 1 deletion app/packages/app/src/useEvents/useSetGroupSlice.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,11 @@ const useSetGroupSlice: EventHandlerHook = ({ router, session }) => {
session.current.sessionGroupSlice = slice;
});

router.push(pathname, { ...router.location.state, groupSlice: slice });
router.push(pathname, {
...router.location.state,
event: "slice",
groupSlice: slice,
});
},
[router, session]
);
6 changes: 5 additions & 1 deletion app/packages/app/src/useWriters/onSetGroupSlice.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,11 @@ const onSetGroupSlice: RegisteredWriter<"sessionGroupSlice"> =

const pathname = router.history.location.pathname + string;

router.push(pathname, { ...router.location.state, groupSlice: slice });
router.push(pathname, {
...router.location.state,
event: "slice",
groupSlice: slice,
});

if (env().VITE_NO_STATE) return;
commitMutation<setGroupSliceMutation>(environment, {
8 changes: 3 additions & 5 deletions e2e-pw/src/oss/poms/grid/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, Locator, Page } from "src/oss/fixtures";
import { Locator, Page, expect } from "src/oss/fixtures";
import { EventUtils } from "src/shared/event-utils";
import { GridActionsRowPom } from "../action-row/grid-actions-row";
import { GridSliceSelectorPom } from "../action-row/grid-slice-selector";
@@ -52,9 +52,7 @@ export class GridPom {
}

async openNthSample(n: number) {
await this.url.pageChange(() =>
this.getNthLooker(n).click({ position: { x: 10, y: 80 } })
);
await this.getNthLooker(n).click({ position: { x: 10, y: 80 } });
}

async openFirstSample() {
@@ -80,7 +78,7 @@ export class GridPom {
}

async selectSlice(slice: string) {
await this.url.pageChange(() => this.sliceSelector.selectSlice(slice));
await this.sliceSelector.selectSlice(slice);
}

/**
14 changes: 5 additions & 9 deletions e2e-pw/src/oss/poms/modal/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, Locator, Page } from "src/oss/fixtures";
import { Locator, Page, expect } from "src/oss/fixtures";
import { EventUtils } from "src/shared/event-utils";
import { Duration } from "../../utils";
import { ModalTaggerPom } from "../action-row/tagger/modal-tagger";
@@ -118,11 +118,9 @@ export class ModalPom {
) {
const currentSampleId = await this.sidebar.getSampleId();

await this.url.pageChange(() =>
this.locator
.getByTestId(`nav-${direction === "forward" ? "right" : "left"}-button`)
.click()
);
await this.locator
.getByTestId(`nav-${direction === "forward" ? "right" : "left"}-button`)
.click();

// wait for sample id to change
await this.page.waitForFunction((currentSampleId) => {
@@ -219,9 +217,7 @@ export class ModalPom {

async close() {
// close by clicking outside of modal
await this.url.pageChange(() =>
this.page.click("body", { position: { x: 0, y: 0 } })
);
await this.page.click("body", { position: { x: 0, y: 0 } });
}

async navigateNextSample(allowErrorInfo = false) {

0 comments on commit fb56e23

Please sign in to comment.