Skip to content

Commit 26eeab7

Browse files
[CUTL-90] ☔️ (Base) Major testing overhaul - convert and improve Cypress specs for all pages; Updates for enforcing code coverage (50%); Skip coverage for pages
Note: We still need to configure coverage for pages - this should bring our numbers up quite a bit
1 parent 3eefce1 commit 26eeab7

File tree

96 files changed

+634
-1887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+634
-1887
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ coverage
66
build
77
stats.json
88
npm-debug.log
9+
.nyc_output/*
910

1011
# Mac meta file
1112
.DS_Store

app/components/AutoSaveFormField/AutoSaveFormField.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,21 @@ const AutoSaveFormField = ({ onSave, name, value, ...rest }) => {
4040
if (success)
4141
return (
4242
<Box animation={{ type: 'fadeIn', delay: 0, duration: 200 }} width="60px">
43-
<StatusGood color="status-ok" style={{ marginLeft: 10, marginBottom: 22 }} />
43+
<StatusGood
44+
data-testid={`success-${name}`}
45+
color="status-ok"
46+
style={{ marginLeft: 10, marginBottom: 22 }}
47+
/>
4448
</Box>
4549
)
4650
if (error)
4751
return (
4852
<Box animation={{ type: 'fadeIn', delay: 0, duration: 200 }} width="60px">
49-
<StatusCritical color="status-error" style={{ marginLeft: 10, marginBottom: 58 }} />
53+
<StatusCritical
54+
data-testid={`error-${name}`}
55+
color="status-error"
56+
style={{ marginLeft: 10, marginBottom: 58 }}
57+
/>
5058
</Box>
5159
)
5260
return <Box width="60px" />

app/components/Box/stories/Box.Round.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
22
import { storiesOf } from '@storybook/react'
3-
import { Grid } from 'grommet' /** @todo: replace with custom wrappers */
43

54
// Components
65
import { Box } from '..'
6+
import { Grid } from '../../Grid'
77
import { StoryContainer } from '../../StoryContainer'
88

99
// Misc

app/components/Button/stories/Button.Plain.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
22
import { storiesOf } from '@storybook/react'
3-
import { Text } from 'grommet' /** @todo: replace with custom wrappers */
43
import { Add } from 'grommet-icons'
54

65
// Components
76
import { Box } from '../../Box'
87
import { Button } from '..'
98
import { StoryContainer } from '../../StoryContainer'
9+
import { Text } from '../../Text'
1010

1111
// Misc
1212
import README from '../README.md'

app/components/Button/stories/Button.Sidebar.stories.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useState } from 'react'
22
import { storiesOf } from '@storybook/react'
3-
import { grommet, Text } from 'grommet' /** @todo: replace with custom wrappers */
43

54
// Components
65
import { Box } from '../../Box'
76
import { Button } from '..'
87
import { StoryContainer } from '../../StoryContainer'
8+
import { Text } from '../../Text'
99

1010
// Utils
1111
import { genericProps } from '../../../utils/propTypes'
@@ -33,7 +33,7 @@ SidebarButton.propTypes = {
3333
const SidebarButtons = () => {
3434
const [active, setActive] = useState()
3535
return (
36-
<StoryContainer full theme={grommet}>
36+
<StoryContainer full>
3737
<Box fill direction="row">
3838
<Box background="neutral-1">
3939
{['Dashboard', 'Devices', 'Settings'].map(label => (

app/components/PasswordInput/PasswordInput.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TextInput } from '../TextInput'
1010
*
1111
* PasswordInput
1212
*
13-
* Displays a textinput with masked value for password
13+
* Displays a text input with masked value for password
1414
*
1515
* - When FormView Icon is clicked, it reveals the password
1616
* - When HIde Icon is clicked, it masks the password
@@ -34,12 +34,18 @@ const PasswordInput = ({ value, onChange = () => {}, type, ...rest }) => {
3434
/>
3535

3636
<Button
37+
data-testid="show-password-toggle"
3738
primary={false}
3839
icon={
3940
reveal ? (
40-
<FormView size="medium" style={{ width: 30 }} color="light-5" />
41+
<FormView
42+
data-testid="shown-icon"
43+
size="medium"
44+
style={{ width: 30 }}
45+
color="light-5"
46+
/>
4147
) : (
42-
<Hide size="medium" style={{ width: 30 }} color="light-5" />
48+
<Hide data-testid="hidden-icon" size="medium" style={{ width: 30 }} color="light-5" />
4349
)
4450
}
4551
onClick={() => setReveal(!reveal)}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import React from 'react'
2-
import { render } from '@testing-library/react'
2+
import { fireEvent, render } from '@testing-library/react'
33

44
import PasswordInput from './PasswordInput'
55

66
const renderComponent = (props = {}) => render(<PasswordInput {...props} />)
77

8-
test('it renders and matches snapshot', () => {
9-
const { container } = renderComponent()
10-
expect(container).toMatchSnapshot()
8+
describe('PasswordInput', () => {
9+
it('renders and matches snapshot', () => {
10+
const { container } = renderComponent()
11+
12+
expect(container).toMatchSnapshot()
13+
})
14+
15+
it('toggles between shown and hidden', () => {
16+
const { getByTestId } = renderComponent()
17+
18+
getByTestId('hidden-icon')
19+
20+
fireEvent.click(getByTestId('show-password-toggle'))
21+
22+
getByTestId('shown-icon')
23+
24+
fireEvent.click(getByTestId('show-password-toggle'))
25+
26+
getByTestId('hidden-icon')
27+
})
1128
})

app/components/PasswordInput/__snapshots__/PasswordInput.test.js.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`it renders and matches snapshot 1`] = `
3+
exports[`PasswordInput renders and matches snapshot 1`] = `
44
<div>
55
<div
66
class="StyledBox-sc-13pk1d4-0 bUEJOH"
@@ -17,11 +17,13 @@ exports[`it renders and matches snapshot 1`] = `
1717
</div>
1818
<button
1919
class="StyledButton-sc-323bzc-0 tdSht Button__StyledGrommetButton-sc-5cxguj-0 liIZVq"
20+
data-testid="show-password-toggle"
2021
type="button"
2122
>
2223
<svg
2324
aria-label="Hide"
2425
class="StyledIcon-ofa7kd-0 jIkYfD"
26+
data-testid="hidden-icon"
2527
style="width: 30px;"
2628
viewBox="0 0 24 24"
2729
>

app/components/PublicRoute/__snapshots__/PublicRoute.test.js.snap

+2
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,13 @@ exports[`<PublicRoute /> renders Login if user is not authenticated 1`] = `
127127
</div>
128128
<button
129129
class="StyledButton-sc-323bzc-0 tdSht Button__StyledGrommetButton-sc-5cxguj-0 liIZVq"
130+
data-testid="show-password-toggle"
130131
type="button"
131132
>
132133
<svg
133134
aria-label="Hide"
134135
class="StyledIcon-ofa7kd-0 dWXdkj"
136+
data-testid="hidden-icon"
135137
style="width: 30px;"
136138
viewBox="0 0 24 24"
137139
>

app/pages/ConfirmAccount/tests/ConfirmAccount.test.js

-21
This file was deleted.

app/pages/ConfirmAccount/tests/__snapshots__/ConfirmAccount.test.js.snap

-44
This file was deleted.

app/pages/Dashboard/tests/Dashboard.test.js

-25
This file was deleted.

app/pages/Dashboard/tests/__snapshots__/Dashboard.test.js.snap

-21
This file was deleted.

0 commit comments

Comments
 (0)