diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-03 03:11:20 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-03 03:11:20 +0300 |
commit | 498ba9dc41fcf2b4be30a8f3721543953efb3c3b (patch) | |
tree | ed33fbf37c0c2ae3a71042455f9b51800907a984 /spec/frontend/security_configuration | |
parent | 515f39456fce82eb2ab811fa366167ad084a3b12 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/security_configuration')
-rw-r--r-- | spec/frontend/security_configuration/components/app_spec.js | 11 | ||||
-rw-r--r-- | spec/frontend/security_configuration/components/training_provider_list_spec.js | 60 |
2 files changed, 70 insertions, 1 deletions
diff --git a/spec/frontend/security_configuration/components/app_spec.js b/spec/frontend/security_configuration/components/app_spec.js index 4e0ea6a9717..759844b941a 100644 --- a/spec/frontend/security_configuration/components/app_spec.js +++ b/spec/frontend/security_configuration/components/app_spec.js @@ -5,7 +5,10 @@ import { useLocalStorageSpy } from 'helpers/local_storage_helper'; import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser'; import stubChildren from 'helpers/stub_children'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; -import SecurityConfigurationApp, { i18n } from '~/security_configuration/components/app.vue'; +import SecurityConfigurationApp, { + i18n, + TRAINING_PROVIDERS, +} from '~/security_configuration/components/app.vue'; import AutoDevopsAlert from '~/security_configuration/components/auto_dev_ops_alert.vue'; import AutoDevopsEnabledAlert from '~/security_configuration/components/auto_dev_ops_enabled_alert.vue'; import { @@ -20,6 +23,7 @@ import { AUTO_DEVOPS_ENABLED_ALERT_DISMISSED_STORAGE_KEY, } from '~/security_configuration/components/constants'; import FeatureCard from '~/security_configuration/components/feature_card.vue'; +import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue'; import UpgradeBanner from '~/security_configuration/components/upgrade_banner.vue'; import { @@ -78,6 +82,7 @@ describe('App component', () => { const findTabs = () => wrapper.findAllComponents(GlTab); const findByTestId = (id) => wrapper.findByTestId(id); const findFeatureCards = () => wrapper.findAllComponents(FeatureCard); + const findTrainingProviderList = () => wrapper.findComponent(TrainingProviderList); const findManageViaMRErrorAlert = () => wrapper.findByTestId('manage-via-mr-error-alert'); const findLink = ({ href, text, container = wrapper }) => { const selector = `a[href="${href}"]`; @@ -180,6 +185,10 @@ describe('App component', () => { expect(findComplianceViewHistoryLink().exists()).toBe(false); expect(findSecurityViewHistoryLink().exists()).toBe(false); }); + + it('renders training provider list with correct props', () => { + expect(findTrainingProviderList().props('providers')).toEqual(TRAINING_PROVIDERS); + }); }); describe('Manage via MR Error Alert', () => { diff --git a/spec/frontend/security_configuration/components/training_provider_list_spec.js b/spec/frontend/security_configuration/components/training_provider_list_spec.js new file mode 100644 index 00000000000..1169a977d44 --- /dev/null +++ b/spec/frontend/security_configuration/components/training_provider_list_spec.js @@ -0,0 +1,60 @@ +import { GlLink, GlToggle, GlCard } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import TrainingProviderList from '~/security_configuration/components/training_provider_list.vue'; +import { TRAINING_PROVIDERS } from '~/security_configuration/components/app.vue'; + +const DEFAULT_PROPS = { + providers: TRAINING_PROVIDERS, +}; + +describe('TrainingProviderList component', () => { + let wrapper; + + const createComponent = (props = {}) => { + wrapper = shallowMount(TrainingProviderList, { + propsData: { + ...DEFAULT_PROPS, + ...props, + }, + }); + }; + + const findCards = () => wrapper.findAllComponents(GlCard); + const findLinks = () => wrapper.findAllComponents(GlLink); + const findToggles = () => wrapper.findAllComponents(GlToggle); + + afterEach(() => { + wrapper.destroy(); + }); + + describe('basic structure', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders correct amount of cards', () => { + expect(findCards()).toHaveLength(DEFAULT_PROPS.providers.length); + }); + + DEFAULT_PROPS.providers.forEach(({ name, description, url, isEnabled }, index) => { + it(`shows the name for card ${index}`, () => { + expect(findCards().at(index).text()).toContain(name); + }); + + it(`shows the description for card ${index}`, () => { + expect(findCards().at(index).text()).toContain(description); + }); + + it(`shows the learn more link for card ${index}`, () => { + expect(findLinks().at(index).attributes()).toEqual({ + target: '_blank', + href: url, + }); + }); + + it(`shows the toggle with the correct value for card ${index}`, () => { + expect(findToggles().at(index).props('value')).toEqual(isEnabled); + }); + }); + }); +}); |