Skip to content

Commit

Permalink
fix: Do not create AppSuggestion for non stable konnector
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Crash-- committed Jan 4, 2024
1 parent 247b4d0 commit 8690743
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/ducks/brandDictionary/brandsReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/ducks/brandDictionary/brandsReducer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ describe('makeBrands', () => {
banksTransactionRegExp: '\\bameli\\b'
}
}
},
{
slug: 'fnac'
}
])
const mockClient = new CozyClient({
Expand Down Expand Up @@ -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([
{
Expand Down

0 comments on commit 8690743

Please sign in to comment.