2021-12-02 22:14:42 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
2021-12-06 04:10:26 -05:00
|
|
|
import { mapValues } from 'lodash';
|
2021-12-02 22:14:42 -05:00
|
|
|
import App from '~/google_cloud/components/app.vue';
|
|
|
|
import Home from '~/google_cloud/components/home.vue';
|
|
|
|
import IncubationBanner from '~/google_cloud/components/incubation_banner.vue';
|
|
|
|
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 =
|
2022-03-24 08:07:26 -04:00
|
|
|
'https://gitlab.com/gitlab-org/incubation-engineering/five-minute-production/feedback/-/issues/new';
|
2021-12-06 04:10:26 -05:00
|
|
|
const SCREEN_COMPONENTS = {
|
|
|
|
Home,
|
|
|
|
ServiceAccountsForm,
|
|
|
|
GcpError,
|
|
|
|
NoGcpProjects,
|
|
|
|
};
|
|
|
|
const SERVICE_ACCOUNTS_FORM_PROPS = {
|
|
|
|
gcpProjects: [1, 2, 3],
|
2022-03-02 10:16:07 -05:00
|
|
|
refs: [4, 5, 6],
|
2021-12-06 04:10:26 -05:00
|
|
|
cancelPath: '',
|
|
|
|
};
|
|
|
|
const HOME_PROPS = {
|
|
|
|
serviceAccounts: [{}, {}],
|
2022-02-23 13:16:59 -05:00
|
|
|
gcpRegions: [{}, {}],
|
2021-12-06 04:10:26 -05:00
|
|
|
createServiceAccountUrl: '#url-create-service-account',
|
2022-02-23 13:16:59 -05:00
|
|
|
configureGcpRegionsUrl: '#url-configure-gcp-regions',
|
2021-12-06 04:10:26 -05:00
|
|
|
emptyIllustrationUrl: '#url-empty-illustration',
|
2022-02-11 13:18:58 -05:00
|
|
|
enableCloudRunUrl: '#url-enable-cloud-run',
|
|
|
|
enableCloudStorageUrl: '#enableCloudStorageUrl',
|
2022-03-15 08:07:44 -04:00
|
|
|
revokeOauthUrl: '#revokeOauthUrl',
|
2021-12-06 04:10:26 -05:00
|
|
|
};
|
2021-12-02 22:14:42 -05:00
|
|
|
|
|
|
|
describe('google_cloud App component', () => {
|
|
|
|
let wrapper;
|
|
|
|
|
|
|
|
const findIncubationBanner = () => wrapper.findComponent(IncubationBanner);
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
wrapper.destroy();
|
|
|
|
});
|
|
|
|
|
2021-12-06 04:10:26 -05:00
|
|
|
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-02 22:14:42 -05:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2021-12-06 04:10:26 -05:00
|
|
|
wrapper = shallowMount(App, { propsData: { screen, ...extraProps } });
|
2021-12-02 22:14:42 -05:00
|
|
|
});
|
|
|
|
|
2021-12-06 04:10:26 -05:00
|
|
|
it(`renders only ${componentName}`, () => {
|
|
|
|
const existences = mapValues(SCREEN_COMPONENTS, (x) => wrapper.findComponent(x).exists());
|
2021-12-02 22:14:42 -05:00
|
|
|
|
2021-12-06 04:10:26 -05:00
|
|
|
expect(existences).toEqual({
|
|
|
|
...mapValues(SCREEN_COMPONENTS, () => false),
|
|
|
|
[componentName]: true,
|
2021-12-02 22:14:42 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2021-12-06 04:10:26 -05:00
|
|
|
it(`renders the ${componentName} with props`, () => {
|
|
|
|
expect(wrapper.findComponent(component).props()).toEqual(extraProps);
|
2021-12-02 22:14:42 -05:00
|
|
|
});
|
|
|
|
|
2021-12-06 04:10:26 -05:00
|
|
|
it('renders incubation banner', () => {
|
2021-12-02 22:14:42 -05:00
|
|
|
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`,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|