Skip to content
Snippets Groups Projects
Commit 2eaa98f2 authored by 🤖 GitLab Bot 🤖's avatar 🤖 GitLab Bot 🤖
Browse files

Automatic merge of gitlab-org/gitlab master

parents 85030933 4b1e65aa
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,7 @@ export default {
'releaseTag',
'search',
'weight',
'myReactionEmoji',
]);
// Temporarily disabled until negated filters are supported for epic boards
......
<script>
import { GlButton, GlSprintf } from '@gitlab/ui';
import { numberToHumanSize } from '~/lib/utils/number_utils';
import { s__ } from '~/locale';
export default {
components: {
GlButton,
GlSprintf,
},
props: {
totalSize: {
type: Number,
required: true,
},
},
i18n: {
totalSize: s__('CorpusManagement|Total Size: %{totalSize}'),
newCorpus: s__('CorpusManagement|New corpus'),
},
computed: {
formattedFileSize() {
return numberToHumanSize(this.totalSize);
},
},
methods: {
newCorpus() {
this.$emit('newcorpus');
},
},
};
</script>
<template>
<div
class="gl-h-11 gl-bg-gray-10 gl-display-flex gl-justify-content-space-between gl-align-items-center"
>
<div class="gl-ml-5">
<gl-sprintf :message="$options.i18n.totalSize">
<template #totalSize>
<span class="gl-font-weight-bold">{{ formattedFileSize }}</span>
</template>
</gl-sprintf>
</div>
<gl-button class="gl-mr-5" category="primary" variant="confirm" @click="newCorpus">
{{ this.$options.i18n.newCorpus }}
</gl-button>
</div>
</template>
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Corpus Upload component renders header 1`] = `
<div
class="gl-h-11 gl-bg-gray-10 gl-display-flex gl-justify-content-space-between gl-align-items-center"
>
<div
class="gl-ml-5"
>
<gl-sprintf-stub
message="Total Size: %{totalSize}"
/>
</div>
<gl-button-stub
buttontextclasses=""
category="primary"
class="gl-mr-5"
icon=""
size="medium"
variant="confirm"
>
New corpus
</gl-button-stub>
</div>
`;
import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import CorpusUpload from 'ee/security_configuration/corpus_management/components/corpus_upload.vue';
describe('Corpus Upload', () => {
let wrapper;
const createComponentFactory = (mountFn = shallowMount) => (options = {}) => {
const defaultProps = { totalSize: 4e8 };
wrapper = mountFn(CorpusUpload, {
propsData: defaultProps,
...options,
});
};
const createComponent = createComponentFactory();
afterEach(() => {
wrapper.destroy();
});
describe('component', () => {
it('renders header', () => {
createComponent();
expect(wrapper.findComponent(GlButton).exists()).toBe(true);
expect(wrapper.element).toMatchSnapshot();
});
it('calls the `uploadCorpus` callback on `new corpus` button click', async () => {
createComponent({ stubs: { GlButton } });
await wrapper.findComponent(GlButton).trigger('click');
expect(wrapper.emitted().newcorpus).toEqual([[]]);
});
});
});
......@@ -8645,6 +8645,12 @@ msgstr ""
msgid "CorpusManagement|Fuzz testing corpus management"
msgstr ""
 
msgid "CorpusManagement|New corpus"
msgstr ""
msgid "CorpusManagement|Total Size: %{totalSize}"
msgstr ""
msgid "Could not add admins as members"
msgstr ""
 
......
......@@ -17,8 +17,6 @@
let(:card) { find('.board:nth-child(2)').first('.board-card') }
before do
stub_feature_flags(graphql_board_lists: false)
project.add_maintainer(user)
sign_in(user)
......
......@@ -52,7 +52,7 @@ describe('Test issue body', () => {
});
it('renders issue name', () => {
expect(findDescription().text()).toBe(failedIssue.name);
expect(findDescription().text()).toContain(failedIssue.name);
});
it('renders failed status icon', () => {
......
import { GlAlert } from '@gitlab/ui';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import VueApollo from 'vue-apollo';
import createMockApollo from 'helpers/mock_apollo_helper';
......@@ -14,7 +15,10 @@ localVue.use(VueApollo);
describe('RunnerInstructions component', () => {
let wrapper;
let fakeApollo;
let runnerPlatformsHandler;
let runnerSetupInstructionsHandler;
const findAlert = () => wrapper.findComponent(GlAlert);
const findModalButton = () => wrapper.find('[data-testid="show-modal-button"]');
const findPlatformButtons = () => wrapper.findAll('[data-testid="platform-button"]');
const findArchitectureDropdownItems = () =>
......@@ -22,10 +26,10 @@ describe('RunnerInstructions component', () => {
const findBinaryInstructionsSection = () => wrapper.find('[data-testid="binary-instructions"]');
const findRunnerInstructionsSection = () => wrapper.find('[data-testid="runner-instructions"]');
beforeEach(async () => {
const createComponent = () => {
const requestHandlers = [
[getRunnerPlatforms, jest.fn().mockResolvedValue(mockGraphqlRunnerPlatforms)],
[getRunnerSetupInstructions, jest.fn().mockResolvedValue(mockGraphqlInstructions)],
[getRunnerPlatforms, runnerPlatformsHandler],
[getRunnerSetupInstructions, runnerSetupInstructionsHandler],
];
fakeApollo = createMockApollo(requestHandlers);
......@@ -37,6 +41,13 @@ describe('RunnerInstructions component', () => {
localVue,
apolloProvider: fakeApollo,
});
};
beforeEach(async () => {
runnerPlatformsHandler = jest.fn().mockResolvedValue(mockGraphqlRunnerPlatforms);
runnerSetupInstructionsHandler = jest.fn().mockResolvedValue(mockGraphqlInstructions);
createComponent();
await wrapper.vm.$nextTick();
});
......@@ -46,6 +57,10 @@ describe('RunnerInstructions component', () => {
wrapper = null;
});
it('should not show alert', () => {
expect(findAlert().exists()).toBe(false);
});
it('should show the "Show Runner installation instructions" button', () => {
const button = findModalButton();
......@@ -110,4 +125,23 @@ describe('RunnerInstructions component', () => {
expect(runner.text()).toMatch(mockGraphqlInstructions.data.runnerSetup.registerInstructions);
});
describe('when instructions cannot be loaded', () => {
beforeEach(async () => {
runnerSetupInstructionsHandler.mockRejectedValue();
createComponent();
await wrapper.vm.$nextTick();
});
it('should show alert', () => {
expect(findAlert().exists()).toBe(true);
});
it('should not show instructions', () => {
expect(findBinaryInstructionsSection().exists()).toBe(false);
expect(findRunnerInstructionsSection().exists()).toBe(false);
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment