-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): Fix credential icon for old node type version (#7843)
If a credential was for a node's older version, its icon was not shown.
- Loading branch information
Showing
7 changed files
with
1,115 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
packages/editor-ui/src/components/__tests__/CredentialIcon.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { createComponentRenderer } from '@/__tests__/render'; | ||
import CredentialIcon from '@/components/CredentialIcon.vue'; | ||
import { STORES } from '@/constants'; | ||
import { createTestingPinia } from '@pinia/testing'; | ||
import * as testNodeTypes from './testData/nodeTypesTestData'; | ||
import merge from 'lodash-es/merge'; | ||
import { groupNodeTypesByNameAndType } from '@/utils/nodeTypes/nodeTypeTransforms'; | ||
|
||
const defaultState = { | ||
[STORES.CREDENTIALS]: {}, | ||
[STORES.NODE_TYPES]: {}, | ||
}; | ||
|
||
const renderComponent = createComponentRenderer(CredentialIcon, { | ||
pinia: createTestingPinia({ | ||
initialState: defaultState, | ||
}), | ||
global: { | ||
stubs: ['n8n-tooltip'], | ||
}, | ||
}); | ||
|
||
describe('CredentialIcon', () => { | ||
const findIcon = (baseElement: Element) => baseElement.querySelector('img'); | ||
|
||
it('shows correct icon for credential type that is for the latest node type version', () => { | ||
const { baseElement } = renderComponent({ | ||
pinia: createTestingPinia({ | ||
initialState: merge(defaultState, { | ||
[STORES.CREDENTIALS]: {}, | ||
[STORES.NODE_TYPES]: { | ||
nodeTypes: groupNodeTypesByNameAndType([ | ||
testNodeTypes.twitterV1, | ||
testNodeTypes.twitterV2, | ||
]), | ||
}, | ||
}), | ||
}), | ||
props: { | ||
credentialTypeName: 'twitterOAuth2Api', | ||
}, | ||
}); | ||
|
||
expect(findIcon(baseElement)).toHaveAttribute( | ||
'src', | ||
'/icons/n8n-nodes-base/dist/nodes/Twitter/x.svg', | ||
); | ||
}); | ||
|
||
it('shows correct icon for credential type that is for an older node type version', () => { | ||
const { baseElement } = renderComponent({ | ||
pinia: createTestingPinia({ | ||
initialState: merge(defaultState, { | ||
[STORES.CREDENTIALS]: {}, | ||
[STORES.NODE_TYPES]: { | ||
nodeTypes: groupNodeTypesByNameAndType([ | ||
testNodeTypes.twitterV1, | ||
testNodeTypes.twitterV2, | ||
]), | ||
}, | ||
}), | ||
}), | ||
props: { | ||
credentialTypeName: 'twitterOAuth1Api', | ||
}, | ||
}); | ||
|
||
expect(findIcon(baseElement)).toHaveAttribute( | ||
'src', | ||
'/icons/n8n-nodes-base/dist/nodes/Twitter/x.svg', | ||
); | ||
}); | ||
}); |
Oops, something went wrong.