Commit 1d45c462 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'andr3-fix-designmanagement-upload-limit' into 'master'

Apply correctly the limit of 10 designs per upload

See merge request gitlab-org/gitlab!18819
parents 2929db33 3fcea2b6
---
title: Apply correctly the limit of 10 designs per upload
merge_request:
author:
type: fixed
......@@ -83,7 +83,7 @@ export default {
onUploadDesign(files) {
if (!this.canCreateDesign) return null;
if (files.length >= MAXIMUM_FILE_UPLOAD_LIMIT) {
if (files.length > MAXIMUM_FILE_UPLOAD_LIMIT) {
createFlash(
sprintf(
s__(
......
import { createLocalVue, shallowMount } from '@vue/test-utils';
import createFlash from '~/flash';
import VueRouter from 'vue-router';
import Index from 'ee/design_management/pages/index.vue';
import uploadDesignQuery from 'ee/design_management/graphql/mutations/uploadDesign.mutation.graphql';
......@@ -16,6 +17,8 @@ const router = new VueRouter({
],
});
jest.mock('~/flash.js');
const mockDesigns = [
{
id: 'design-1',
......@@ -218,6 +221,30 @@ describe('Design management index page', () => {
expect(wrapper.vm.isSaving).toBe(false);
});
});
describe('upload count limit', () => {
const MAXIMUM_FILE_UPLOAD_LIMIT = 10;
afterEach(() => {
createFlash.mockReset();
});
it('doesn not warn when the max files are uploaded', () => {
createComponent();
wrapper.vm.onUploadDesign(new Array(MAXIMUM_FILE_UPLOAD_LIMIT).fill(mockDesigns[0]));
expect(createFlash).not.toHaveBeenCalled();
});
it('warns when too many files are uploaded', () => {
createComponent();
wrapper.vm.onUploadDesign(new Array(MAXIMUM_FILE_UPLOAD_LIMIT + 1).fill(mockDesigns[0]));
expect(createFlash).toHaveBeenCalled();
});
});
});
describe('on latest version', () => {
......
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