Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert new phenogrid to svg #468

Merged
merged 9 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,9 @@ Useful for setting the dimensions of your iframe container, for example:

```js
window.addEventListener("message", (event) => {
// get your iframe dom element somehow
const iframe = document.querySelector("iframe");
// some static styles that should probably be on it to prevent overflow
iframe.style.maxWidth = "100%";
iframe.style.maxHeight = "100%";
// dynamically fit dimensions to content (with some padding for possible scroll bars)
iframe.style.width = event.data.width + 20 + "px";
iframe.style.height = event.data.height + 20 + "px";
iframe.style.maxWidth = event.data.width + "px";
iframe.style.maxHeight = event.data.height + "px";
});
```

Expand Down
7 changes: 5 additions & 2 deletions frontend/e2e/axe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ const paths = [
"/explore",
"/about",
"/help",
"/overview",
"/cite",
"/team",
"/publications",
"/terms",
"/feedback",
"/MONDO:012345",
"/MONDO:0007523",
"/testbed",
];

Expand Down Expand Up @@ -45,7 +44,11 @@ const checkPage =

/** navigate to page */
await page.goto(path);

/** wait for content to load */
await page.waitForSelector("main");
await page.waitForSelector("section");
await page.waitForSelector("h1");
await page.waitForTimeout(100);

/** setup axe */
Expand Down
19 changes: 0 additions & 19 deletions frontend/fixtures/association-counts.json

This file was deleted.

14 changes: 0 additions & 14 deletions frontend/fixtures/entity.json

This file was deleted.

73 changes: 23 additions & 50 deletions frontend/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { rest } from "msw";
import { apiUrl, biolink } from "@/api";
import { http, HttpResponse, passthrough } from "msw";
import { feedbackEndpoint } from "@/api/feedback";
import { efetch, esummary } from "@/api/publications";
import { uptimeRobot } from "@/api/uptime";
import associationsTable from "./association-table.json";
import associations from "./associations.json";
import autocomplete from "./autocomplete.json";
import feedback from "./feedback.json";
import histopheno from "./histopheno.json";
Expand All @@ -17,68 +15,45 @@ import search from "./search.json";
import textAnnotator from "./text-annotator.json";
import uptime from "./uptime.json";

/** make single regex from base url and pattern */
const regex = (base: string = "", pattern: string = "") =>
new RegExp(base + pattern.replace(/[/\\]/g, "\\$&"), "i");

/** api calls to be mocked with fixture data */
export const handlers = [
/** api status monitoring on /help */
rest.post(regex(uptimeRobot), (req, res, ctx) =>
res(ctx.status(200), ctx.json(uptime)),
),
http.post(uptimeRobot, () => HttpResponse.json(uptime)),

/** histopheno data */
rest.get(regex(apiUrl, "/histopheno"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(histopheno)),
),
http.get("*/histopheno/:id", () => HttpResponse.json(histopheno)),

/** submit feedback form */
rest.post(regex(feedbackEndpoint), (req, res, ctx) =>
res(ctx.status(200), ctx.json(feedback)),
),
http.post(feedbackEndpoint, () => HttpResponse.json(feedback)),

/** search * */
rest.get(regex(apiUrl, "/search"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(search)),
),
http.get("*/search", () => HttpResponse.json(search)),

/** autocomplete */
rest.get(regex(apiUrl, "/autocomplete"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(autocomplete)),
),
http.get("*/autocomplete", () => HttpResponse.json(autocomplete)),

/** text annotator */
rest.post(regex(biolink, "/nlp/annotate"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(textAnnotator)),
),
http.post("*/nlp/annotate", () => HttpResponse.json(textAnnotator)),

/** phenotype explorer */
rest.get(regex(biolink, "/sim/search"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(phenotypeExplorerSearch)),
),
rest.post(regex(apiUrl, "/semsim/compare"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(phenotypeExplorerCompare)),
http.get("*/sim/search", () => HttpResponse.json(phenotypeExplorerSearch)),
http.post("*/semsim/compare", () =>
HttpResponse.json(phenotypeExplorerCompare),
),

/** node associations */
rest.get(regex(apiUrl, "/associations"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(associations)),
),

/** node associations table */
rest.get(regex(apiUrl, "/entity/.*/.*"), (req, res, ctx) =>
res(ctx.status(200), ctx.json(associationsTable)),
http.get("*/entity/:id/:assoctype", () =>
HttpResponse.json(associationsTable),
),

/** node lookup */
rest.get(regex(apiUrl, "/entity/.*"), (req, res, ctx) => {
http.get("*/entity/:id", ({ params }) => {
const id = String(params.id);

/**
* change fixture data based on request so we can see UI that is conditional
* on name/category/etc
*/
const id = req.url.pathname.match(/\/entity\/(.*)/)?.[1] || "";

const replace: {
[key: string]: { name?: string; category?: string };
} = {
Expand Down Expand Up @@ -139,20 +114,18 @@ export const handlers = [
if (name) node.name = name;
if (category) node.category = category;

return res(ctx.status(200), ctx.json(node));
return HttpResponse.json(node);
}),

/** node publication info */
rest.get(regex(esummary), (req, res, ctx) =>
res(ctx.status(200), ctx.json(nodePublicationSummary)),
),
rest.get(regex(efetch), (req, res, ctx) =>
res(ctx.status(200), ctx.json(nodePublicationAbstract.abstract)),
),
http.get(esummary, () => HttpResponse.json(nodePublicationSummary)),
http.get(efetch, () => HttpResponse.json(nodePublicationAbstract.abstract)),

/** any other request */
rest.get(/.*/, (req) => {
console.info("Non-mocked request", req.url.pathname);
return req.passthrough();
http.get("*", ({ request }) => {
const { pathname } = new URL(request.url);
if (!pathname.match(/\.[A-Za-z0-9]{2,5}$/))
console.warn("Non-mocked request", pathname);
return passthrough();
}),
];
Loading