diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 11:10:13 +0000 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) | |
download | gitlab-ce-0ea3fcec397b69815975647f5e2aa5fe944a8486.tar.gz |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js')
-rw-r--r-- | spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js b/spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js deleted file mode 100644 index f626652a944..00000000000 --- a/spec/frontend/pipelines/notification/deprecated_type_keyword_notification_spec.js +++ /dev/null @@ -1,146 +0,0 @@ -import VueApollo from 'vue-apollo'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; -import { GlAlert, GlSprintf } from '@gitlab/ui'; -import createMockApollo from 'helpers/mock_apollo_helper'; -import waitForPromises from 'helpers/wait_for_promises'; -import DeprecatedTypeKeywordNotification from '~/pipelines/components/notification/deprecated_type_keyword_notification.vue'; -import getPipelineWarnings from '~/pipelines/graphql/queries/get_pipeline_warnings.query.graphql'; -import { - mockWarningsWithoutDeprecation, - mockWarningsRootType, - mockWarningsType, - mockWarningsTypesAll, -} from './mock_data'; - -const defaultProvide = { - deprecatedKeywordsDocPath: '/help/ci/yaml/index.md#deprecated-keywords', - fullPath: '/namespace/my-project', - pipelineIid: 4, -}; - -let wrapper; - -const mockWarnings = jest.fn(); - -const createComponent = ({ isLoading = false, options = {} } = {}) => { - return shallowMount(DeprecatedTypeKeywordNotification, { - stubs: { - GlSprintf, - }, - provide: { - ...defaultProvide, - }, - mocks: { - $apollo: { - queries: { - warnings: { - loading: isLoading, - }, - }, - }, - }, - ...options, - }); -}; - -const createComponentWithApollo = () => { - const localVue = createLocalVue(); - localVue.use(VueApollo); - - const handlers = [[getPipelineWarnings, mockWarnings]]; - const mockApollo = createMockApollo(handlers); - - return createComponent({ - options: { - localVue, - apolloProvider: mockApollo, - mocks: {}, - }, - }); -}; - -const findAlert = () => wrapper.findComponent(GlAlert); -const findAlertItems = () => findAlert().findAll('li'); - -afterEach(() => { - wrapper.destroy(); -}); - -describe('Deprecated keyword notification', () => { - describe('while loading the pipeline warnings', () => { - beforeEach(() => { - wrapper = createComponent({ isLoading: true }); - }); - - it('does not display the notification', () => { - expect(findAlert().exists()).toBe(false); - }); - }); - - describe('if there is an error in the query', () => { - beforeEach(async () => { - mockWarnings.mockResolvedValue({ errors: ['It didnt work'] }); - wrapper = createComponentWithApollo(); - await waitForPromises(); - }); - - it('does not display the notification', () => { - expect(findAlert().exists()).toBe(false); - }); - }); - - describe('with a valid query result', () => { - describe('if there are no deprecation warnings', () => { - beforeEach(async () => { - mockWarnings.mockResolvedValue(mockWarningsWithoutDeprecation); - wrapper = createComponentWithApollo(); - await waitForPromises(); - }); - it('does not show the notification', () => { - expect(findAlert().exists()).toBe(false); - }); - }); - - describe('with a root type deprecation message', () => { - beforeEach(async () => { - mockWarnings.mockResolvedValue(mockWarningsRootType); - wrapper = createComponentWithApollo(); - await waitForPromises(); - }); - it('shows the notification with one item', () => { - expect(findAlert().exists()).toBe(true); - expect(findAlertItems()).toHaveLength(1); - expect(findAlertItems().at(0).text()).toContain('types'); - }); - }); - - describe('with a job type deprecation message', () => { - beforeEach(async () => { - mockWarnings.mockResolvedValue(mockWarningsType); - wrapper = createComponentWithApollo(); - await waitForPromises(); - }); - it('shows the notification with one item', () => { - expect(findAlert().exists()).toBe(true); - expect(findAlertItems()).toHaveLength(1); - expect(findAlertItems().at(0).text()).toContain('type'); - expect(findAlertItems().at(0).text()).not.toContain('types'); - }); - }); - - describe('with both the root types and job type deprecation message', () => { - beforeEach(async () => { - mockWarnings.mockResolvedValue(mockWarningsTypesAll); - wrapper = createComponentWithApollo(); - await waitForPromises(); - }); - it('shows the notification with two items', () => { - expect(findAlert().exists()).toBe(true); - expect(findAlertItems()).toHaveLength(2); - expect(findAlertItems().at(0).text()).toContain('types'); - expect(findAlertItems().at(1).text()).toContain('type'); - expect(findAlertItems().at(1).text()).not.toContain('types'); - }); - }); - }); -}); |