Commit 78749098 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch...

Merge branch '242028-migrate-bs-callout-to-glalert-in-app-assets-javascripts-jobs-components' into 'master'

Migrate bs-callout to GlAlert in …/unmet_prerequisites_block.vue

See merge request gitlab-org/gitlab!48398
parents 3647f578 2b7a1d1f
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlLink, GlAlert } from '@gitlab/ui';
import { __, s__ } from '~/locale';
/** /**
* Renders Unmet Prerequisites block for job's view. * Renders Unmet Prerequisites block for job's view.
*/ */
export default { export default {
i18n: {
failMessage: s__(
'Job|This job failed because the necessary resources were not successfully created.',
),
moreInformation: __('More information'),
},
components: { components: {
GlLink, GlLink,
GlAlert,
}, },
props: { props: {
helpPath: { helpPath: {
...@@ -16,15 +24,10 @@ export default { ...@@ -16,15 +24,10 @@ export default {
}; };
</script> </script>
<template> <template>
<div class="bs-callout bs-callout-danger"> <gl-alert variant="danger" class="gl-mt-3" :dismissible="false">
<p class="js-failed-unmet-prerequisites gl-mb-0"> {{ $options.i18n.failMessage }}
{{ <gl-link :href="helpPath">
s__(`Job|This job failed because the necessary resources were not successfully created.`) {{ $options.i18n.moreInformation }}
}} </gl-link>
</gl-alert>
<gl-link :href="helpPath" class="js-help-path">
<strong> {{ __('More information') }} </strong>
</gl-link>
</p>
</div>
</template> </template>
---
title: Migrate bs-callout to GlAlert in …/unmet_prerequisites_block.vue
merge_request: 48398
author:
type: other
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import component from '~/jobs/components/unmet_prerequisites_block.vue'; import { GlAlert, GlLink } from '@gitlab/ui';
import mountComponent from '../../helpers/vue_mount_component_helper'; import UnmetPrerequisitesBlock from '~/jobs/components/unmet_prerequisites_block.vue';
describe('Unmet Prerequisites Block Job component', () => { describe('Unmet Prerequisites Block Job component', () => {
const Component = Vue.extend(component); let wrapper;
let vm;
const helpPath = '/user/project/clusters/index.html#troubleshooting-failed-deployment-jobs'; const helpPath = '/user/project/clusters/index.html#troubleshooting-failed-deployment-jobs';
beforeEach(() => { const createComponent = () => {
vm = mountComponent(Component, { wrapper = shallowMount(UnmetPrerequisitesBlock, {
hasNoRunnersForProject: true, propsData: {
helpPath, helpPath,
},
}); });
};
beforeEach(() => {
createComponent();
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('renders an alert with the correct message', () => { it('renders an alert with the correct message', () => {
const container = vm.$el.querySelector('.js-failed-unmet-prerequisites'); const container = wrapper.find(GlAlert);
const alertMessage = const alertMessage =
'This job failed because the necessary resources were not successfully created.'; 'This job failed because the necessary resources were not successfully created.';
expect(container).not.toBeNull(); expect(container).not.toBeNull();
expect(container.innerHTML).toContain(alertMessage); expect(container.text()).toContain(alertMessage);
}); });
it('renders link to help page', () => { it('renders link to help page', () => {
const helpLink = vm.$el.querySelector('.js-help-path'); const helpLink = wrapper.find(GlLink);
expect(helpLink).not.toBeNull(); expect(helpLink).not.toBeNull();
expect(helpLink.innerHTML).toContain('More information'); expect(helpLink.text()).toContain('More information');
expect(helpLink.getAttribute('href')).toEqual(helpPath); expect(helpLink.attributes().href).toEqual(helpPath);
}); });
}); });
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