-
Notifications
You must be signed in to change notification settings - Fork 4
[DT-1641] Implement the DUOS Data Library Card #2864
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
66897f5
feat: Implement the DUOS Data Library Card
PintoGideon bfcfeb1
feat: Remove unused props
PintoGideon 504a645
feat: Update anchor tags to Link components
PintoGideon c9dc3d4
refactor: Update the tooltip component
PintoGideon 5898b2f
feat: Write a test for the Home Page
PintoGideon 34a4f1f
feat: Add visual indication for data library access requiring login
PintoGideon d6ca5b1
feat: Update Tests
PintoGideon 1997e33
feat: Improve Data Library card navigation for unauthenticated users
PintoGideon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* eslint-disable no-undef */ | ||
import React from 'react'; | ||
import { mount } from 'cypress/react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import Home from '../../../src/pages/Home'; | ||
|
||
describe('Home Page - Tests', function() { | ||
describe('When user is not logged in', function() { | ||
beforeEach(() => { | ||
mount( | ||
<MemoryRouter> | ||
<Home isLogged={false} /> | ||
</MemoryRouter> | ||
); | ||
}); | ||
|
||
it('renders the page header correctly', function() { | ||
cy.contains('Data Use Oversight System').should('be.visible'); | ||
cy.contains('Expediting compliant data sharing').should('be.visible'); | ||
}); | ||
|
||
it('renders the Data Libraries section with consistent message', function() { | ||
cy.contains('Data Libraries in DUOS').should('be.visible'); | ||
cy.contains('Click the images below to view curated Data Libraries').should('be.visible'); | ||
}); | ||
|
||
it('displays tooltips with login required message for data libraries', function() { | ||
cy.get('[data-for="anvil"]').find('span[title="Please login to access AnVIL Data Library"]').should('exist'); | ||
cy.get('[data-for="broad"]').find('span[title="Please login to access Broad Institute Data Library"]').should('exist'); | ||
cy.get('[data-for="hca"]').find('span[title="Please login to access Human Cell Atlas Data Library"]').should('exist'); | ||
}); | ||
|
||
it('interacts with library card links when not logged in', function() { | ||
cy.get('.logo-card').should('have.length', 3); | ||
cy.get('.logo-card').each($card => { | ||
cy.wrap($card).find('a').should('exist'); | ||
}); | ||
|
||
// Create a spy on replaceState to check if URL parameters are updated | ||
cy.window().then((win) => { | ||
cy.spy(win.history, 'replaceState').as('replaceState'); | ||
}); | ||
|
||
// Stub document.querySelectorAll to simulate no sign-in button found (fallback case) | ||
cy.window().then((win) => { | ||
cy.stub(win.document, 'querySelectorAll').returns([]); | ||
}); | ||
|
||
// Also stub scrollTo for the fallback behavior | ||
cy.window().then((win) => { | ||
cy.stub(win, 'scrollTo').as('scrollTo'); | ||
}); | ||
|
||
cy.get('.logo-card').first().find('a').click({ force: true }); | ||
|
||
cy.get('@replaceState').should('be.called'); | ||
cy.get('@scrollTo').should('be.called'); | ||
|
||
// URL should contain the redirectTo parameter | ||
cy.location('search').should('include', 'redirectTo=%2Fdatalibrary%2Fanvil'); | ||
}); | ||
}); | ||
|
||
describe('When user is logged in', function() { | ||
beforeEach(() => { | ||
mount( | ||
<MemoryRouter> | ||
<Home isLogged={true} /> | ||
</MemoryRouter> | ||
); | ||
}); | ||
|
||
it('renders the page header correctly', function() { | ||
cy.contains('Data Use Oversight System').should('be.visible'); | ||
cy.contains('Expediting compliant data sharing').should('be.visible'); | ||
}); | ||
|
||
it('renders the Data Libraries section with clickable message', function() { | ||
cy.contains('Data Libraries in DUOS').should('be.visible'); | ||
cy.contains('Click the images below to view curated Data Libraries').should('be.visible'); | ||
}); | ||
|
||
it('displays tooltips with correct text for data libraries', function() { | ||
cy.get('[data-for="anvil"]').find('span[title="AnVIL"]').should('exist'); | ||
cy.get('[data-for="broad"]').find('span[title="Broad Institute"]').should('exist'); | ||
cy.get('[data-for="hca"]').find('span[title="Human Cell Atlas"]').should('exist'); | ||
}); | ||
|
||
it('has direct navigation links when logged in', function() { | ||
cy.get('a[href="/datalibrary/anvil"]').should('exist'); | ||
cy.get('a[href="/datalibrary/broad"]').should('exist'); | ||
cy.get('a[href="/datalibrary/HCA"]').should('exist'); | ||
}); | ||
|
||
it('navigates directly without calling handleSignIn when logged in', function() { | ||
cy.window().then((win) => { | ||
cy.spy(win.history, 'replaceState').as('replaceState'); | ||
}); | ||
cy.get('a[href="/datalibrary/anvil"]').click({ force: true }); | ||
cy.get('@replaceState').should('not.be.called'); | ||
}); | ||
|
||
it('displays logos horizontally on desktop', function() { | ||
cy.viewport(1200, 800); | ||
cy.get('.logo-grid').should('have.css', 'flex-direction', 'row'); | ||
cy.get('.logo-card').should('have.length', 3); | ||
}); | ||
|
||
it('displays logos vertically on mobile', function() { | ||
cy.viewport(600, 800); | ||
cy.get('.logo-grid').should('have.css', 'flex-direction', 'column'); | ||
cy.get('.logo-card').should('have.length', 3); | ||
}); | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.