Skip to content
Snippets Groups Projects
Commit 1f9a9629 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett Committed by Phil Hughes
Browse files

Fix clicking disabled clipboard button toolip

parent a3eabcc2
No related branches found
No related tags found
1 merge request!12073Add RC2 changes to 9-3-stable
Loading
Loading
@@ -50,9 +50,9 @@ export default class BlobViewer {
 
if (this.copySourceBtn) {
this.copySourceBtn.addEventListener('click', () => {
if (this.copySourceBtn.classList.contains('disabled')) return;
if (this.copySourceBtn.classList.contains('disabled')) return this.copySourceBtn.blur();
 
this.switchToViewer('simple');
return this.switchToViewer('simple');
});
}
}
Loading
Loading
Loading
Loading
@@ -83,25 +83,48 @@ describe('Blob viewer', () => {
});
 
describe('copy blob button', () => {
let copyButton;
beforeEach(() => {
copyButton = document.querySelector('.js-copy-blob-source-btn');
});
it('disabled on load', () => {
expect(
document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'),
copyButton.classList.contains('disabled'),
).toBeTruthy();
});
 
it('has tooltip when disabled', () => {
expect(
document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'),
copyButton.getAttribute('data-original-title'),
).toBe('Switch to the source to copy it to the clipboard');
});
 
it('is blurred when clicked and disabled', () => {
spyOn(copyButton, 'blur');
copyButton.click();
expect(copyButton.blur).toHaveBeenCalled();
});
it('is not blurred when clicked and not disabled', () => {
spyOn(copyButton, 'blur');
copyButton.classList.remove('disabled');
copyButton.click();
expect(copyButton.blur).not.toHaveBeenCalled();
});
it('enables after switching to simple view', (done) => {
document.querySelector('.js-blob-viewer-switch-btn[data-viewer="simple"]').click();
 
setTimeout(() => {
expect($.ajax).toHaveBeenCalled();
expect(
document.querySelector('.js-copy-blob-source-btn').classList.contains('disabled'),
copyButton.classList.contains('disabled'),
).toBeFalsy();
 
done();
Loading
Loading
@@ -115,7 +138,7 @@ describe('Blob viewer', () => {
expect($.ajax).toHaveBeenCalled();
 
expect(
document.querySelector('.js-copy-blob-source-btn').getAttribute('data-original-title'),
copyButton.getAttribute('data-original-title'),
).toBe('Copy source to clipboard');
 
done();
Loading
Loading
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