Skip to content

Commit

Permalink
refactor: Move konnector policies to their own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleface authored and doubleface committed Feb 16, 2023
1 parent e26b0d0 commit 131ade6
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ jest.mock('cozy-doctypes', () => {
}
})

jest.mock('../../src/services/budget-insight', () => {
jest.mock('../../src/policies/budget-insight', () => {
const originalBudgetInsight = jest.requireActual(
'../../src/services/budget-insight'
'../../src/policies/budget-insight'
)
return {
konnectorPolicy: {
Expand Down
8 changes: 4 additions & 4 deletions packages/cozy-harvest-lib/src/konnector-policies.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logger from './logger'
import { konnectorPolicy as biKonnectorPolicy } from './services/budget-insight'
import { konnectorPolicy as biWebViewPolicy } from './services/biWebView'
import { konnectorPolicy as cccPolicy } from './services/cccPolicy'
import { konnectorPolicy as biKonnectorPolicy } from './policies/budget-insight'
import { konnectorPolicy as biWebViewPolicy } from './policies/biWebView'
import { konnectorPolicy as cliskPolicy } from './policies/clisk'

const defaultKonnectorPolicy = {
accountContainsAuth: true,
Expand All @@ -19,7 +19,7 @@ const defaultKonnectorPolicy = {
}

const policies = [
cccPolicy,
cliskPolicy,
biWebViewPolicy,
biKonnectorPolicy,
defaultKonnectorPolicy
Expand Down
6 changes: 3 additions & 3 deletions packages/cozy-harvest-lib/src/models/ConnectionFlow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import KonnectorJobWatcher, {
watchKonnectorJob
} from './konnector/KonnectorJobWatcher'
import { konnectorPolicy as biKonnectorPolicy } from '../services/budget-insight'
import { konnectorPolicy as biKonnectorPolicy } from '../policies/budget-insight'
import fixtures from '../../test/fixtures'
import sentryHub from '../sentry'
import { Q } from 'cozy-client'
Expand All @@ -34,8 +34,8 @@ jest.mock('../connections/files', () => ({
createDirectoryByPath: jest.fn()
}))

jest.mock('../services/budget-insight', () => {
const originalBudgetInsight = jest.requireActual('../services/budget-insight')
jest.mock('../policies/budget-insight', () => {
const originalBudgetInsight = jest.requireActual('../policies/budget-insight')
return {
konnectorPolicy: {
...originalBudgetInsight.konnectorPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
* - Deals with the konnector to get temporary tokens
*/

import { getBIConnectionAccountsList, getBIConnection } from './bi-http'
import {
getBIConnectionAccountsList,
getBIConnection
} from '../services/bi-http'
import assert from '../assert'
import logger from '../logger'
import { Q } from 'cozy-client'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import ConnectionFlow from '../models/ConnectionFlow'
import flag from 'cozy-flags'

jest.mock('./bi-http', () => ({
jest.mock('../services/bi-http', () => ({
createBIConnection: jest
.fn()
.mockResolvedValue({ text: Promise.resolve('{}') }),
Expand All @@ -19,13 +19,16 @@ jest.mock('./bi-http', () => ({
getBIConnection: jest.fn()
}))

import { getBIConnectionAccountsList, getBIConnection } from './bi-http'
import {
getBIConnectionAccountsList,
getBIConnection
} from '../services/bi-http'

jest.mock('cozy-logger', () => ({
namespace: () => () => {}
}))

jest.mock('./jobUtils', () => ({
jest.mock('../services/jobUtils', () => ({
waitForRealtimeEvent: jest.fn()
}))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import keyBy from 'lodash/keyBy'
import defaults from 'lodash/defaults'
import { Q } from 'cozy-client'

import { waitForRealtimeEvent } from './jobUtils'
import { waitForRealtimeEvent } from '../services/jobUtils'
import {
getBIConnection,
createBIConnection,
updateBIConnection,
getBIUserConfig,
updateBIUserConfig,
setBIConnectionSyncStatus
} from './bi-http'
} from '../services/bi-http'
import assert from '../assert'
import { mkConnAuth, biErrorMap } from 'cozy-bi-auth'
import { KonnectorJobError } from '../helpers/konnectors'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {
updateBIConnectionFromFlow,
sendTwoFACode
} from './budget-insight'
import { waitForRealtimeEvent } from './jobUtils'
import { waitForRealtimeEvent } from '../services/jobUtils'
import {
getBIConnection,
createBIConnection,
updateBIConnection
} from './bi-http'
} from '../services/bi-http'
import merge from 'lodash/merge'
import ConnectionFlow from '../models/ConnectionFlow'
import biPublicKeyProd from './bi-public-key-prod.json'
import biPublicKeyProd from '../services/bi-public-key-prod.json'
import { LOGIN_SUCCESS_EVENT } from '../models/flowEvents'

jest.mock('cozy-logger', () => ({
Expand All @@ -28,11 +28,11 @@ jest.mock('cozy-logger', () => ({
jest.mock('../connections/accounts', () => ({
saveAccount: jest.fn().mockImplementation(async account => account)
}))
jest.mock('./jobUtils', () => ({
jest.mock('../services/jobUtils', () => ({
waitForRealtimeEvent: jest.fn()
}))

jest.mock('./bi-http', () => ({
jest.mock('../services/bi-http', () => ({
createBIConnection: jest
.fn()
.mockResolvedValue({ text: Promise.resolve('{}') }),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getLauncher, konnectorPolicy } from './cccPolicy'
import { getLauncher, konnectorPolicy } from './clisk'

describe('getLauncher', () => {
it('should get the current Launcher from the given window object', () => {
Expand Down

0 comments on commit 131ade6

Please sign in to comment.