Commit 6b466e38 authored by Luke Bennett's avatar Luke Bennett

Fix bug causing repo mirror settings UI to break

Fixes an exception relating to the new project
cleanup settings in 11.6 that causes the mirror
repo settings UI to become unusable.
parent 1d2ef4c6
export default (buttonSelector, fileSelector) => { export default (buttonSelector, fileSelector) => {
const btn = document.querySelector(buttonSelector); const btn = document.querySelector(buttonSelector);
const fileInput = document.querySelector(fileSelector); const fileInput = document.querySelector(fileSelector);
if (!btn || !fileInput) return;
const form = btn.closest('form'); const form = btn.closest('form');
btn.addEventListener('click', () => { btn.addEventListener('click', () => {
......
---
title: Fix bug causing repository mirror settings UI to break
merge_request: 23712
author:
type: fixed
...@@ -9,7 +9,10 @@ describe('File upload', () => { ...@@ -9,7 +9,10 @@ describe('File upload', () => {
<span class="js-filename"></span> <span class="js-filename"></span>
</form> </form>
`); `);
});
describe('when there is a matching button and input', () => {
beforeEach(() => {
fileUpload('.js-button', '.js-input'); fileUpload('.js-button', '.js-input');
}); });
...@@ -33,4 +36,29 @@ describe('File upload', () => { ...@@ -33,4 +36,29 @@ describe('File upload', () => {
expect(document.querySelector('.js-filename').textContent).toEqual('index.js'); expect(document.querySelector('.js-filename').textContent).toEqual('index.js');
}); });
});
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).not.toHaveBeenCalled();
});
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');
spyOn(input, 'click');
btn.click();
expect(input.click).not.toHaveBeenCalled();
});
}); });
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