mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
[Testing] [Notebook] fix failing notebook tests from three-dot-menu-proto (#3577)
This commit is contained in:
@ -20,7 +20,7 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
import { createOpenMct, resetApplicationState } from 'utils/testing';
|
import { createOpenMct, createMouseEvent, resetApplicationState } from 'utils/testing';
|
||||||
import NotebookPlugin from './plugin';
|
import NotebookPlugin from './plugin';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
|
||||||
@ -133,4 +133,89 @@ describe("Notebook plugin:", () => {
|
|||||||
expect(hasMajorElements).toBe(true);
|
expect(hasMajorElements).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Notebook Snapshots view:", () => {
|
||||||
|
let snapshotIndicator;
|
||||||
|
let drawerElement;
|
||||||
|
|
||||||
|
function clickSnapshotIndicator() {
|
||||||
|
const indicator = element.querySelector('.icon-camera');
|
||||||
|
const button = indicator.querySelector('button');
|
||||||
|
const clickEvent = createMouseEvent('click');
|
||||||
|
|
||||||
|
button.dispatchEvent(clickEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
snapshotIndicator = openmct.indicators.indicatorObjects
|
||||||
|
.find(indicator => indicator.key === 'notebook-snapshot-indicator').element;
|
||||||
|
|
||||||
|
element.append(snapshotIndicator);
|
||||||
|
|
||||||
|
return Vue.nextTick();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
snapshotIndicator.remove();
|
||||||
|
snapshotIndicator = undefined;
|
||||||
|
|
||||||
|
if (drawerElement) {
|
||||||
|
drawerElement.remove();
|
||||||
|
drawerElement = undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
drawerElement = document.querySelector('.l-shell__drawer');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (drawerElement) {
|
||||||
|
drawerElement.classList.remove('is-expanded');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("has Snapshots indicator", () => {
|
||||||
|
const hasSnapshotIndicator = snapshotIndicator !== null && snapshotIndicator !== undefined;
|
||||||
|
expect(hasSnapshotIndicator).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("snapshots container has class isExpanded", () => {
|
||||||
|
let classes = drawerElement.classList;
|
||||||
|
const isExpandedBefore = classes.contains('is-expanded');
|
||||||
|
|
||||||
|
clickSnapshotIndicator();
|
||||||
|
classes = drawerElement.classList;
|
||||||
|
const isExpandedAfterFirstClick = classes.contains('is-expanded');
|
||||||
|
|
||||||
|
expect(isExpandedBefore).toBeFalse();
|
||||||
|
expect(isExpandedAfterFirstClick).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("snapshots container does not have class isExpanded", () => {
|
||||||
|
let classes = drawerElement.classList;
|
||||||
|
const isExpandedBefore = classes.contains('is-expanded');
|
||||||
|
|
||||||
|
clickSnapshotIndicator();
|
||||||
|
classes = drawerElement.classList;
|
||||||
|
const isExpandedAfterFirstClick = classes.contains('is-expanded');
|
||||||
|
|
||||||
|
clickSnapshotIndicator();
|
||||||
|
classes = drawerElement.classList;
|
||||||
|
const isExpandedAfterSecondClick = classes.contains('is-expanded');
|
||||||
|
|
||||||
|
expect(isExpandedBefore).toBeFalse();
|
||||||
|
expect(isExpandedAfterFirstClick).toBeTrue();
|
||||||
|
expect(isExpandedAfterSecondClick).toBeFalse();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("show notebook snapshots container text", () => {
|
||||||
|
clickSnapshotIndicator();
|
||||||
|
|
||||||
|
const notebookSnapshots = drawerElement.querySelector('.l-browse-bar__object-name');
|
||||||
|
const snapshotsText = notebookSnapshots.textContent.trim();
|
||||||
|
|
||||||
|
expect(snapshotsText).toBe('Notebook Snapshots');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user