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

feat: 5673 cell guide tissue specific cell type route #6232

Merged
merged 3 commits into from
Dec 7, 2023

Conversation

tihuan
Copy link
Contributor

@tihuan tihuan commented Nov 15, 2023

Reason for Change

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
DO NOT MERGE UNTIL @ainfeld is back to help sort out analytics impact
UPDATE(12/1): @ainfeld has confirmed that no engineering changes for analytics changes
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

Changes

Behavior changes:

  1. On a cell type page, the tissue dropdown now navigates to tissue specific cell type page
  2. On a cell type page, the right cell type info panel's link now navigates to tissue specific cell type page
  3. On a tissue page, clicking on a cell type node now navigates to its tissue specific cell type page. HOWEVER, if the cell type page ends up not having the specific tissue in its tissue dropdown, we will redirect the page to its tissue agnostic equivalent

Code changes:

  1. Move tissueId from hook state to the route state
  2. Refactor: Extract hooks into connect.ts
  3. Add SEO snapshots for new tissue specific cell type pages
  4. Add isSuccess to hooks useAllOrgansLookupTables() and useOrganAndOrganismFilterListForCellType(), so we can do behavior change 3 above
  5. Add a new useEffect in connect.ts to redirect user to tissue agnostic cell type page, using isSuccess from the change right above
  6. Extract getCellTypeLink() utility function for all three places (dropdown, ontology viewer, and right side cell type info panel) that push user to cell type page to use
  7. Add e2e tests

Testing steps

Three behavior changes:

BEHAVIOR 1:

  1. Navigate to https://pr-6232-frontend.rdev.single-cell.czi.technology/cellguide/tissues/UBERON_0000955/cell-types/CL_0000540
  2. You should see Neuron Cell Page with Brain selected in the tissue dropdown
Screenshot 2023-11-16 at 9 14 49 AM

Video:

  1. Changing tissue changes the URL, which is a shareable URL by default
  2. Route change doesn't trigger a full page reload, which is more performant
  3. App state also changes accordingly to show tissue specific data when a tissue is selected
Screen.Recording.2023-11-16.at.9.38.40.AM.mov

BEHAVIOR 2:

  1. On a tissue page, clicking on a cell type node in ontology viewer should navigate you to its tissue specific cell type page

BEHAVIOR 3:

  1. On a tissue page, clicking on a cell type node in ontology viewer should navigate you to its tissue AGNOSTIC cell type page, IF the cell type page turns out not having such tissue in its tissue dropdown.

For example, on Brain tissue page, clicking on "cell" node should take you to the tissue agnostic "cell" page

Checklist 🛎️

  • Add product, design, and eng as reviewers for rdev review
  • For UI changes, add screenshots/videos, so the reviewers know what you expect them to see
  • For UI changes, add e2e tests to prevent regressions

Notes for Reviewer

Copy link
Contributor

Deployment Summary

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (04ca119) 91.96% compared to head (8083870) 91.96%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6232   +/-   ##
=======================================
  Coverage   91.96%   91.96%           
=======================================
  Files         178      178           
  Lines       14706    14706           
=======================================
  Hits        13524    13524           
  Misses       1182     1182           
Flag Coverage Δ
unittests 91.96% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch 6 times, most recently from c2b40cc to bcd9d8a Compare November 16, 2023 17:46
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new snapshot for tissue specific cell type page SEO

@@ -1,3 +1,11 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention is to use [cellTypeId].tsx to serve both CELL_GUIDE_CELL_TYPE and CELL_GUIDE_TISSUE_SPECIFIC_CELL_TYPE routes, so we have single source of truth and not duplicate code where possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracts out stuff to connect.ts

element: JSX.Element;
} | null>(null);

const { cellTypeId: queryCellTypeId, tissueId: queryTissueId } = router.query;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we get tissueId from the router now, I've removed the states that used to track selectedOrgan and selectedOrganId

const throttledHandleResize = useMemo(() => {
return throttle(handleResize, 100);
}, [handleResize]);
const handleChangeOrgan = (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleChangeOrgan() now just pushes the app to the new route!

const headerName = page.getByTestId(CELL_GUIDE_CARD_HEADER_NAME);
const headerNameText = await headerName.textContent();
expect(headerNameText).toBe("Neuron");
test("All tissue specific CellGuide card components are present", async ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test for tissue specific cell type page SEO description

const rowCountAfter = rowElementsAfter.length;
expect(rowCountAfter).toBeGreaterThan(1);
expect(rowCountAfter).not.toBe(rowCountBefore);
await tryUntil(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update test to avoid flakiness caused by table not yet loaded

const firstRowContentAfter =
await rowElementsAfter[0].textContent();
expect(firstRowContentBefore).not.toBe(firstRowContentAfter);
await tryUntil(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update test to avoid flakiness caused by table not yet loaded new data for specific tissue

* (thuang): Since the marker gene table is not stably sorted, we need
* to target a specific marker gene to prevent flakiness.
*/
const markerGeneNRXN1 = page.locator(`${tableSelector} tbody tr`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prevent flakiness caused by marker gene table not having a stable sort

const node = page.getByTestId(
`${CELL_GUIDE_CARD_ONTOLOGY_DAG_VIEW_RECT_OR_CIRCLE_PREFIX_ID}-CL:0000099__0-has-children-isTargetNode=false`
`${CELL_GUIDE_CARD_ONTOLOGY_DAG_VIEW_RECT_OR_CIRCLE_PREFIX_ID}-CL:0002319__0-has-children-isTargetNode=false`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neural cell works well with NRXN1 marker gene

@tihuan tihuan changed the title feat: 5673 cell guide tissue specific cell type route [DO NOT MERGE] feat: 5673 cell guide tissue specific cell type route Nov 16, 2023
Copy link
Contributor

@hthomas-czi hthomas-czi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tihuan The page should maintain scroll position when changing the tissue. Is that still possible? Otherwise looks good!

@tihuan
Copy link
Contributor Author

tihuan commented Nov 16, 2023

@tihuan The page should maintain scroll position when changing the tissue. Is that still possible? Otherwise looks good!

Oh yes! I wasn't sure if it was a bug or a feature to keep the scroll position, so went with the default navigation behavior 😆

Just updated the code to keep the scroll position. Rdev should be updated soon 🙆‍♂️

Thanks for the great feedback!

@tihuan
Copy link
Contributor Author

tihuan commented Nov 20, 2023

@atarashansky PTAL this PR for feature related implementation 🙏

I'm keeping this PR in draft until @ainfeld is back to collaborate on analytics changes

Thank you!

@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch 8 times, most recently from d489736 to 804ef34 Compare November 21, 2023 23:05
@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch 2 times, most recently from 8b39639 to 7d94c83 Compare November 30, 2023 20:29
@tihuan tihuan changed the title [DO NOT MERGE] feat: 5673 cell guide tissue specific cell type route feat: 5673 cell guide tissue specific cell type route Nov 30, 2023
@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch from 7d94c83 to c3f9873 Compare November 30, 2023 20:58
@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch 7 times, most recently from bd7afa9 to 5ed4f90 Compare December 1, 2023 16:08
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated snapshots for tissue specific cell type page SEO

Comment on lines +19 to +21
CELL_GUIDE_CELL_TYPE = "/cellguide/:cellTypeId",
CELL_GUIDE_TISSUE = "/cellguide/tissues/:tissueId",
CELL_GUIDE_TISSUE_SPECIFIC_CELL_TYPE = "/cellguide/tissues/:tissueId/cell-types/:cellTypeId",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add routes for easier way to have a consistent way to create URL and find places that navigate to the same route

@@ -60,27 +65,27 @@ function CellGuideInfoBar({
router.push(href);
}
track(EVENTS.CG_VIEW_CELLGUIDE_PAGE_CLICKED, {
cell_type: cellInfoCellType.cellTypeName,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and below - use destructuring to improve readability


const { cellTypeId, cellTypeName } = cellInfoCellType;

const cellTypeUrl = getCellTypeLink({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the new utility function to get cellTypeLink


interface AnimatedNodesProps {
tree: HierarchyPointNode<TreeNodeWithState>;
tissueId?: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this component needs tissueId now to construct cellTypeLink

Comment on lines -198 to -220
await isElementVisible(page, CELL_GUIDE_CARD_HEADER_NAME);
await isElementVisible(page, CELL_GUIDE_CARD_HEADER_TAG);
await isElementVisible(page, CELL_GUIDE_CARD_CL_DESCRIPTION);
await isElementVisible(page, CELL_GUIDE_CARD_GPT_DESCRIPTION);
await isElementVisible(page, CELL_GUIDE_CARD_SYNONYMS);
await isElementVisible(page, CELL_GUIDE_CARD_GPT_TOOLTIP_LINK);
await isElementVisible(page, CELL_GUIDE_CARD_SEARCH_BAR);
await isElementVisible(page, CELL_GUIDE_CARD_ENRICHED_GENES_TABLE);
await isElementVisible(page, CELL_GUIDE_CARD_ONTOLOGY_DAG_VIEW);
const headerName = page.getByTestId(CELL_GUIDE_CARD_HEADER_NAME);
const headerNameText = await headerName.textContent();
expect(headerNameText).toBe("Neuron");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted to assertAllCellCardComponentsArePresent() for reuse

@@ -554,6 +578,99 @@ 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 ({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add new tests to cover the behaviors where:

  1. On a tissue page, clicking on a cell type node should navigate to its tissue specific cell type page
  2. On a tissue page, clicking on a cell type node should navigate to its tissue agnostic page IF the cell type page turns out not having such tissue in the tissue dropdown

@tihuan tihuan force-pushed the thuang-5673-new-cell-guide-route branch from 5ed4f90 to fe41791 Compare December 1, 2023 16:18
@tihuan tihuan marked this pull request as ready for review December 1, 2023 16:31
Copy link
Contributor

@kaloster kaloster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid work @tihuan! Look good to me 🚀

@tihuan tihuan enabled auto-merge (squash) December 7, 2023 18:30
@tihuan
Copy link
Contributor Author

tihuan commented Dec 7, 2023

@kaloster Thanks for reviewing this!

@ainfeld sorry that this didn't go out this week, but it will get merged today and go out to prod next week for sure now. Thank you!

(I'm still on bereavement, just thought I'd get this merged 😆 Will be back 12/18. Thanks all!)

@tihuan tihuan merged commit 35b99a4 into main Dec 7, 2023
40 checks passed
@tihuan tihuan deleted the thuang-5673-new-cell-guide-route branch December 7, 2023 18:55
@ainfeld
Copy link
Contributor

ainfeld commented Dec 7, 2023

thanks @tihuan!! no worries about when it actually goes to prod, doesn't really matter to me haha just useful to know when it's expected so I can plan the work I need to do after it. This gives me lots of time to play around with it in staging to understand what I need to change for analytics so really really appreciate that 🙏

@tihuan
Copy link
Contributor Author

tihuan commented Dec 7, 2023

Ahaha awesome! Glad some extra time in staging is useful this time 🎉 Thanks again, @ainfeld 😄 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants