-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Sites & Applications page (#220)
* PageNav component * Add abbreviated version of Logo * Add Header component * Style header * Add component tests * More tests * Footer component * Create layout for beta pages * Make layout mobile friendly * Move CSS fixes into beta layout * Add Search, styling * Fix Cypress test * Working on S&A page * Styling S&A * Add content, styling * Add tests * Add Cypress spec for Sites and Applications feature * Add mock Keystone API, fix test * Open Bookmark links in new window * Display external link icon on Bookmarks * Remove external link icon * Resolve linting errors * Up test coverage
- Loading branch information
Suzanne Rozier
authored
Sep 13, 2021
1 parent
85f4cad
commit b0bee3c
Showing
20 changed files
with
197 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ node_modules/ | |
out/ | ||
|
||
# Keystone output | ||
.keystone | ||
/.keystone | ||
|
||
# Storybook build output | ||
storybook-static | ||
|
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ node_modules/ | |
out/ | ||
|
||
# Keystone output | ||
.keystone | ||
/.keystone | ||
|
||
# Storybook build output | ||
storybook-static | ||
|
This file contains 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ node_modules/ | |
out/ | ||
|
||
# Keystone output | ||
.keystone | ||
/.keystone | ||
|
||
# Storybook build output | ||
storybook-static | ||
|
This file contains 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
This file contains 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,14 @@ | ||
describe('Sites and Applications', () => { | ||
beforeEach(() => { | ||
// Make sure the beta cookie is set | ||
cy.visit('/joinbeta') | ||
}) | ||
|
||
it('can visit the Sites & Applications page', () => { | ||
// Client-side navigate to the page | ||
cy.contains('All sites & applications').click() | ||
|
||
cy.url().should('eq', Cypress.config().baseUrl + '/sites-and-applications') | ||
cy.contains('Sites & Applications') | ||
}) | ||
}) |
This file contains 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
This file contains 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
This file contains 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,5 @@ | ||
export const lists = { | ||
Collection: { | ||
findMany: () => Promise.resolve([]), | ||
}, | ||
} |
This file contains 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,61 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { render, screen } from '@testing-library/react' | ||
import SitesAndApplications, { | ||
getStaticProps, | ||
} from 'pages/beta/sites-and-applications' | ||
|
||
const mockCollections = [ | ||
{ | ||
id: 1, | ||
title: 'Example Collection 1', | ||
bookmarks: [ | ||
{ | ||
id: 1, | ||
url: 'www.example.com', | ||
label: 'Example 1', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 2, | ||
title: 'Example Collection 2', | ||
bookmarks: [ | ||
{ | ||
id: 1, | ||
url: 'www.example.com', | ||
label: 'Example 1', | ||
}, | ||
{ | ||
id: 2, | ||
url: 'www.example2.com', | ||
label: 'Example 2', | ||
}, | ||
], | ||
}, | ||
] | ||
|
||
describe('Sites and Applications page', () => { | ||
it('renders Sites & Applications content', () => { | ||
render(<SitesAndApplications collections={mockCollections} />) | ||
|
||
expect( | ||
screen.getByRole('heading', { name: 'Sites & Applications' }) | ||
).toBeInTheDocument() | ||
|
||
const collections = screen.getAllByRole('heading', { level: 3 }) | ||
expect(collections).toHaveLength(mockCollections.length) | ||
collections.forEach((c, i) => { | ||
// eslint-disable-next-line security/detect-object-injection | ||
expect(collections[i]).toHaveTextContent(mockCollections[i].title) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('getStaticProps', () => { | ||
it('returns expected props', async () => { | ||
const results = await getStaticProps() | ||
expect(results).toEqual({ props: { collections: [] } }) | ||
}) | ||
}) |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,57 @@ | ||
import { InferGetStaticPropsType } from 'next' | ||
import { Grid } from '@trussworks/react-uswds' | ||
|
||
import { lists } from '.keystone/api' | ||
|
||
import { withBetaLayout } from 'layout/Beta/DefaultLayout/DefaultLayout' | ||
import Collection from 'components/Collection/Collection' | ||
import Bookmark from 'components/Bookmark/Bookmark' | ||
import styles from 'styles/pages/sitesAndApplications.module.scss' | ||
|
||
type Bookmark = { | ||
id: string | ||
url: string | ||
label?: string | ||
description?: string | ||
} | ||
|
||
const SitesAndApplications = ({ | ||
collections, | ||
}: InferGetStaticPropsType<typeof getStaticProps>) => { | ||
return ( | ||
<> | ||
<h2 className={styles.pageTitle}>Sites & Applications</h2> | ||
|
||
<div className={styles.widgetContainer}> | ||
<Grid row gap> | ||
{collections.map((collection) => ( | ||
<Grid | ||
key={`collection_${collection.id}`} | ||
tablet={{ col: 6 }} | ||
desktop={{ col: 3 }}> | ||
<Collection title={collection.title}> | ||
{collection.bookmarks.map((bookmark: Bookmark) => ( | ||
<Bookmark key={`bookmark_${bookmark.id}`} href={bookmark.url}> | ||
{bookmark.label} | ||
</Bookmark> | ||
))} | ||
</Collection> | ||
</Grid> | ||
))} | ||
</Grid> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default SitesAndApplications | ||
|
||
SitesAndApplications.getLayout = withBetaLayout | ||
|
||
export async function getStaticProps() { | ||
const collections = await lists.Collection.findMany({ | ||
query: 'id title bookmarks { id url label }', | ||
}) | ||
|
||
return { props: { collections } } | ||
} |
This file contains 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,12 @@ | ||
@import 'styles/uswdsDependencies'; | ||
|
||
.pageTitle { | ||
margin-top: 0; | ||
} | ||
|
||
.widgetContainer { | ||
border: 1px solid color('base-light'); | ||
border-radius: 4px; | ||
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.15); | ||
padding: units(4) units(4) units(6); | ||
} |
Empty file.