Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
dexamundsen committed Dec 1, 2024
1 parent ced075e commit 547a212
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 69 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
24 changes: 12 additions & 12 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

0 comments on commit 547a212

Please sign in to comment.