Commit 215133b4 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch...

Merge branch '356089-learn-more-link-for-security-training-providers-point-to-the-wrong-location' into 'master'

Fix learn-more links for sec providers

See merge request gitlab-org/gitlab!83081
parents 5a4da371 3eca93b8
...@@ -292,3 +292,10 @@ export const TEMP_PROVIDER_LOGOS = { ...@@ -292,3 +292,10 @@ export const TEMP_PROVIDER_LOGOS = {
svg: scwLogo, svg: scwLogo,
}, },
}; };
// Use the `url` field from the GraphQL query once this issue is resolved
// https://gitlab.com/gitlab-org/gitlab/-/issues/356129
export const TEMP_PROVIDER_URLS = {
Kontra: 'https://application.security/',
[__('Secure Code Warrior')]: 'https://www.securecodewarrior.com/',
};
...@@ -25,7 +25,7 @@ import { ...@@ -25,7 +25,7 @@ import {
updateSecurityTrainingCache, updateSecurityTrainingCache,
updateSecurityTrainingOptimisticResponse, updateSecurityTrainingOptimisticResponse,
} from '~/security_configuration/graphql/cache_utils'; } from '~/security_configuration/graphql/cache_utils';
import { TEMP_PROVIDER_LOGOS } from './constants'; import { TEMP_PROVIDER_LOGOS, TEMP_PROVIDER_URLS } from './constants';
const i18n = { const i18n = {
providerQueryErrorMessage: __( providerQueryErrorMessage: __(
...@@ -206,6 +206,7 @@ export default { ...@@ -206,6 +206,7 @@ export default {
}, },
i18n, i18n,
TEMP_PROVIDER_LOGOS, TEMP_PROVIDER_LOGOS,
TEMP_PROVIDER_URLS,
}; };
</script> </script>
...@@ -247,7 +248,8 @@ export default { ...@@ -247,7 +248,8 @@ export default {
<p> <p>
{{ provider.description }} {{ provider.description }}
<gl-link <gl-link
:href="provider.url" v-if="$options.TEMP_PROVIDER_URLS[provider.name]"
:href="$options.TEMP_PROVIDER_URLS[provider.name]"
target="_blank" target="_blank"
@click="trackProviderLearnMoreClick(provider.id)" @click="trackProviderLearnMoreClick(provider.id)"
> >
......
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
TRACK_PROVIDER_LEARN_MORE_CLICK_ACTION, TRACK_PROVIDER_LEARN_MORE_CLICK_ACTION,
TRACK_PROVIDER_LEARN_MORE_CLICK_LABEL, TRACK_PROVIDER_LEARN_MORE_CLICK_LABEL,
} from '~/security_configuration/constants'; } from '~/security_configuration/constants';
import { TEMP_PROVIDER_URLS } from '~/security_configuration/components/constants';
import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue'; import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue';
import { updateSecurityTrainingOptimisticResponse } from '~/security_configuration/graphql/cache_utils'; import { updateSecurityTrainingOptimisticResponse } from '~/security_configuration/graphql/cache_utils';
import securityTrainingProvidersQuery from '~/security_configuration/graphql/security_training_providers.query.graphql'; import securityTrainingProvidersQuery from '~/security_configuration/graphql/security_training_providers.query.graphql';
...@@ -145,55 +146,60 @@ describe('TrainingProviderList component', () => { ...@@ -145,55 +146,60 @@ describe('TrainingProviderList component', () => {
expect(findCards()).toHaveLength(TEST_TRAINING_PROVIDERS_DEFAULT.data.length); expect(findCards()).toHaveLength(TEST_TRAINING_PROVIDERS_DEFAULT.data.length);
}); });
TEST_TRAINING_PROVIDERS_DEFAULT.data.forEach( TEST_TRAINING_PROVIDERS_DEFAULT.data.forEach(({ name, description, isEnabled }, index) => {
({ name, description, url, isEnabled }, index) => { it(`shows the name for card ${index}`, () => {
it(`shows the name for card ${index}`, () => { expect(findCards().at(index).text()).toContain(name);
expect(findCards().at(index).text()).toContain(name); });
});
it(`shows the description for card ${index}`, () => { it(`shows the description for card ${index}`, () => {
expect(findCards().at(index).text()).toContain(description); expect(findCards().at(index).text()).toContain(description);
}); });
it(`shows the learn more link for enabled card ${index}`, () => {
const learnMoreLink = findCards().at(index).find(GlLink);
const tempLogo = TEMP_PROVIDER_URLS[name];
it(`shows the learn more link for card ${index}`, () => { if (tempLogo) {
expect(findLinks().at(index).attributes()).toEqual({ expect(learnMoreLink.attributes()).toEqual({
target: '_blank', target: '_blank',
href: url, href: TEMP_PROVIDER_URLS[name],
}); });
}); } else {
expect(learnMoreLink.exists()).toBe(false);
}
});
it(`shows the toggle with the correct value for card ${index}`, () => { it(`shows the toggle with the correct value for card ${index}`, () => {
expect(findToggles().at(index).props('value')).toEqual(isEnabled); expect(findToggles().at(index).props('value')).toEqual(isEnabled);
}); });
it(`shows a radio button to select the provider as primary within card ${index}`, () => { it(`shows a radio button to select the provider as primary within card ${index}`, () => {
const primaryProviderRadioForCurrentCard = findPrimaryProviderRadios().at(index); const primaryProviderRadioForCurrentCard = findPrimaryProviderRadios().at(index);
// if the given provider is not enabled it should not be possible select it as primary // if the given provider is not enabled it should not be possible select it as primary
expect(primaryProviderRadioForCurrentCard.find('input').attributes('disabled')).toBe( expect(primaryProviderRadioForCurrentCard.find('input').attributes('disabled')).toBe(
isEnabled ? undefined : 'disabled', isEnabled ? undefined : 'disabled',
); );
expect(primaryProviderRadioForCurrentCard.text()).toBe( expect(primaryProviderRadioForCurrentCard.text()).toBe(
TrainingProviderList.i18n.primaryTraining, TrainingProviderList.i18n.primaryTraining,
); );
}); });
it('shows a info-tooltip that describes the purpose of a primary provider', () => { it('shows a info-tooltip that describes the purpose of a primary provider', () => {
const infoIcon = findPrimaryProviderRadios().at(index).find(GlIcon); const infoIcon = findPrimaryProviderRadios().at(index).find(GlIcon);
const tooltip = getBinding(infoIcon.element, 'gl-tooltip'); const tooltip = getBinding(infoIcon.element, 'gl-tooltip');
expect(infoIcon.props()).toMatchObject({ expect(infoIcon.props()).toMatchObject({
name: 'information-o', name: 'information-o',
});
expect(tooltip.value).toBe(TrainingProviderList.i18n.primaryTrainingDescription);
}); });
expect(tooltip.value).toBe(TrainingProviderList.i18n.primaryTrainingDescription);
});
it('does not show loader when query is populated', () => { it('does not show loader when query is populated', () => {
expect(findLoader().exists()).toBe(false); expect(findLoader().exists()).toBe(false);
}); });
}, });
);
}); });
describe('provider logo', () => { describe('provider logo', () => {
......
export const testProjectPath = 'foo/bar'; export const testProjectPath = 'foo/bar';
export const testProviderIds = [101, 102, 103]; export const testProviderIds = [101, 102, 103];
export const testProviderName = ['Vendor Name 1', 'Vendor Name 2', 'Vendor Name 3']; export const testProviderName = ['Kontra', 'Secure Code Warrior', 'Other Vendor'];
export const testTrainingUrls = [ export const testTrainingUrls = [
'https://www.vendornameone.com/url', 'https://www.vendornameone.com/url',
'https://www.vendornametwo.com/url', 'https://www.vendornametwo.com/url',
......
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