-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2375 from HHS/main
[Prod] Post launch tweaks to training/session report
- Loading branch information
Showing
16 changed files
with
493 additions
and
57 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
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,158 @@ | ||
import React, { useState, useRef } from 'react'; | ||
import { | ||
ButtonGroup, | ||
Button, | ||
Form, | ||
FormGroup, | ||
Label, | ||
TextInput, | ||
} from '@trussworks/react-uswds'; | ||
import ContentFromFeedByTag from '../../components/ContentFromFeedByTag'; | ||
import Container from '../../components/Container'; | ||
import DrawerTriggerButton from '../../components/DrawerTriggerButton'; | ||
import Drawer from '../../components/Drawer'; | ||
|
||
export default function FeedPreview() { | ||
const [title, setTitle] = useState(''); | ||
const [tag, setTag] = useState(''); | ||
const [contentSelector, setContentSelector] = useState(''); | ||
const [cssClass, setCssClass] = useState(''); | ||
const drawerTriggerRef = useRef(null); | ||
|
||
const onSubmit = (e) => { | ||
e.preventDefault(); | ||
const data = new FormData(e.target); | ||
setTitle(data.get('title')); | ||
setTag(data.get('tag')); | ||
setContentSelector(data.get('contentSelector')); | ||
setCssClass(data.get('cssClass')); | ||
}; | ||
|
||
const onReset = () => { | ||
setTitle(''); | ||
setTag(''); | ||
setContentSelector(''); | ||
setCssClass(''); | ||
}; | ||
|
||
return ( | ||
<Container> | ||
<h1>Preview confluence RSS feed</h1> | ||
{' '} | ||
{tag && ( | ||
<> | ||
<DrawerTriggerButton | ||
drawerTriggerRef={drawerTriggerRef} | ||
> | ||
Preview drawer | ||
</DrawerTriggerButton> | ||
<Drawer | ||
triggerRef={drawerTriggerRef} | ||
stickyHeader | ||
stickyFooter | ||
title={title} | ||
> | ||
|
||
<ContentFromFeedByTag | ||
className={cssClass} | ||
tagName={tag} | ||
contentSelector={contentSelector} | ||
/> | ||
</Drawer> | ||
</> | ||
)} | ||
<Form onSubmit={onSubmit} className="margin-bottom-2"> | ||
<details> | ||
<summary> More info</summary> | ||
<p className="usa-prose"> | ||
The CSS class is used to style the feed preview by the engineers. | ||
The option to add it here is so that you can preview changes to existing feeds. | ||
(It won't do anything unless an engineer has already | ||
added corresponding styles.) | ||
</p> | ||
</details> | ||
<FormGroup> | ||
<Label htmlFor="title" required>Title</Label> | ||
<TextInput | ||
id="title" | ||
name="title" | ||
type="text" | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label htmlFor="tag" required>Tag</Label> | ||
<TextInput | ||
id="tag" | ||
name="tag" | ||
type="text" | ||
required | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label htmlFor="contentSelector">Content selector</Label> | ||
<TextInput | ||
id="contentSelector" | ||
name="contentSelector" | ||
type="text" | ||
/> | ||
</FormGroup> | ||
<FormGroup> | ||
<Label htmlFor="cssClass">CSS class</Label> | ||
<TextInput | ||
id="cssClass" | ||
name="cssClass" | ||
type="text" | ||
/> | ||
|
||
</FormGroup> | ||
<ButtonGroup> | ||
<Button type="submit">Save changes</Button> | ||
<Button type="reset" onClick={onReset} outline>Reset</Button> | ||
</ButtonGroup> | ||
</Form> | ||
|
||
<hr /> | ||
<table className="usa-table"> | ||
<caption> | ||
Existing drawer configuration | ||
</caption> | ||
<thead> | ||
<tr> | ||
<th>Drawer title</th> | ||
<th>Tag</th> | ||
<th>Content selector</th> | ||
<th>CSS class</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>Support type</td> | ||
<td>ttahub-tta-support-type</td> | ||
<td>table</td> | ||
<td>ttahub-drawer--objective-support-type-guidance</td> | ||
</tr> | ||
<tr> | ||
<td>Objective topics</td> | ||
<td>ttahub-topic</td> | ||
<td>table</td> | ||
<td>ttahub-drawer--objective-topics-guidance</td> | ||
</tr> | ||
<tr> | ||
<td>Class review first section</td> | ||
<td>ttahub-class-thresholds</td> | ||
<td>div:nth-child(3)</td> | ||
<td>ttahub-class-feed-article</td> | ||
</tr> | ||
<tr> | ||
<td>Class review second section</td> | ||
<td>ttahub-class-thresholds</td> | ||
<td>div:nth-child(4)</td> | ||
<td>ttahub-class-feed-article</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
</Container> | ||
); | ||
} |
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,51 @@ | ||
import '@testing-library/jest-dom'; | ||
import React from 'react'; | ||
import { | ||
render, screen, act, | ||
waitFor, | ||
} from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import fetchMock from 'fetch-mock'; | ||
import join from 'url-join'; | ||
import FeedPreview from '../FeedPreview'; | ||
import { mockRSSData } from '../../../testHelpers'; | ||
|
||
const tagUrl = join('/', 'api', 'feeds', 'item', '?tag=tag'); | ||
|
||
describe('FeedPreview', () => { | ||
const renderTest = () => { | ||
render(<FeedPreview />); | ||
}; | ||
|
||
afterEach(() => fetchMock.restore()); | ||
|
||
it('renders page and submits form', async () => { | ||
fetchMock.get(tagUrl, mockRSSData()); | ||
act(() => { | ||
renderTest(); | ||
}); | ||
|
||
userEvent.type(await screen.findByLabelText('Tag'), 'tag'); | ||
userEvent.type(await screen.findByLabelText('Title'), 'title'); | ||
userEvent.type(await screen.findByLabelText('Content selector'), 'contentSelector'); | ||
userEvent.type(await screen.findByLabelText('CSS class'), 'cssClass'); | ||
|
||
userEvent.click(await screen.findByRole('button', { name: 'Reset' })); | ||
|
||
expect(await screen.findByLabelText('Tag')).toHaveValue(''); | ||
expect(await screen.findByLabelText('Title')).toHaveValue(''); | ||
expect(await screen.findByLabelText('Content selector')).toHaveValue(''); | ||
expect(await screen.findByLabelText('CSS class')).toHaveValue(''); | ||
|
||
userEvent.type(await screen.findByLabelText('Tag'), 'tag'); | ||
userEvent.type(await screen.findByLabelText('Title'), 'title'); | ||
userEvent.type(await screen.findByLabelText('Content selector'), 'contentSelector'); | ||
userEvent.type(await screen.findByLabelText('CSS class'), 'cssClass'); | ||
|
||
act(() => { | ||
userEvent.click(screen.getByRole('button', { name: 'Save changes' })); | ||
}); | ||
|
||
await waitFor(() => expect(fetchMock.called(tagUrl)).toBe(true)); | ||
}); | ||
}); |
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
Oops, something went wrong.