@openneuro/app 4.2.2 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/jestsetup.ts +0 -5
  2. package/package.json +7 -13
  3. package/src/scripts/common/forms/__tests__/__snapshots__/warn-button.spec.jsx.snap +26 -26
  4. package/src/scripts/common/forms/__tests__/warn-button.spec.jsx +7 -5
  5. package/src/scripts/datalad/subscriptions/__tests__/__snapshots__/files-subscription.spec.jsx.snap +1 -159
  6. package/src/scripts/datalad/subscriptions/__tests__/files-subscription.spec.jsx +6 -3
  7. package/src/scripts/errors/errorRoute.jsx +4 -23
  8. package/src/scripts/faq/__tests__/__snapshots__/faq.spec.jsx.snap +183 -154
  9. package/src/scripts/faq/__tests__/faq.spec.jsx +3 -3
  10. package/src/scripts/refactor_2021/admin/admin.jsx +1 -7
  11. package/src/scripts/refactor_2021/dataset/comments/__tests__/__snapshots__/comments.spec.jsx.snap +12 -110
  12. package/src/scripts/refactor_2021/dataset/comments/__tests__/comments.spec.jsx +7 -5
  13. package/src/scripts/refactor_2021/dataset/dataset-routes.jsx +0 -11
  14. package/src/scripts/refactor_2021/dataset/download/__tests__/__snapshots__/download-command-line.spec.jsx.snap +8 -9
  15. package/src/scripts/refactor_2021/dataset/download/__tests__/__snapshots__/download-link.spec.jsx.snap +46 -1255
  16. package/src/scripts/refactor_2021/dataset/download/__tests__/__snapshots__/shell-example.spec.jsx.snap +3 -4
  17. package/src/scripts/refactor_2021/dataset/download/__tests__/download-command-line.spec.jsx +10 -11
  18. package/src/scripts/refactor_2021/dataset/download/__tests__/download-link.spec.jsx +3 -3
  19. package/src/scripts/refactor_2021/dataset/download/__tests__/shell-example.spec.jsx +3 -3
  20. package/src/scripts/refactor_2021/dataset/download/download-command-line.jsx +1 -1
  21. package/src/scripts/refactor_2021/dataset/draft-container.tsx +15 -9
  22. package/src/scripts/refactor_2021/dataset/draft-snapshot-routes.tsx +1 -6
  23. package/src/scripts/refactor_2021/dataset/files/__tests__/__snapshots__/file-tree.spec.jsx.snap +24 -49
  24. package/src/scripts/refactor_2021/dataset/files/__tests__/__snapshots__/file.spec.jsx.snap +74 -54
  25. package/src/scripts/refactor_2021/dataset/files/__tests__/file-tree-unloaded-directory.spec.jsx +4 -3
  26. package/src/scripts/refactor_2021/dataset/files/__tests__/file-tree.spec.jsx +23 -19
  27. package/src/scripts/refactor_2021/dataset/files/__tests__/file-viewer-type.spec.jsx +5 -3
  28. package/src/scripts/refactor_2021/dataset/files/__tests__/file.spec.jsx +21 -21
  29. package/src/scripts/refactor_2021/dataset/files/file.jsx +3 -2
  30. package/src/scripts/refactor_2021/dataset/files/viewers/__tests__/__snapshots__/file-viewer-json.spec.jsx.snap +85 -60
  31. package/src/scripts/refactor_2021/dataset/files/viewers/__tests__/file-viewer-json.spec.jsx +5 -5
  32. package/src/scripts/refactor_2021/dataset/fragments/__tests__/__snapshots__/cancel-button.spec.tsx.snap +14 -6
  33. package/src/scripts/refactor_2021/dataset/fragments/__tests__/__snapshots__/edit-button.spec.tsx.snap +14 -6
  34. package/src/scripts/refactor_2021/dataset/fragments/__tests__/__snapshots__/save-button.spec.tsx.snap +14 -6
  35. package/src/scripts/refactor_2021/dataset/fragments/__tests__/__snapshots__/select-input.spec.tsx.snap +178 -105
  36. package/src/scripts/refactor_2021/dataset/fragments/__tests__/cancel-button.spec.tsx +3 -3
  37. package/src/scripts/refactor_2021/dataset/fragments/__tests__/edit-button.spec.tsx +3 -3
  38. package/src/scripts/refactor_2021/dataset/fragments/__tests__/edit-list.spec.jsx +0 -1
  39. package/src/scripts/refactor_2021/dataset/fragments/__tests__/save-button.spec.tsx +3 -3
  40. package/src/scripts/refactor_2021/dataset/fragments/__tests__/select-input.spec.tsx +9 -9
  41. package/src/scripts/refactor_2021/dataset/fragments/select-input.tsx +1 -1
  42. package/src/scripts/refactor_2021/dataset/mutations/__tests__/__snapshots__/description.spec.jsx.snap +3 -277
  43. package/src/scripts/refactor_2021/dataset/mutations/__tests__/description.spec.jsx +22 -9
  44. package/src/scripts/refactor_2021/dataset/mutations/update-file.jsx +15 -19
  45. package/src/scripts/refactor_2021/dataset/routes/__tests__/__snapshots__/publish.spec.jsx.snap +3 -0
  46. package/src/scripts/refactor_2021/dataset/routes/__tests__/publish.spec.jsx +13 -0
  47. package/src/scripts/refactor_2021/dataset/snapshot-container.tsx +4 -8
  48. package/src/scripts/refactor_2021/routes.tsx +9 -9
  49. package/src/scripts/refactor_2021/uploader/uploader-setup-routes.jsx +4 -24
  50. package/src/scripts/refactor_2021/uploader/uploader-status-routes.jsx +1 -6
  51. package/src/scripts/common/forms/__tests__/__snapshots__/input.spec.jsx.snap +0 -13
  52. package/src/scripts/common/forms/__tests__/input.spec.jsx +0 -25
  53. package/src/scripts/common/forms/input.jsx +0 -98
  54. package/src/scripts/datalad/routes/__tests__/__snapshots__/publish.spec.jsx.snap +0 -14
  55. package/src/scripts/datalad/routes/__tests__/publish.spec.jsx +0 -10
  56. package/src/scripts/datalad/routes/mobile-class.tsx +0 -16
  57. package/src/scripts/datalad/routes/publish.jsx +0 -50
@@ -1,10 +1,9 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`dataset/download/ShellExample renders successfully 1`] = `
4
- <Fragment>
5
- <Noop />
4
+ <DocumentFragment>
6
5
  <pre
7
- className="css-xak41w"
6
+ class="css-xak41w"
8
7
  />
9
- </Fragment>
8
+ </DocumentFragment>
10
9
  `;
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render, screen } from '@testing-library/react'
3
+ import '@testing-library/jest-dom/extend-expect'
3
4
  import { DownloadSampleCommand } from '../download-command-line.jsx'
4
5
 
5
6
  const defProps = { datasetId: 'ds000001' }
@@ -7,20 +8,18 @@ const defProps = { datasetId: 'ds000001' }
7
8
  describe('dataset/download', () => {
8
9
  describe('DownloadSampleCommand component', () => {
9
10
  it('renders successfully', () => {
10
- const wrapper = shallow(<DownloadSampleCommand {...defProps} />)
11
- expect(wrapper).toMatchSnapshot()
11
+ const { asFragment } = render(<DownloadSampleCommand {...defProps} />)
12
+ expect(asFragment()).toMatchSnapshot()
12
13
  })
13
14
  it('drafts show draft flag', () => {
14
- const wrapper = shallow(<DownloadSampleCommand {...defProps} />)
15
- expect(wrapper.text()).toEqual(expect.stringContaining('--draft'))
16
- expect(wrapper.text()).toEqual(expect.not.stringContaining('--snapshot'))
15
+ render(<DownloadSampleCommand {...defProps} />)
16
+ expect(screen.getByRole('figure')).toHaveTextContent('--draft')
17
+ expect(screen.queryByText('--snapshot')).not.toBeInTheDocument()
17
18
  })
18
19
  it('snapshots show snapshot flag', () => {
19
- const wrapper = shallow(
20
- <DownloadSampleCommand {...defProps} snapshotTag="1.0.0" />,
21
- )
22
- expect(wrapper.text()).toEqual(expect.stringContaining('--snapshot'))
23
- expect(wrapper.text()).toEqual(expect.not.stringContaining('--draft'))
20
+ render(<DownloadSampleCommand {...defProps} snapshotTag="1.0.0" />)
21
+ expect(screen.getByRole('figure')).toHaveTextContent('--snapshot')
22
+ expect(screen.queryByText('--draft')).not.toBeInTheDocument()
24
23
  })
25
24
  })
26
25
  })
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render } from '@testing-library/react'
3
3
  import DownloadLink from '../download-link.jsx'
4
4
  import { MockedProvider } from '@apollo/client/testing'
5
5
  const defProps = {
@@ -9,11 +9,11 @@ const defProps = {
9
9
 
10
10
  describe('dataset/download/DownloadLink', () => {
11
11
  it('renders successfully', () => {
12
- const wrapper = shallow(
12
+ const { asFragment } = render(
13
13
  <MockedProvider>
14
14
  <DownloadLink {...defProps} />
15
15
  </MockedProvider>,
16
16
  )
17
- expect(wrapper).toMatchSnapshot()
17
+ expect(asFragment()).toMatchSnapshot()
18
18
  })
19
19
  })
@@ -1,10 +1,10 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render } from '@testing-library/react'
3
3
  import ShellExample from '../shell-example.jsx'
4
4
 
5
5
  describe('dataset/download/ShellExample', () => {
6
6
  it('renders successfully', () => {
7
- const wrapper = shallow(<ShellExample />)
8
- expect(wrapper).toMatchSnapshot()
7
+ const { asFragment } = render(<ShellExample />)
8
+ expect(asFragment()).toMatchSnapshot()
9
9
  })
10
10
  })
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
3
3
  import ShellExample from './shell-example.jsx'
4
4
 
5
5
  export const DownloadSampleCommand = ({ datasetId, snapshotTag }) => (
6
- <ShellExample>
6
+ <ShellExample role="figure">
7
7
  openneuro download {snapshotTag ? `--snapshot ${snapshotTag}` : '--draft'}{' '}
8
8
  {datasetId} {datasetId}
9
9
  -download/
@@ -194,14 +194,20 @@ const DraftContainer: React.FC<DraftContainerProps> = ({ dataset }) => {
194
194
  />
195
195
  )}
196
196
  renderFiles={() => (
197
- <Files
198
- datasetId={datasetId}
199
- snapshotTag={null}
200
- datasetName={dataset.draft.description.Name}
201
- files={dataset.draft.files}
202
- editMode={hasEdit}
203
- datasetPermissions={dataset.permissions}
204
- />
197
+ <ReadMore
198
+ fileTree={true}
199
+ id="collapse-tree"
200
+ expandLabel="Expand File Tree"
201
+ collapseLabel="Collapse File Tree">
202
+ <Files
203
+ datasetId={datasetId}
204
+ snapshotTag={null}
205
+ datasetName={dataset.draft.description.Name}
206
+ files={dataset.draft.files}
207
+ editMode={hasEdit}
208
+ datasetPermissions={dataset.permissions}
209
+ />
210
+ </ReadMore>
205
211
  )}
206
212
  renderReadMe={() => (
207
213
  <MetaDataBlock
@@ -218,7 +224,7 @@ const DraftContainer: React.FC<DraftContainerProps> = ({ dataset }) => {
218
224
  <ReadMore
219
225
  id="readme"
220
226
  expandLabel="Read More"
221
- collapseabel="Collapse">
227
+ collapseLabel="Collapse">
222
228
  <Markdown>{dataset.draft.readme || 'N/A'}</Markdown>
223
229
  </ReadMore>
224
230
  </EditDescriptionField>
@@ -6,15 +6,10 @@ const Dataset = () => {
6
6
  return (
7
7
  <Switch>
8
8
  <Route
9
- name="datalad-snapshot"
10
9
  path="/datasets/:datasetId/versions/:snapshotId"
11
10
  component={DatasetQuery}
12
11
  />
13
- <Route
14
- name="datalad-dataset"
15
- path="/datasets/:datasetId/"
16
- component={DatasetQuery}
17
- />
12
+ <Route path="/datasets/:datasetId/" component={DatasetQuery} />
18
13
  </Switch>
19
14
  )
20
15
  }
@@ -1,59 +1,34 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`FileTree component renders with default props 1`] = `
4
- <FileTree>
5
- <AccordionTab
6
- accordionStyle="file-tree"
7
- className=""
8
- label=""
9
- startOpen={false}
4
+ <DocumentFragment>
5
+ <article
6
+ class="file-tree accordion "
10
7
  >
11
- <article
12
- className="file-tree accordion "
8
+ <div
9
+ class="accordion-title "
13
10
  >
14
- <div
15
- className="accordion-title "
16
- onClick={[Function]}
11
+ <span
12
+ aria-label=""
13
+ class="file-icon on-icon "
14
+ role="img"
17
15
  >
18
- <Icon
19
- className="file-icon"
20
- icon="fas fa-folder"
21
- label=""
22
- >
23
- <span
24
- aria-label=""
25
- className="file-icon on-icon "
26
- role="img"
27
- style={
28
- Object {
29
- "backgroundColor": undefined,
30
- "color": undefined,
31
- }
32
- }
33
- >
34
- <i
35
- className="fas fa-folder"
36
- style={
37
- Object {
38
- "fontSize": undefined,
39
- }
40
- }
41
- />
42
- </span>
43
- </Icon>
44
- </div>
16
+ <i
17
+ class="fas fa-folder"
18
+ />
19
+ </span>
20
+ </div>
21
+ <div
22
+ class="accordion-item collapsed "
23
+ >
45
24
  <div
46
- className="accordion-item collapsed "
25
+ class="accordion-content"
47
26
  >
48
- <div
49
- className="accordion-content"
50
- >
51
- <ul
52
- className="child-files"
53
- />
54
- </div>
27
+ <ul
28
+ class="child-files"
29
+ />
55
30
  </div>
56
- </article>
57
- </AccordionTab>
58
- </FileTree>
31
+ </div>
32
+ </article>
33
+ </DocumentFragment>
59
34
  `;
@@ -1,103 +1,123 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`File component renders for dataset snapshots 1`] = `
4
- <Fragment>
5
- <Icon
6
- color="deepskyblue"
7
- icon="fab fa-markdown"
8
- />
9
-   
10
- README
4
+ <DocumentFragment>
11
5
  <span
12
- className="filetree-editfile"
6
+ aria-label=""
7
+ class=" on-icon "
8
+ role="img"
9
+ style="color: deepskyblue;"
13
10
  >
14
- <Media
15
- className=""
16
- greaterThanOrEqual="medium"
11
+ <i
12
+ class="fab fa-markdown"
13
+ />
14
+ </span>
15
+   README
16
+ <span
17
+ class="filetree-editfile"
18
+ >
19
+ <div
20
+ class="fresnel-container fresnel-greaterThanOrEqual-medium "
17
21
  >
18
- <Tooltip
19
- tooltip="Download"
22
+ <span
23
+ class=" "
24
+ data-flow="up"
25
+ data-tooltip="Download"
20
26
  >
21
27
  <span
22
- className="edit-file download-file"
28
+ class="edit-file download-file"
23
29
  >
24
30
  <a
25
- download={true}
31
+ aria-label="download file"
32
+ download=""
26
33
  href="/crn/datasets/ds001/snapshots/1.0.0/files/README"
27
34
  >
28
35
  <i
29
- className="fa fa-download"
36
+ class="fa fa-download"
30
37
  />
31
38
  </a>
32
39
  </span>
33
- </Tooltip>
34
- </Media>
35
- <Tooltip
36
- tooltip="View"
40
+ </span>
41
+ </div>
42
+ <span
43
+ class=" "
44
+ data-flow="up"
45
+ data-tooltip="View"
37
46
  >
38
47
  <span
39
- className="edit-file view-file"
48
+ class="edit-file view-file"
40
49
  >
41
- <Link
42
- to="/datasets/ds001/versions/1.0.0/file-display/README"
50
+ <a
51
+ aria-label="view file"
52
+ href="/datasets/ds001/versions/1.0.0/file-display/README"
43
53
  >
44
54
  <i
45
- className="fa fa-eye"
55
+ class="fa fa-eye"
46
56
  />
47
- </Link>
57
+ </a>
48
58
  </span>
49
- </Tooltip>
59
+ </span>
50
60
  </span>
51
- </Fragment>
61
+ </DocumentFragment>
52
62
  `;
53
63
 
54
64
  exports[`File component renders with common props 1`] = `
55
- <Fragment>
56
- <Icon
57
- color="deepskyblue"
58
- icon="fab fa-markdown"
59
- />
60
-   
61
- README
65
+ <DocumentFragment>
62
66
  <span
63
- className="filetree-editfile"
67
+ aria-label=""
68
+ class=" on-icon "
69
+ role="img"
70
+ style="color: deepskyblue;"
64
71
  >
65
- <Media
66
- className=""
67
- greaterThanOrEqual="medium"
72
+ <i
73
+ class="fab fa-markdown"
74
+ />
75
+ </span>
76
+   README
77
+ <span
78
+ class="filetree-editfile"
79
+ >
80
+ <div
81
+ class="fresnel-container fresnel-greaterThanOrEqual-medium "
68
82
  >
69
- <Tooltip
70
- tooltip="Download"
83
+ <span
84
+ class=" "
85
+ data-flow="up"
86
+ data-tooltip="Download"
71
87
  >
72
88
  <span
73
- className="edit-file download-file"
89
+ class="edit-file download-file"
74
90
  >
75
91
  <a
76
- download={true}
92
+ aria-label="download file"
93
+ download=""
77
94
  href="/crn/datasets/ds001/files/README"
78
95
  >
79
96
  <i
80
- className="fa fa-download"
97
+ class="fa fa-download"
81
98
  />
82
99
  </a>
83
100
  </span>
84
- </Tooltip>
85
- </Media>
86
- <Tooltip
87
- tooltip="View"
101
+ </span>
102
+ </div>
103
+ <span
104
+ class=" "
105
+ data-flow="up"
106
+ data-tooltip="View"
88
107
  >
89
108
  <span
90
- className="edit-file view-file"
109
+ class="edit-file view-file"
91
110
  >
92
- <Link
93
- to="/datasets/ds001/file-display/README"
111
+ <a
112
+ aria-label="view file"
113
+ href="/datasets/ds001/file-display/README"
94
114
  >
95
115
  <i
96
- className="fa fa-eye"
116
+ class="fa fa-eye"
97
117
  />
98
- </Link>
118
+ </a>
99
119
  </span>
100
- </Tooltip>
120
+ </span>
101
121
  </span>
102
- </Fragment>
122
+ </DocumentFragment>
103
123
  `;
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { mount } from 'enzyme'
2
+ import { render, screen, fireEvent } from '@testing-library/react'
3
3
  import DatasetQueryContext from '../../../../datalad/dataset/dataset-query-context.js'
4
4
  import FileTreeUnloadedDirectory, {
5
5
  mergeNewFiles,
@@ -12,12 +12,13 @@ const dir = {
12
12
  describe('FileTreeUnloadedDirectory component', () => {
13
13
  it('calls fetchMoreDirectory when clicked', () => {
14
14
  const fetchMore = jest.fn()
15
- const wrapper = mount(
15
+ render(
16
16
  <DatasetQueryContext.Provider value={{ fetchMore }}>
17
17
  <FileTreeUnloadedDirectory datasetId={'ds000001'} directory={dir} />
18
18
  </DatasetQueryContext.Provider>,
19
19
  )
20
- wrapper.find('div.accordion-title').simulate('click')
20
+ // Label is filename
21
+ fireEvent.click(screen.getByLabelText(dir.filename))
21
22
  expect(fetchMore).toHaveBeenCalled()
22
23
  })
23
24
  describe('mergeNewFiles', () => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
- import { mount } from 'enzyme'
3
- import { ApolloProvider } from '@apollo/client'
2
+ import { render, screen, fireEvent } from '@testing-library/react'
3
+ import { MockedProvider } from '@apollo/client/testing'
4
4
  import FileTree, {
5
5
  sortByFilename,
6
6
  sortByName,
@@ -30,27 +30,31 @@ jest.mock('react-spring', () => ({
30
30
 
31
31
  describe('FileTree component', () => {
32
32
  it('renders with default props', () => {
33
- expect(mount(<FileTree />)).toMatchSnapshot()
33
+ const { asFragment } = render(<FileTree />)
34
+ expect(asFragment()).toMatchSnapshot()
34
35
  })
35
36
  it('expands and closes when clicked', () => {
36
- // ApolloProvider isn't used in this test but must exist
37
- // When enzyme supports hooks, this can be simplified
38
- const wrapper = mount(
39
- <ApolloProvider client={{}}>
37
+ render(
38
+ <MockedProvider>
40
39
  <FileTree name="Top Level" />
41
- </ApolloProvider>,
40
+ </MockedProvider>,
41
+ )
42
+ // Test the folder icon is closed
43
+ expect(screen.getByLabelText('Top Level').firstChild).toHaveClass(
44
+ 'fa-folder',
45
+ )
46
+ expect(screen.getByLabelText('Top Level').firstChild).not.toHaveClass(
47
+ 'fa-folder-open',
48
+ )
49
+ // Click it
50
+ fireEvent.click(screen.getByLabelText('Top Level'))
51
+ // Test that it is now open
52
+ expect(screen.getByLabelText('Top Level').firstChild).toHaveClass(
53
+ 'fa-folder-open',
54
+ )
55
+ expect(screen.getByLabelText('Top Level').firstChild).not.toHaveClass(
56
+ 'fa-folder',
42
57
  )
43
- expect(
44
- wrapper.find('div.accordion-title i').hasClass('fa-folder-open'),
45
- ).toBe(false)
46
- wrapper.find('div.accordion-title').simulate('click')
47
- expect(
48
- wrapper.find('div.accordion-title i').hasClass('fa-folder-open'),
49
- ).toBe(true)
50
- wrapper.find('div.accordion-title').simulate('click')
51
- expect(
52
- wrapper.find('div.accordion-title i').hasClass('fa-folder-open'),
53
- ).toBe(false)
54
58
  })
55
59
  describe('sortByFilename()', () => {
56
60
  it('sorts the expected filename properties', () => {
@@ -1,15 +1,17 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render, screen } from '@testing-library/react'
3
3
  import FileViewerType from '../file-viewer-type.jsx'
4
4
 
5
5
  describe('FileViewerType component', () => {
6
6
  it('displays a fallback when an unknown file is specified', () => {
7
- const wrapper = shallow(
7
+ const component = render(
8
8
  <FileViewerType
9
9
  path="unknown-file-extension.xyz"
10
10
  data={new ArrayBuffer(128)}
11
11
  />,
12
12
  )
13
- expect(wrapper.at(0).hasClass('file-viewer-fallback')).toBe(true)
13
+ expect(
14
+ screen.getByText(/this file must be downloaded to view it/i),
15
+ ).toHaveClass('file-viewer-fallback')
14
16
  })
15
17
  })
@@ -1,43 +1,43 @@
1
1
  import React from 'react'
2
- import { shallow } from 'enzyme'
2
+ import { render, screen } from '@testing-library/react'
3
+ import { MemoryRouter } from 'react-router-dom'
3
4
  import File from '../file.jsx'
4
- import { CookiesProvider, Cookies } from 'react-cookie'
5
5
 
6
6
  describe('File component', () => {
7
7
  it('renders with common props', () => {
8
- expect(
9
- shallow(<File datasetId="ds001" path="" filename="README" />),
10
- ).toMatchSnapshot()
8
+ const { asFragment } = render(
9
+ <File datasetId="ds001" path="" filename="README" />,
10
+ { wrapper: MemoryRouter },
11
+ )
12
+ expect(asFragment()).toMatchSnapshot()
11
13
  })
12
14
  it('renders for dataset snapshots', () => {
13
- expect(
14
- shallow(
15
- <File
16
- datasetId="ds001"
17
- snapshotTag="1.0.0"
18
- path=""
19
- filename="README"
20
- />,
21
- ),
22
- ).toMatchSnapshot()
15
+ const { asFragment } = render(
16
+ <File datasetId="ds001" snapshotTag="1.0.0" path="" filename="README" />,
17
+ { wrapper: MemoryRouter },
18
+ )
19
+ expect(asFragment()).toMatchSnapshot()
23
20
  })
24
21
  it('generates correct download links for top level files', () => {
25
- const wrapper = shallow(
26
- <File datasetId="ds001" path="" filename="README" />,
27
- )
28
- expect(wrapper.find('.download-file > a').prop('href')).toEqual(
22
+ render(<File datasetId="ds001" path="" filename="README" />, {
23
+ wrapper: MemoryRouter,
24
+ })
25
+ expect(screen.getByRole('link', { name: 'download file' })).toHaveAttribute(
26
+ 'href',
29
27
  '/crn/datasets/ds001/files/README',
30
28
  )
31
29
  })
32
30
  it('generates correct download links for nested files', () => {
33
- const wrapper = shallow(
31
+ render(
34
32
  <File
35
33
  datasetId="ds001"
36
34
  path="sub-01:anat"
37
35
  filename="sub-01_T1w.nii.gz"
38
36
  />,
37
+ { wrapper: MemoryRouter },
39
38
  )
40
- expect(wrapper.find('.download-file > a').prop('href')).toEqual(
39
+ expect(screen.getByRole('link', { name: 'download file' })).toHaveAttribute(
40
+ 'href',
41
41
  '/crn/datasets/ds001/files/sub-01:anat:sub-01_T1w.nii.gz',
42
42
  )
43
43
  })
@@ -113,7 +113,8 @@ const File = ({
113
113
  <span className="edit-file download-file">
114
114
  <a
115
115
  href={apiPath(datasetId, snapshotTag, filePath(path, filename))}
116
- download>
116
+ download
117
+ aria-label="download file">
117
118
  <i className="fa fa-download" />
118
119
  </a>
119
120
  </span>
@@ -121,7 +122,7 @@ const File = ({
121
122
  </Media>
122
123
  <Tooltip tooltip="View">
123
124
  <span className="edit-file view-file">
124
- <Link to={viewerPath}>
125
+ <Link to={viewerPath} aria-label="view file">
125
126
  <i className="fa fa-eye" />
126
127
  </Link>
127
128
  </span>