From 8690743b8be2dce4f7f75f8cbd7359cdc3522785 Mon Sep 17 00:00:00 2001 From: Crash-- Date: Wed, 3 Jan 2024 16:34:06 +0100 Subject: [PATCH] fix: Do not create AppSuggestion for non stable konnector We need to check the `latest_version` attribute to know if there is a stable version or not. Before the fix, we created app suggestion even for beta or dev konnectors. --- src/ducks/brandDictionary/brandsReducer.js | 20 +++++++++++++++++-- .../brandDictionary/brandsReducer.spec.js | 4 +++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ducks/brandDictionary/brandsReducer.js b/src/ducks/brandDictionary/brandsReducer.js index 0e4904927b..cd9d2de8c8 100644 --- a/src/ducks/brandDictionary/brandsReducer.js +++ b/src/ducks/brandDictionary/brandsReducer.js @@ -51,6 +51,23 @@ export const makeBrands = async (client, dispatch, inService) => { type: 'konnector' }) + /* + Even if we specify channel "stable", we can get a konnector that doesn't have + a stable version. We can have published konnector with no stable version, for + instance a konnector that have only dev or beta version. The + ``` + fetchApps({ + limit: 1000, + channel: 'stable', + type: 'konnector' + }) + ``` + will return it. The channel filter is only applied on version & latest_version. + So in order to only use konnector with a stable version, we filter them here. + */ + const filteredKonnector = allRegistryKonnectors.filter( + konnector => konnector.latest_version + ) const triggerWithoutCurrentStateQuery = buildTriggerWithoutCurrentStateQuery() const triggers = await client.queryAll( triggerWithoutCurrentStateQuery.definition, @@ -60,8 +77,7 @@ export const makeBrands = async (client, dispatch, inService) => { const configuredKonnectorsSlugs = triggers ? triggers.map(getKonnectorSlug).filter(Boolean) : [] - - const allBrands = allRegistryKonnectors.reduce( + const allBrands = filteredKonnector.reduce( (allBrands, data) => [ ...allBrands, makeBrand(data, brands, configuredKonnectorsSlugs) diff --git a/src/ducks/brandDictionary/brandsReducer.spec.js b/src/ducks/brandDictionary/brandsReducer.spec.js index b4c5ced012..39d60229bb 100644 --- a/src/ducks/brandDictionary/brandsReducer.spec.js +++ b/src/ducks/brandDictionary/brandsReducer.spec.js @@ -32,6 +32,9 @@ describe('makeBrands', () => { banksTransactionRegExp: '\\bameli\\b' } } + }, + { + slug: 'fnac' } ]) const mockClient = new CozyClient({ @@ -102,7 +105,6 @@ describe('makeBrands', () => { describe('target service', () => { it('Should make brands with just necessary informations and dispatch', async () => { const brands = await makeBrands(mockClient, undefined, true) - act(() => { expect(brands).toEqual([ {