File tree 2 files changed +12
-6
lines changed
packages/cozy-harvest-lib/src
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ describe('TriggerErrorInfo', () => {
33
33
34
34
const setup = ( { props : optionProps } = { } ) => {
35
35
fakeClient = {
36
- query : jest . fn ( )
36
+ fetchQueryAndGetFromState : jest . fn ( )
37
37
}
38
38
const root = render (
39
39
< AppLike client = { fakeClient } >
@@ -58,8 +58,8 @@ describe('TriggerErrorInfo', () => {
58
58
} )
59
59
60
60
it ( 'should render unknown error with configured mail support if any' , ( ) => {
61
- fakeClient . query . mockResolvedValue ( {
62
- data : { attributes : { support_address : 'test@address' } }
61
+ fakeClient . fetchQueryAndGetFromState . mockResolvedValue ( {
62
+ data : [ { attributes : { support_address : 'test@address' } } ]
63
63
} )
64
64
const { root } = setup ( {
65
65
props : {
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import has from 'lodash/has'
3
3
import trim from 'lodash/trim'
4
4
import { getBoundT } from '../locales'
5
5
6
- import { Q } from 'cozy-client'
6
+ import { Q , fetchPolicies } from 'cozy-client'
7
7
8
8
import * as accounts from './accounts'
9
9
@@ -168,8 +168,14 @@ export const getErrorLocale = (
168
168
}
169
169
170
170
export const fetchSupportMail = async client => {
171
- const result = await client . query ( Q ( 'io.cozy.settings' ) . getById ( 'context' ) )
172
- return get ( result , 'data.attributes.support_address' , DEFAULT_SUPPORT_MAIL )
171
+ const result = await client . fetchQueryAndGetFromState ( {
172
+ definition : Q ( 'io.cozy.settings' ) . getById ( 'context' ) ,
173
+ options : {
174
+ as : 'contextSupportMail' ,
175
+ fetchPolicy : fetchPolicies . olderThan ( 60 * 60 * 1000 )
176
+ }
177
+ } )
178
+ return get ( result , 'data[0].attributes.support_address' , DEFAULT_SUPPORT_MAIL )
173
179
}
174
180
175
181
export const getErrorLocaleBound = (
You can’t perform that action at this time.
0 commit comments