提交 04131663 编写于 作者: N Nick Thomas

Merge branch 'fix-repo-settings-file-upload-error' into 'master'

Fix bug causing repository mirror settings UI to break

Closes #55134

See merge request gitlab-org/gitlab-ce!23712
export default (buttonSelector, fileSelector) => {
const btn = document.querySelector(buttonSelector);
const fileInput = document.querySelector(fileSelector);
if (!btn || !fileInput) return;
const form = btn.closest('form');
btn.addEventListener('click', () => {
......
---
title: Fix bug causing repository mirror settings UI to break
merge_request: 23712
author:
type: fixed
......@@ -9,28 +9,56 @@ describe('File upload', () => {
<span class="js-filename"></span>
</form>
`);
});
describe('when there is a matching button and input', () => {
beforeEach(() => {
fileUpload('.js-button', '.js-input');
});
it('clicks file input after clicking button', () => {
const btn = document.querySelector('.js-button');
const input = document.querySelector('.js-input');
spyOn(input, 'click');
btn.click();
expect(input.click).toHaveBeenCalled();
});
it('updates file name text', () => {
const input = document.querySelector('.js-input');
fileUpload('.js-button', '.js-input');
input.value = 'path/to/file/index.js';
input.dispatchEvent(new CustomEvent('change'));
expect(document.querySelector('.js-filename').textContent).toEqual('index.js');
});
});
it('clicks file input after clicking button', () => {
const btn = document.querySelector('.js-button');
it('fails gracefully when there is no matching button', () => {
const input = document.querySelector('.js-input');
const btn = document.querySelector('.js-button');
fileUpload('.js-not-button', '.js-input');
spyOn(input, 'click');
btn.click();
expect(input.click).toHaveBeenCalled();
expect(input.click).not.toHaveBeenCalled();
});
it('updates file name text', () => {
it('fails gracefully when there is no matching input', () => {
const input = document.querySelector('.js-input');
const btn = document.querySelector('.js-button');
fileUpload('.js-button', '.js-not-input');
input.value = 'path/to/file/index.js';
spyOn(input, 'click');
input.dispatchEvent(new CustomEvent('change'));
btn.click();
expect(document.querySelector('.js-filename').textContent).toEqual('index.js');
expect(input.click).not.toHaveBeenCalled();
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册