cozy-viewer 2.2.0 → 2.3.1

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 2.3.1 (2024-11-05)
7
+
8
+ **Note:** Version bump only for package cozy-viewer
9
+
10
+
11
+
12
+
13
+
14
+ # 2.3.0 (2024-10-30)
15
+
16
+
17
+ ### Features
18
+
19
+ * Update deps for cozy-viewer ([b2e103a](https://github.com/cozy/cozy-libs/commit/b2e103a1280182881ae1133860c0a09650271920))
20
+
21
+
22
+
23
+
24
+
6
25
  # 2.2.0 (2024-10-30)
7
26
 
8
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-viewer",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "Cozy-Viewer provides a component to show files in a viewer.",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -24,14 +24,14 @@
24
24
  "@testing-library/react": "11.2.7",
25
25
  "@testing-library/react-hooks": "^3.2.1",
26
26
  "babel-plugin-inline-json-import": "0.3.2",
27
- "babel-preset-cozy-app": "^2.4.0",
28
- "cozy-client": "48.8.0",
27
+ "babel-preset-cozy-app": "^2.5.1",
28
+ "cozy-client": "50.0.0",
29
29
  "cozy-device-helper": "2.0.0",
30
- "cozy-harvest-lib": "^6.7.3",
31
- "cozy-intent": "^1.16.1",
32
- "cozy-logger": "^1.12.0",
30
+ "cozy-harvest-lib": "^30.3.1",
31
+ "cozy-intent": "^2.26.1",
32
+ "cozy-logger": "^1.13.1",
33
33
  "cozy-sharing": "14.1.0",
34
- "cozy-ui": "^112.0.0",
34
+ "cozy-ui": "^112.2.0",
35
35
  "enzyme": "3.11.0",
36
36
  "enzyme-adapter-react-16": "1.15.6",
37
37
  "enzyme-to-json": "3.6.2",
@@ -50,15 +50,15 @@
50
50
  "react-pdf": "^5.7.2"
51
51
  },
52
52
  "peerDependencies": {
53
- "cozy-client": ">=49.0.0",
53
+ "cozy-client": ">=50.0.0",
54
54
  "cozy-device-helper": ">=2.0.0",
55
- "cozy-harvest-lib": ">=6.7.3",
56
- "cozy-intent": ">=1.16.1",
55
+ "cozy-harvest-lib": ">=30.2.0",
56
+ "cozy-intent": ">=2.26.0",
57
57
  "cozy-logger": ">=1.9.0",
58
58
  "cozy-sharing": ">=14.1.0",
59
- "cozy-ui": ">=112.0.0",
59
+ "cozy-ui": ">=112.2.0",
60
60
  "react": ">=16.12.0",
61
61
  "react-dom": ">=16.12.0"
62
62
  },
63
- "gitHead": "b9937f0b5374a867281c8bdbd10aba5db8e9dc0e"
63
+ "gitHead": "102cfa397539ed1f44a027acc263cce818fd639b"
64
64
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,73 +0,0 @@
1
- import { render, waitFor } from '@testing-library/react'
2
- import React from 'react'
3
-
4
- import { checkImageSource } from 'cozy-ui/transpiled/react/FileImageLoader/checkImageSource'
5
- import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints'
6
- import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
7
-
8
- import ImageViewer from './ImageViewer'
9
- import DemoProvider from '../providers/DemoProvider'
10
-
11
- jest.mock('cozy-ui/transpiled/react/FileImageLoader/checkImageSource', () => ({
12
- ...jest.requireActual(
13
- 'cozy-ui/transpiled/react/FileImageLoader/checkImageSource'
14
- ),
15
- checkImageSource: jest.fn()
16
- }))
17
-
18
- const file = {
19
- _id: 'image',
20
- class: 'image',
21
- mime: 'image/jpg',
22
- name: 'sample.jpg',
23
- links: {
24
- large: 'https://viewerdemo.cozycloud.cc/IMG_0062.PNG'
25
- }
26
- }
27
-
28
- const gestures = {
29
- on: jest.fn(),
30
- off: jest.fn(),
31
- get: jest.fn()
32
- }
33
-
34
- const setup = () => {
35
- const root = render(
36
- <DemoProvider>
37
- <BreakpointsProvider>
38
- <EncryptedProvider>
39
- <ImageViewer
40
- file={file}
41
- gestures={gestures}
42
- gesturesRef={{}}
43
- onSwipe={jest.fn()}
44
- />
45
- </EncryptedProvider>
46
- </BreakpointsProvider>
47
- </DemoProvider>
48
- )
49
-
50
- return { root }
51
- }
52
-
53
- describe('ImageViewer', () => {
54
- afterEach(() => {
55
- jest.restoreAllMocks
56
- })
57
-
58
- it('should render a spinner then the image viewer', async () => {
59
- const { root } = setup()
60
- const { container, queryByRole } = root
61
-
62
- expect(queryByRole('progressbar')).toBeTruthy()
63
-
64
- // simulate a successfull image loading
65
- checkImageSource.mockResolvedValue('ok')
66
-
67
- await waitFor(() => container.querySelector('img'))
68
-
69
- const img = container.querySelector('img')
70
- expect(img.getAttribute('alt')).toBe(file.name)
71
- expect(img.getAttribute('src')).toBe(file.links.large)
72
- })
73
- })
@@ -1,76 +0,0 @@
1
- import { render, waitFor } from '@testing-library/react'
2
- import React from 'react'
3
-
4
- import { CozyProvider, createMockClient } from 'cozy-client'
5
- import logger from 'cozy-logger'
6
- import EncryptedProvider from 'cozy-ui/transpiled/react/providers/Encrypted'
7
- import { I18n } from 'cozy-ui/transpiled/react/providers/I18n'
8
-
9
- import { PdfMobileViewer } from './PdfMobileViewer'
10
-
11
- logger.error = logger.warn = jest.fn()
12
-
13
- const client = createMockClient({})
14
- client.collection = jest.fn(() => ({
15
- getDownloadLinkById: jest.fn()
16
- }))
17
- client.plugins.realtime = {
18
- subscribe: jest.fn(),
19
- unsubscribe: jest.fn(),
20
- unsubscribeAll: jest.fn()
21
- }
22
- jest.mock('cozy-ui/transpiled/react/providers/Alert', () => ({
23
- useAlert: jest.fn().mockReturnValue({ showAlert: jest.fn() })
24
- }))
25
-
26
- const file = {
27
- _id: 'pdf',
28
- class: 'pdf',
29
- name: 'Demo.pdf',
30
- mime: 'application/pdf',
31
- links: {
32
- medium: 'https://viewerdemo.cozycloud.cc/IMG_0062.PNG'
33
- }
34
- }
35
-
36
- const setup = ({ file }) => {
37
- const root = render(
38
- <CozyProvider client={client}>
39
- <I18n lang="en" dictRequire={() => ''}>
40
- <EncryptedProvider>
41
- <PdfMobileViewer file={file} t={x => x} />
42
- </EncryptedProvider>
43
- </I18n>
44
- </CozyProvider>
45
- )
46
-
47
- return { root }
48
- }
49
-
50
- describe('PdfMobileViewer', () => {
51
- it('should show a spinner if image is not loaded', () => {
52
- const { root } = setup({ file })
53
- const { getByRole } = root
54
-
55
- expect(getByRole('progressbar'))
56
- })
57
-
58
- describe('errors if file as no medium or failed to download', () => {
59
- let fileWithoutLinks = file
60
-
61
- beforeAll(() => {
62
- fileWithoutLinks.links = undefined
63
- })
64
-
65
- it('should show "download" button on browser', async () => {
66
- const { root } = setup({ file: fileWithoutLinks })
67
- const { getByText, queryByRole } = root
68
-
69
- await waitFor(() => {
70
- expect(queryByRole('progressbar')).toBeFalsy()
71
- expect(getByText('Viewer.download'))
72
- expect(getByText(file.name))
73
- })
74
- })
75
- })
76
- })