Skip to content

Commit

Permalink
Run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
dexamundsen committed Dec 2, 2024
1 parent 1b11a33 commit 801f09a
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 74 deletions.
71 changes: 37 additions & 34 deletions ui/cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,48 +31,51 @@ Cypress.Commands.add("createCohortFromSearch", (name, search, domain) => {
cy.iframe().find("button[aria-label=back]").click();
});

Cypress.Commands.add("createCohortFromSearchThenAddAnnotationData", (name, search, domain) => {
cy.get("button:Contains(New cohort)").click();
cy.wait(2000);

cy.iframe().find("[data-testid='EditIcon']").first().click();
cy.iframe()
.find("input[name=text]")
.type("{selectall}" + name);
cy.iframe().find("button:Contains(Update)").click();
cy.iframe().find("a:Contains(Add some criteria)").first().click();
if (domain) {
cy.iframe().find(`[data-testid='${domain}']`).click();
}
cy.iframe().find("input").type(search);
Cypress.Commands.add(
"createCohortFromSearchThenAddAnnotationData",
(name, search, domain) => {
cy.get("button:Contains(New cohort)").click();
cy.wait(2000);

cy.iframe().find("[data-testid='EditIcon']").first().click();
cy.iframe()
.find("input[name=text]")
.type("{selectall}" + name);
cy.iframe().find("button:Contains(Update)").click();
cy.iframe().find("a:Contains(Add some criteria)").first().click();
if (domain) {
cy.iframe().find(`[data-testid='${domain}']`).click();
}
cy.iframe().find("input").type(search);

cy.possiblyMultiSelect(search);
cy.possiblyMultiSelect(search);

cy.iframe().contains("Review").click();
cy.iframe().contains("Review").click();

cy.iframe().find("[data-testid='AddIcon']").first().click();
cy.iframe().find("input[name=name]").type("Initial");
cy.iframe().find("input[name=size]").type("2");
cy.iframe().find("button:Contains(Create)").click();
cy.iframe().find("[data-testid='AddIcon']").first().click();
cy.iframe().find("input[name=name]").type("Initial");
cy.iframe().find("input[name=size]").type("2");
cy.iframe().find("button:Contains(Create)").click();

cy.iframe().find("button:Contains(Annotations)").click();
cy.iframe().find("button:Contains(Annotations)").click();

cy.iframe().contains("Add annotation field").click();
cy.iframe().find(".MuiSelect-select:Contains(Free text)").click();
cy.iframe().find("li:Contains(Review status)").click();
cy.iframe().find("input[name=displayName]").type("Test status");
cy.iframe().find("button:Contains(Create)").click().should("not.exist");
cy.iframe().contains("Add annotation field").click();
cy.iframe().find(".MuiSelect-select:Contains(Free text)").click();
cy.iframe().find("li:Contains(Review status)").click();
cy.iframe().find("input[name=displayName]").type("Test status");
cy.iframe().find("button:Contains(Create)").click().should("not.exist");

cy.iframe().find("button:Contains(Reviews)").click();
cy.iframe().find("button:Contains(Review individual participants)").click();
cy.iframe().find("button:Contains(Reviews)").click();
cy.iframe().find("button:Contains(Review individual participants)").click();

cy.iframe().find(".MuiSelect-select").click();
cy.iframe().find("li:Contains(Included)").click();
cy.iframe().find(".MuiSelect-select").click();
cy.iframe().find("li:Contains(Included)").click();

cy.iframe().find("[data-testid='ArrowBackIcon']").first().click();
cy.iframe().find("[data-testid='ArrowBackIcon']").first().click();
cy.iframe().find("button[aria-label=back]", { timeout: 20000 }).click();
});
cy.iframe().find("[data-testid='ArrowBackIcon']").first().click();
cy.iframe().find("[data-testid='ArrowBackIcon']").first().click();
cy.iframe().find("button[aria-label=back]", { timeout: 20000 }).click();
}
);

Cypress.Commands.add("multiSelect", (search) => {
cy.iframe()
Expand Down
15 changes: 12 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@
"codegen": "./codegen.sh"
},
"eslintConfig": {
"extends": ["react-app", "react-app/jest"]
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all"],
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
Expand Down Expand Up @@ -118,6 +125,8 @@
"prettier-plugin-organize-imports": "^2.3.4"
},
"jest": {
"transformIgnorePatterns": ["node_modules/(?!(@brightspace-ui)/)"]
"transformIgnorePatterns": [
"node_modules/(?!(@brightspace-ui)/)"
]
}
}
7 changes: 5 additions & 2 deletions ui/src/activityLog/cohortRevision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import useSWRImmutable from "swr/immutable";
export function CohortRevision() {
const studySource = useStudySource();
const underlaySource = useUnderlaySource();
const { studyId, cohortId, revisionId } =
useParams<{ studyId: string; cohortId: string; revisionId: string }>();
const { studyId, cohortId, revisionId } = useParams<{
studyId: string;
cohortId: string;
revisionId: string;
}>();

const cohortState = useSWRImmutable(
{ type: "cohort", studyId, cohortId, revisionId },
Expand Down
52 changes: 29 additions & 23 deletions ui/src/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ function renderApp(fakeAuthCtx?: FakeAuthContextType) {
let appRouter: Router;
if (fakeAuthCtx) {
const env = getEnvironment();
env.REACT_APP_AUTH0_DOMAIN = "fake-domain"
env.REACT_APP_AUTH0_CLIENT_ID = "fake-client"
env.REACT_APP_AUTH0_AUDIENCE = "fake-audience"
appRouter = createAppRouter({authCtx: fakeAuthCtx});
env.REACT_APP_AUTH0_DOMAIN = "fake-domain";
env.REACT_APP_AUTH0_CLIENT_ID = "fake-client";
env.REACT_APP_AUTH0_AUDIENCE = "fake-audience";
appRouter = createAppRouter({ authCtx: fakeAuthCtx });
render(<AppWithRouter {...appRouter} />);

} else {
appRouter = createAppRouter({} as AuthProviderProps);
appRouter = createAppRouter({} as AuthProviderProps);
render(<App />);

}

return appRouter
return appRouter;
}

test("render included datasets heading", async () => {
Expand All @@ -41,37 +39,45 @@ test("render included datasets heading", async () => {
});

test("with-auth: signed out redirects to login screen", () => {
renderApp( makeFakeAuth({
expired: true
}));
renderApp(
makeFakeAuth({
expired: true,
})
);
expect(screen.getByText(logInText)).toBeInTheDocument();
expect(
screen.getByRole("button", { name: logInText })
).toBeInTheDocument();
expect(screen.getByRole("button", { name: logInText })).toBeInTheDocument();
});

test("with-auth: signed in renders the home page", async () => {
renderApp(makeFakeAuth({
expired: false, profile: FakeProfile
}));
renderApp(
makeFakeAuth({
expired: false,
profile: FakeProfile,
})
);
await waitFor(() => {
expect(screen.getByText(/underlay_name/i)).toBeInTheDocument();
});
});

test("with-auth: login page while signed in redirects to home page", () => {
const appRouter = renderApp(makeFakeAuth({
expired: false, profile: FakeProfile
}));
const appRouter = renderApp(
makeFakeAuth({
expired: false,
profile: FakeProfile,
})
);
appRouter.navigate({ pathname: "/login" });
render(<RouterProvider router={appRouter} />);
expect(appRouter.state.location.pathname).toBe("/");
});

test("with-auth: signed out with bad url redirects to login screen", () => {
const appRouter = renderApp(makeFakeAuth({
expired: true
}));
const appRouter = renderApp(
makeFakeAuth({
expired: true,
})
);
appRouter.navigate({ pathname: "/badurl" });
render(<RouterProvider router={appRouter} />);
expect(screen.getByText(logInText)).toBeInTheDocument();
Expand Down
10 changes: 5 additions & 5 deletions ui/src/cohortContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ export function useCohortContext() {
export function useNewCohortContext(showSnackbar: (message: string) => void) {
const studySource = useStudySource();
const underlaySource = useUnderlaySource();
const { studyId, cohortId } =
useParams<{ studyId: string; cohortId: string }>();
const { studyId, cohortId } = useParams<{
studyId: string;
cohortId: string;
}>();

if (!studyId || !cohortId) {
throw new Error(
Expand Down Expand Up @@ -148,9 +150,7 @@ export function useNewCohortContext(showSnackbar: (message: string) => void) {

mutate(
(key: { type: string; studyId: string; list: boolean }) =>
key.type === "cohort" &&
key.studyId === studyId &&
key.list === true,
key.type === "cohort" && key.studyId === studyId && key.list,
undefined,
{ revalidate: true }
);
Expand Down
10 changes: 5 additions & 5 deletions ui/src/featureSet/featureSetContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export function useNewFeatureSetContext(
) {
const studySource = useStudySource();
const underlaySource = useUnderlaySource();
const { studyId, featureSetId } =
useParams<{ studyId: string; featureSetId: string }>();
const { studyId, featureSetId } = useParams<{
studyId: string;
featureSetId: string;
}>();

if (!studyId || !featureSetId) {
throw new Error(
Expand Down Expand Up @@ -144,9 +146,7 @@ export function useNewFeatureSetContext(

mutate(
(key: { type: string; studyId: string; list: boolean }) =>
key.type === "featureSet" &&
key.studyId === studyId &&
key.list === true,
key.type === "featureSet" && key.studyId === studyId && key.list,
undefined,
{ revalidate: true }
);
Expand Down
6 changes: 4 additions & 2 deletions ui/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ export function useBackendCohort() {
export function useCohortGroupSectionAndGroup() {
const cohort = useCohort();

const { groupSectionId, groupId } =
useParams<{ groupSectionId: string; groupId: string }>();
const { groupSectionId, groupId } = useParams<{
groupSectionId: string;
groupId: string;
}>();
const sectionIndex = Math.max(
0,
cohort.groupSections.findIndex((s) => s.id === groupSectionId)
Expand Down

0 comments on commit 801f09a

Please sign in to comment.