Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tihuan committed Nov 30, 2023
1 parent 104e6f3 commit 8b39639
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions frontend/src/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum ROUTES {
SITEMAP = "/sitemap",
CELL_GUIDE = "/cellguide",
CELL_GUIDE_CELL_TYPE = "/cellguide/:cellTypeId",
CELL_GUIDE_TISSUE = "/cellguide/tissues/:tissueId",
CELL_GUIDE_TISSUE_SPECIFIC_CELL_TYPE = "/cellguide/tissues/:tissueId/cell-types/:cellTypeId",
DEPLOYED_VERSION = "/api/deployed_version",
}
71 changes: 71 additions & 0 deletions frontend/tests/features/cellGuide/cellGuide.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ const T_CELL_CELL_TYPE_ID = "CL_0000084";
const BRAIN_TISSUE_ID = "UBERON_0000955";
const LUNG_TISSUE_ID = "UBERON_0002048";
const ABNORMAL_CELL_TYPE_ID = "CL_0001061";
const BRAIN_VASCULAR_CELL_TYPE_ID = "CL_4023072";
const NATIVE_CELL_CELL_TYPE_ID = "CL_0000003";

describe("Cell Guide", () => {
describe("Landing Page", () => {
Expand Down Expand Up @@ -575,6 +577,74 @@ describe("Cell Guide", () => {
});

describe("Ontology Viewer", () => {
describe("Tissue specific cell type page", () => {
test("Clicks on a cell type node that has the same tissue in its dropdown in the ontology viewer navigates to the correct cell type page", async ({
page,
}) => {
await goToPage(
`${TEST_URL}${ROUTES.CELL_GUIDE_TISSUE.replace(
":tissueId",
BRAIN_TISSUE_ID
)}`,
page
);

await Promise.all([
page.waitForURL(
`${TEST_URL}${ROUTES.CELL_GUIDE_TISSUE_SPECIFIC_CELL_TYPE.replace(
":tissueId",
BRAIN_TISSUE_ID
).replace(":cellTypeId", BRAIN_VASCULAR_CELL_TYPE_ID)}`
),
page.getByText("brain vascular cell").click(),
]);

await tryUntil(
async () => {
const dropdownText = await page
.getByTestId(CELL_GUIDE_CARD_GLOBAL_TISSUE_FILTER_DROPDOWN)
.textContent();

expect(dropdownText).toBe("brain");
},
{ page }
);
});

test("Clicks on a cell type node that does NOT have the same tissue in its dropdown in the ontology viewer navigates to the generic cell type page", async ({
page,
}) => {
await goToPage(
`${TEST_URL}${ROUTES.CELL_GUIDE_TISSUE.replace(
":tissueId",
BRAIN_TISSUE_ID
)}`,
page
);

await Promise.all([
page.waitForURL(
`${TEST_URL}${ROUTES.CELL_GUIDE_CELL_TYPE.replace(
":cellTypeId",
NATIVE_CELL_CELL_TYPE_ID
)}`
),
page.getByText("native cell").click(),
]);

await tryUntil(
async () => {
const dropdownText = await page
.getByTestId(CELL_GUIDE_CARD_GLOBAL_TISSUE_FILTER_DROPDOWN)
.textContent();

expect(dropdownText).toBe("Tissue Agnostic");
},
{ page }
);
});
});

test("Clicking on a parent node expands and collapses its children", async ({
page,
}) => {
Expand Down Expand Up @@ -841,6 +911,7 @@ describe("Cell Guide", () => {
expect(newTooltipText).not.toContain(`${geneSymbol} stats`);
});
});

describe("Tissue Card", () => {
test("All tissue card components are present", async ({ page }) => {
await goToPage(
Expand Down

0 comments on commit 8b39639

Please sign in to comment.