2023-03-04 22:38:38 +05:30
|
|
|
import renderObservability from '~/behaviors/markdown/render_observability';
|
|
|
|
import * as ColorUtils from '~/lib/utils/color_utils';
|
|
|
|
|
|
|
|
describe('Observability iframe renderer', () => {
|
|
|
|
const findObservabilityIframes = (theme = 'light') =>
|
|
|
|
document.querySelectorAll(`iframe[src="https://observe.gitlab.com/?theme=${theme}&kiosk"]`);
|
|
|
|
|
|
|
|
const renderEmbeddedObservability = () => {
|
|
|
|
renderObservability([...document.querySelectorAll('.js-render-observability')]);
|
|
|
|
jest.runAllTimers();
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
document.body.dataset.page = '';
|
|
|
|
document.body.innerHTML = '';
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders an observability iframe', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
document.body.innerHTML = `<div class="js-render-observability" data-frame-url="https://observe.gitlab.com/"></div>`;
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
expect(findObservabilityIframes()).toHaveLength(0);
|
|
|
|
|
|
|
|
renderEmbeddedObservability();
|
|
|
|
|
|
|
|
expect(findObservabilityIframes()).toHaveLength(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders iframe with dark param when GL has dark theme', () => {
|
2023-04-23 21:23:45 +05:30
|
|
|
document.body.innerHTML = `<div class="js-render-observability" data-frame-url="https://observe.gitlab.com/"></div>`;
|
2023-03-04 22:38:38 +05:30
|
|
|
jest.spyOn(ColorUtils, 'darkModeEnabled').mockImplementation(() => true);
|
|
|
|
|
|
|
|
expect(findObservabilityIframes('dark')).toHaveLength(0);
|
|
|
|
|
|
|
|
renderEmbeddedObservability();
|
|
|
|
|
|
|
|
expect(findObservabilityIframes('dark')).toHaveLength(1);
|
|
|
|
});
|
|
|
|
});
|