Commit f1c2d885 authored by Stan Hu's avatar Stan Hu

Merge branch 'vs/fix-broken-master-with-ee-test' into 'master'

Move EE-related tests to the EE folder [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!65076
parents b131b903 f51cc7d8
import { GlToggle } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import CcValidationRequiredAlert from 'ee_component/billings/components/cc_validation_required_alert.vue';
import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises';
import SharedRunnersToggleComponent from '~/projects/settings/components/shared_runners_toggle.vue';
const TEST_UPDATE_PATH = '/test/update_shared_runners';
describe('projects/settings/components/shared_runners', () => {
let wrapper;
const createComponent = (props = {}) => {
wrapper = shallowMount(SharedRunnersToggleComponent, {
propsData: {
isEnabled: false,
isDisabledAndUnoverridable: false,
isLoading: false,
updatePath: TEST_UPDATE_PATH,
isCreditCardValidationRequired: false,
...props,
},
});
};
const findSharedRunnersToggle = () => wrapper.find(GlToggle);
const findCcValidationRequiredAlert = () => wrapper.findComponent(CcValidationRequiredAlert);
const getToggleValue = () => findSharedRunnersToggle().props('value');
const isToggleDisabled = () => findSharedRunnersToggle().props('disabled');
afterEach(() => {
wrapper.destroy();
});
describe('with credit card validation required and shared runners DISABLED', () => {
beforeEach(() => {
window.gon = {
subscriptions_url: TEST_HOST,
payment_form_url: TEST_HOST,
};
createComponent({
isCreditCardValidationRequired: true,
isEnabled: false,
});
});
it('toggle should not be visible', () => {
expect(findSharedRunnersToggle().exists()).toBe(false);
});
it('credit card validation component should exist', () => {
expect(findCcValidationRequiredAlert().exists()).toBe(true);
expect(findCcValidationRequiredAlert().text()).toBe(
SharedRunnersToggleComponent.i18n.REQUIRES_VALIDATION_TEXT,
);
});
describe('when credit card is validated', () => {
it('should show the toggle button', async () => {
findCcValidationRequiredAlert().vm.$emit('verifiedCreditCard');
await waitForPromises();
expect(findSharedRunnersToggle().exists()).toBe(true);
expect(getToggleValue()).toBe(false);
expect(isToggleDisabled()).toBe(false);
});
});
});
});
import { GlAlert, GlToggle, GlTooltip } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import MockAxiosAdapter from 'axios-mock-adapter';
import CcValidationRequiredAlert from 'ee_component/billings/components/cc_validation_required_alert.vue';
import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises';
import axios from '~/lib/utils/axios_utils';
import SharedRunnersToggleComponent from '~/projects/settings/components/shared_runners_toggle.vue';
......@@ -31,7 +29,6 @@ describe('projects/settings/components/shared_runners', () => {
const findErrorAlert = () => wrapper.find(GlAlert);
const findSharedRunnersToggle = () => wrapper.find(GlToggle);
const findToggleTooltip = () => wrapper.find(GlTooltip);
const findCcValidationRequiredAlert = () => wrapper.findComponent(CcValidationRequiredAlert);
const getToggleValue = () => findSharedRunnersToggle().props('value');
const isToggleLoading = () => findSharedRunnersToggle().props('isLoading');
const isToggleDisabled = () => findSharedRunnersToggle().props('disabled');
......@@ -158,40 +155,4 @@ describe('projects/settings/components/shared_runners', () => {
});
});
});
describe('with credit card validation required and shared runners DISABLED', () => {
beforeEach(() => {
window.gon = {
subscriptions_url: TEST_HOST,
payment_form_url: TEST_HOST,
};
createComponent({
isCreditCardValidationRequired: true,
isEnabled: false,
});
});
it('toggle should not be visible', () => {
expect(findSharedRunnersToggle().exists()).toBe(false);
});
it('credit card validation component should exist', () => {
expect(findCcValidationRequiredAlert().exists()).toBe(true);
expect(findCcValidationRequiredAlert().text()).toBe(
SharedRunnersToggleComponent.i18n.REQUIRES_VALIDATION_TEXT,
);
});
describe('when credit card is validated', () => {
it('should show the toggle button', async () => {
findCcValidationRequiredAlert().vm.$emit('verifiedCreditCard');
await waitForPromises();
expect(findSharedRunnersToggle().exists()).toBe(true);
expect(getToggleValue()).toBe(false);
expect(isToggleDisabled()).toBe(false);
});
});
});
});
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