debian-mirror-gitlab/spec/frontend/google_cloud/components/app_spec.js

75 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-12-11 22:18:48 +05:30
import { shallowMount } from '@vue/test-utils';
2022-01-26 12:08:38 +05:30
import { mapValues } from 'lodash';
2021-12-11 22:18:48 +05:30
import App from '~/google_cloud/components/app.vue';
2022-01-26 12:08:38 +05:30
import Home from '~/google_cloud/components/home.vue';
2021-12-11 22:18:48 +05:30
import IncubationBanner from '~/google_cloud/components/incubation_banner.vue';
2022-01-26 12:08:38 +05:30
import ServiceAccountsForm from '~/google_cloud/components/service_accounts_form.vue';
import GcpError from '~/google_cloud/components/errors/gcp_error.vue';
import NoGcpProjects from '~/google_cloud/components/errors/no_gcp_projects.vue';
const BASE_FEEDBACK_URL =
'https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/meta/-/issues/new';
const SCREEN_COMPONENTS = {
Home,
ServiceAccountsForm,
GcpError,
NoGcpProjects,
};
const SERVICE_ACCOUNTS_FORM_PROPS = {
gcpProjects: [1, 2, 3],
environments: [4, 5, 6],
cancelPath: '',
};
const HOME_PROPS = {
serviceAccounts: [{}, {}],
createServiceAccountUrl: '#url-create-service-account',
emptyIllustrationUrl: '#url-empty-illustration',
2022-04-04 11:22:00 +05:30
enableCloudRunUrl: '#url-enable-cloud-run',
enableCloudStorageUrl: '#enableCloudStorageUrl',
2022-01-26 12:08:38 +05:30
};
2021-12-11 22:18:48 +05:30
describe('google_cloud App component', () => {
let wrapper;
const findIncubationBanner = () => wrapper.findComponent(IncubationBanner);
afterEach(() => {
wrapper.destroy();
});
2022-01-26 12:08:38 +05:30
describe.each`
screen | extraProps | componentName
${'gcp_error'} | ${{ error: 'mock_gcp_client_error' }} | ${'GcpError'}
${'no_gcp_projects'} | ${{}} | ${'NoGcpProjects'}
${'service_accounts_form'} | ${SERVICE_ACCOUNTS_FORM_PROPS} | ${'ServiceAccountsForm'}
${'home'} | ${HOME_PROPS} | ${'Home'}
`('for screen=$screen', ({ screen, extraProps, componentName }) => {
const component = SCREEN_COMPONENTS[componentName];
2021-12-11 22:18:48 +05:30
2022-01-26 12:08:38 +05:30
beforeEach(() => {
wrapper = shallowMount(App, { propsData: { screen, ...extraProps } });
2021-12-11 22:18:48 +05:30
});
2022-01-26 12:08:38 +05:30
it(`renders only ${componentName}`, () => {
const existences = mapValues(SCREEN_COMPONENTS, (x) => wrapper.findComponent(x).exists());
2021-12-11 22:18:48 +05:30
2022-01-26 12:08:38 +05:30
expect(existences).toEqual({
...mapValues(SCREEN_COMPONENTS, () => false),
[componentName]: true,
2021-12-11 22:18:48 +05:30
});
});
2022-01-26 12:08:38 +05:30
it(`renders the ${componentName} with props`, () => {
expect(wrapper.findComponent(component).props()).toEqual(extraProps);
2021-12-11 22:18:48 +05:30
});
2022-01-26 12:08:38 +05:30
it('renders incubation banner', () => {
expect(findIncubationBanner().props()).toEqual({
shareFeedbackUrl: `${BASE_FEEDBACK_URL}?issuable_template=general_feedback`,
reportBugUrl: `${BASE_FEEDBACK_URL}?issuable_template=report_bug`,
featureRequestUrl: `${BASE_FEEDBACK_URL}?issuable_template=feature_request`,
2021-12-11 22:18:48 +05:30
});
});
});
});