diff --git a/docs/api/cozy-client/classes/CozyClient.md b/docs/api/cozy-client/classes/CozyClient.md index 5b024213d4..8f0601339e 100644 --- a/docs/api/cozy-client/classes/CozyClient.md +++ b/docs/api/cozy-client/classes/CozyClient.md @@ -1099,7 +1099,7 @@ loadInstanceOptionsFromDOM - Loads the dataset injected by the Stack in web page loadInstanceOptionsFromStack - Loads the instance options from cozy-stack and exposes it through getInstanceOptions -For now only retrieving capabilities is supported +This method is not iso with loadInstanceOptionsFromDOM for now. *Returns* @@ -1604,7 +1604,7 @@ Saves multiple documents in one batch *Defined in* -[packages/cozy-client/src/CozyClient.js:1729](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1729) +[packages/cozy-client/src/CozyClient.js:1735](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1735) *** @@ -1628,7 +1628,7 @@ set some data in the store. *Defined in* -[packages/cozy-client/src/CozyClient.js:1702](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1702) +[packages/cozy-client/src/CozyClient.js:1708](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1708) *** @@ -1652,7 +1652,7 @@ At any time put an error function *Defined in* -[packages/cozy-client/src/CozyClient.js:1715](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1715) +[packages/cozy-client/src/CozyClient.js:1721](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1721) *** @@ -1728,7 +1728,7 @@ Contains the fetched token and the client information. These should be stored an *Defined in* -[packages/cozy-client/src/CozyClient.js:1722](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1722) +[packages/cozy-client/src/CozyClient.js:1728](https://github.com/cozy/cozy-client/blob/master/packages/cozy-client/src/CozyClient.js#L1728) *** diff --git a/packages/cozy-client/src/CozyClient.js b/packages/cozy-client/src/CozyClient.js index 9658d1169f..08d3a8d264 100644 --- a/packages/cozy-client/src/CozyClient.js +++ b/packages/cozy-client/src/CozyClient.js @@ -1676,7 +1676,7 @@ instantiation of the client.` /** * loadInstanceOptionsFromStack - Loads the instance options from cozy-stack and exposes it through getInstanceOptions * - * For now only retrieving capabilities is supported + * This method is not iso with loadInstanceOptionsFromDOM for now. * * @returns {Promise} */ @@ -1685,8 +1685,14 @@ instantiation of the client.` Q('io.cozy.settings').getById('io.cozy.settings.capabilities') ) + const { data: instanceData } = await this.query( + Q('io.cozy.settings').getById('io.cozy.settings.instance') + ) + this.instanceOptions = { - capabilities: data.attributes + capabilities: data.attributes, + locale: instanceData.attributes?.locale, + tracking: instanceData.attributes?.tracking } this.capabilities = this.instanceOptions.capabilities || null diff --git a/packages/cozy-client/src/CozyClient.spec.js b/packages/cozy-client/src/CozyClient.spec.js index 8edbc23e5c..ce6cb1af3a 100644 --- a/packages/cozy-client/src/CozyClient.spec.js +++ b/packages/cozy-client/src/CozyClient.spec.js @@ -492,9 +492,14 @@ describe('CozyClient logout', () => { }) it('should call reset on each link that can be reset', async () => { - client.query = jest.fn().mockResolvedValueOnce({ - data: { attributes: { file_versioning: true, flat_subdomains: true } } - }) + client.query = jest + .fn() + .mockResolvedValueOnce({ + data: { attributes: { file_versioning: true, flat_subdomains: true } } + }) + .mockResolvedValueOnce({ + data: { attributes: { locale: 'fr', tracking: true } } + }) links[0].reset = jest.fn() links[2].reset = jest.fn() await client.login() @@ -512,9 +517,14 @@ describe('CozyClient logout', () => { }) it('should call all reset even if a reset throws an error', async () => { - client.query = jest.fn().mockResolvedValueOnce({ - data: { attributes: { file_versioning: true, flat_subdomains: true } } - }) + client.query = jest + .fn() + .mockResolvedValueOnce({ + data: { attributes: { file_versioning: true, flat_subdomains: true } } + }) + .mockResolvedValueOnce({ + data: { attributes: { locale: 'fr', tracking: true } } + }) links[0].reset = jest.fn().mockRejectedValue(new Error('Async error')) links[2].reset = jest.fn() await client.login() @@ -524,9 +534,14 @@ describe('CozyClient logout', () => { }) it('should emit events', async () => { - client.query = jest.fn().mockResolvedValueOnce({ - data: { attributes: { file_versioning: true, flat_subdomains: true } } - }) + client.query = jest + .fn() + .mockResolvedValueOnce({ + data: { attributes: { file_versioning: true, flat_subdomains: true } } + }) + .mockResolvedValueOnce({ + data: { attributes: { locale: 'fr', tracking: true } } + }) const originalLogout = client.logout links[0].reset = jest.fn() links[2].reset = jest.fn() @@ -545,9 +560,14 @@ describe('CozyClient logout', () => { }) it('should unregister an oauth client', async () => { - client.query = jest.fn().mockResolvedValueOnce({ - data: { attributes: { file_versioning: true, flat_subdomains: true } } - }) + client.query = jest + .fn() + .mockResolvedValueOnce({ + data: { attributes: { file_versioning: true, flat_subdomains: true } } + }) + .mockResolvedValueOnce({ + data: { attributes: { locale: 'fr', tracking: true } } + }) await client.login() stackClient.isRegistered.mockReturnValue(true) diff --git a/packages/cozy-client/types/CozyClient.d.ts b/packages/cozy-client/types/CozyClient.d.ts index 32bf75bb74..ffd7118b2c 100644 --- a/packages/cozy-client/types/CozyClient.d.ts +++ b/packages/cozy-client/types/CozyClient.d.ts @@ -687,7 +687,7 @@ declare class CozyClient { /** * loadInstanceOptionsFromStack - Loads the instance options from cozy-stack and exposes it through getInstanceOptions * - * For now only retrieving capabilities is supported + * This method is not iso with loadInstanceOptionsFromDOM for now. * * @returns {Promise} */