diff --git a/package.json b/package.json index 0b413067e3..5aeacd219b 100644 --- a/package.json +++ b/package.json @@ -88,12 +88,13 @@ "commitlint": "7.6.1", "commitlint-config-cozy": "0.6.0", "copyfiles": "2.1.1", - "cozy-client": "^27.5.1", + "cozy-client": "27.19.1", "cozy-device-helper": "^1.16.1", "cozy-doctypes": "^1.69.0", "cozy-harvest-lib": "^6.7.3", "cozy-intent": "^1.6.0", "cozy-sharing": "^3.10.0", + "cozy-stack-client": "27.19.1", "css-loader": "0.28.11", "cssnano": "4.1.11", "cssnano-preset-advanced": "4.0.8", @@ -168,7 +169,7 @@ }, "peerDependencies": { "@material-ui/core": ">=4.12", - "cozy-client": ">=27.5.1", + "cozy-client": ">=27.19.1", "cozy-device-helper": "^1.16.0", "cozy-doctypes": "^1.69.0", "cozy-harvest-lib": "^6.7.3", diff --git a/react/AppIcon/index.jsx b/react/AppIcon/index.jsx index a459d5c9d6..67eeaf9bc6 100644 --- a/react/AppIcon/index.jsx +++ b/react/AppIcon/index.jsx @@ -49,6 +49,7 @@ export class AppIcon extends Component { return client.getStackClient().getIconURL({ type, slug: app.slug || app, + appData: app, priority }) } @@ -59,6 +60,7 @@ export class AppIcon extends Component { async load() { const { app, fetchIcon, onReady, client } = this.props + const loadFn = fetchIcon || this.fetchIcon let loadedUrl let loadError diff --git a/react/AppIcon/test/AppIcon.spec.js b/react/AppIcon/test/AppIcon.spec.js index 28e07d0db4..2d2fe097e2 100644 --- a/react/AppIcon/test/AppIcon.spec.js +++ b/react/AppIcon/test/AppIcon.spec.js @@ -43,6 +43,44 @@ describe('AppIcon component', () => { expect(console.error).not.toHaveBeenCalled() }) + it(`should provide appData to getIconUrl in order to get icon simply, when oauth not needed`, async done => { + const app = { + name: 'app name', + slug: 'slug', + links: { + icon: 'icon url' + }, + latest_version: { + version: 'version' + } + } + const getIconURLMock = jest + .fn() + .mockImplementation(() => `https://${domain}`) + const mockClient = { + getStackClient: () => ({ + uri: `https://${domain}`, + getIconURL: getIconURLMock + }) + } + const wrapper = shallow( + { + wrapper.update() + expect(getIconURLMock).toHaveBeenNthCalledWith(1, { + appData: app, + priority: 'stack', + slug: 'slug', + type: 'app' + }) + done() + }} + /> + ) + }) + it(`renders correctly`, async done => { const wrapper = shallow( ({ + withClient: Component => { + const client = { + getStackClient: () => ({ + getIconURL: ({ type, appData }) => { + console.log('getIconUrl called with:') + console.log(type) + console.log(appData) + } + }) + } + return konnector => ( + + ) + } +})) + +jest.mock('../AppIcon', () => ({ fetchIcon }) => ( + +)) + +describe('CipherIcon', () => { + it('should provide appData to getIconUrl in order to get icon simply, when oauth not needed', () => { + // Given + jest.spyOn(console, 'log').mockImplementation() + const konnector = { + name: 'PropTypes.string', + slug: 'slug', + links: { + icon: 'icon url' + }, + latest_version: { + version: 'version' + } + } + const { getByTestId } = render() + + // When + fireEvent.click(getByTestId('app-icon')) + + // Then + expect(console.log).toHaveBeenNthCalledWith(1, 'getIconUrl called with:') + expect(console.log).toHaveBeenNthCalledWith(2, 'konnector') + expect(console.log).toHaveBeenNthCalledWith(3, { konnector }) + }) +}) diff --git a/yarn.lock b/yarn.lock index 1eb1b4108f..82e9f21c35 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5111,10 +5111,10 @@ cozy-bi-auth@0.0.23: lodash "^4.17.20" node-jose "^1.1.4" -cozy-client@^27.5.1: - version "27.5.1" - resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-27.5.1.tgz#5b4b81df34276115337404d4db903e92a5cfe635" - integrity sha512-HuRdqAKWb/5tjyZ5Vry4lVcTJtx71YOx0/K/KvX/4gvAxTwd2gPLb7nZfmB3kEtSzHDLq6F/mhgLLl0TDZfE3A== +cozy-client@27.19.1: + version "27.19.1" + resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-27.19.1.tgz#f7cab0257e290118e295d29436dd4731c014c7fc" + integrity sha512-kqDzQ/qgqwGBW6KTBppCxc1d00DEV1i0c7YpQXSAylTTXMk/FW6GF2Y51RJaESLYrTBJcLKmfkP79G/x0kQtrA== dependencies: "@cozy/minilog" "1.0.0" "@types/jest" "^26.0.20" @@ -5123,7 +5123,7 @@ cozy-client@^27.5.1: cozy-device-helper "^1.12.0" cozy-flags "2.7.1" cozy-logger "^1.6.0" - cozy-stack-client "^27.1.0" + cozy-stack-client "^27.19.1" json-stable-stringify "^1.0.1" lodash "^4.17.13" microee "^0.0.6" @@ -5245,10 +5245,10 @@ cozy-sharing@^3.10.0: react-tooltip "^3.11.1" snarkdown "^2.0.0" -cozy-stack-client@^27.1.0: - version "27.1.0" - resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-27.1.0.tgz#facc296e99b666c5fd56e449c65f95decac6ec8b" - integrity sha512-fcZJpoUd5E+rDRwiuQ5Whjg+jJlxlC/xpmDjdph0mlyDshAP5B8pdNpPIm7MYhnUbcS97JEZHLcQntdKZnHz5Q== +cozy-stack-client@27.19.1, cozy-stack-client@^27.19.1: + version "27.19.1" + resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-27.19.1.tgz#679253c6e028273b480b350583627389d98c6a69" + integrity sha512-DdJCi0lHofWsnT4ZvX02uaELsvgNquuPFPaXulo8gw1x/mVoHsPn+Lpt9xCw35CvhJm3ajJQ709f7JT4lPbCSQ== dependencies: cozy-flags "2.7.1" detect-node "^2.0.4"