Commit 53a9e843 authored by Samantha Ming's avatar Samantha Ming

Update to use name field instead of externalId

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/357727
parent 1ad684ad
......@@ -113,8 +113,8 @@ export default {
return this.securityTrainingProviders?.some(({ isEnabled }) => isEnabled);
},
supportedIdentifiersExternalIds() {
return this.identifiers.flatMap(({ externalType, externalId }) =>
externalType?.toLowerCase() === SUPPORTED_IDENTIFIER_TYPES.cwe ? externalId : [],
return this.identifiers.flatMap(({ externalType, name }) =>
externalType?.toLowerCase() === SUPPORTED_IDENTIFIER_TYPES.cwe ? name : [],
);
},
hasSupportedIdentifier() {
......
......@@ -158,7 +158,7 @@ describe('VulnerabilityTraining component', () => {
${'non-supported-identifier'} | ${true}
`('sets it to "$exists" for "$identifier"', async ({ identifier, exists }) => {
createApolloProvider();
createComponent({ identifiers: [{ externalType: identifier, externalId: 'cwe-1' }] });
createComponent({ identifiers: [{ externalType: identifier, name: 'cwe-1' }] });
await waitForQueryToBeLoaded();
expect(findUnavailableMessage().exists()).toBe(exists);
});
......@@ -262,6 +262,32 @@ describe('VulnerabilityTraining component', () => {
expect(findTrainingItemLinkIcons().exists()).toBe(false);
});
});
describe('security training query', () => {
it('is called with the correct variables', async () => {
const projectQueryHandler = jest.fn().mockResolvedValue(TEST_TRAINING_URLS_EMPTY.response);
const identifiers = [
{
externalType: SUPPORTED_IDENTIFIER_TYPES.cwe,
externalId: 'some external id',
name: 'cwe-1',
},
];
createApolloProvider({ projectQueryHandler });
createComponent({ identifiers });
await waitForQueryToBeLoaded();
expect(projectQueryHandler).toHaveBeenCalledWith(
expect.objectContaining({
identifierExternalIds: [identifiers[0].name],
projectFullPath,
}),
);
});
});
});
describe('with the query resulting in an error', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment