Commit 1e047ea2 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch '357727-use-name-for-training-url-query' into 'master'

Update to use name field for training url graphql query

See merge request gitlab-org/gitlab!84335
parents de2d187f 53a9e843
...@@ -113,8 +113,8 @@ export default { ...@@ -113,8 +113,8 @@ export default {
return this.securityTrainingProviders?.some(({ isEnabled }) => isEnabled); return this.securityTrainingProviders?.some(({ isEnabled }) => isEnabled);
}, },
supportedIdentifiersExternalIds() { supportedIdentifiersExternalIds() {
return this.identifiers.flatMap(({ externalType, externalId }) => return this.identifiers.flatMap(({ externalType, name }) =>
externalType?.toLowerCase() === SUPPORTED_IDENTIFIER_TYPES.cwe ? externalId : [], externalType?.toLowerCase() === SUPPORTED_IDENTIFIER_TYPES.cwe ? name : [],
); );
}, },
hasSupportedIdentifier() { hasSupportedIdentifier() {
......
...@@ -158,7 +158,7 @@ describe('VulnerabilityTraining component', () => { ...@@ -158,7 +158,7 @@ describe('VulnerabilityTraining component', () => {
${'non-supported-identifier'} | ${true} ${'non-supported-identifier'} | ${true}
`('sets it to "$exists" for "$identifier"', async ({ identifier, exists }) => { `('sets it to "$exists" for "$identifier"', async ({ identifier, exists }) => {
createApolloProvider(); createApolloProvider();
createComponent({ identifiers: [{ externalType: identifier, externalId: 'cwe-1' }] }); createComponent({ identifiers: [{ externalType: identifier, name: 'cwe-1' }] });
await waitForQueryToBeLoaded(); await waitForQueryToBeLoaded();
expect(findUnavailableMessage().exists()).toBe(exists); expect(findUnavailableMessage().exists()).toBe(exists);
}); });
...@@ -262,6 +262,32 @@ describe('VulnerabilityTraining component', () => { ...@@ -262,6 +262,32 @@ describe('VulnerabilityTraining component', () => {
expect(findTrainingItemLinkIcons().exists()).toBe(false); 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', () => { 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