* Remove unused CSS rules * Use bootstrap utility class over custom css * Fix grapical bug with buffer tags * Fix internal UI highlighting and misc fixes This commit is a little bit too big. It fixes a bug with the internal UI that was breaking the highlighting feature (indicates status of articles and when an AJAX request has been made). It also does some reformatting in the internal listings UI. This should make it a bit easier on anyone writing buffer updates in the listings UI. I was able to reapply some stimulus I wrote previously for this, super easy! There are also a couple of CSS classes I renamed to match Bootstrap's naming conventions. * Remove <br> tag * Update article_controller Stimulus test
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
import { Application } from 'stimulus';
|
|
import BufferController from '../../controllers/buffer_controller';
|
|
import '../../__mocks__/mutationObserver';
|
|
|
|
describe('BufferController', () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = `<div data-controller="buffer">
|
|
<h2 data-target="buffer.header"></h2>
|
|
<button data-action="buffer#tagBufferUpdateConfirmed"></button>
|
|
<button data-action="buffer#tagBufferUpdateDismissed"></button>
|
|
<button data-action="buffer#highlightElement"></button>
|
|
</div>`;
|
|
|
|
const application = Application.start();
|
|
application.register('buffer', BufferController);
|
|
});
|
|
|
|
describe('#tagBufferUpdateConfirmed', () => {
|
|
it('adds a badge to the header', () => {
|
|
const button = document.querySelectorAll('button')[0];
|
|
const header = document.querySelector('h2');
|
|
|
|
button.click();
|
|
|
|
expect(header.firstChild.textContent).toMatch(/Confirm/);
|
|
});
|
|
});
|
|
|
|
describe('#tagBufferUpdateDismissed', () => {
|
|
it('adds a badge to the header', () => {
|
|
const button = document.querySelectorAll('button')[1];
|
|
const header = document.querySelector('h2');
|
|
|
|
button.click();
|
|
|
|
expect(header.firstChild.textContent).toMatch(/Dismiss/);
|
|
});
|
|
});
|
|
|
|
describe('#highlightElement', () => {
|
|
it('adds a class to the controller element', () => {
|
|
const button = document.querySelectorAll('button')[2];
|
|
const element = document.querySelector("[data-controller='buffer']");
|
|
|
|
button.click();
|
|
|
|
expect(
|
|
element.classList.contains('bg-highlighted', 'border-highlighted'),
|
|
).toBe(true);
|
|
});
|
|
});
|
|
});
|