Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests of "visibility of empty event sources" controls per event layer #632

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import { test, expect } from "@playwright/test";
import { Helioviewer } from "../../../page_objects/helioviewer";
import { mockEvents } from "../../../utils/events";

/**
* This test mocks some random events including some empty event-types
* then validates they are visible eventhough they are not checked
* then toggle empty resource visibility,
* then validates they those empty event-type nodes are not visible anymore
*/
test("Toggle event source visibility should hide/show empty event-type nodes, on off style", async ({
page,
browser
}, info) => {
// mocked event data
const events = {
HEK: {
"Active Region": {
SPoCA: {
"SPoCA 37775": {},
"SPoCA 37776": {}
},
"NOAA SWPC Observer": {
"NOAA 13814": {},
"NOAA 13815": {}
}
},
"Coronal Hole": {
SPoCA: {
"SPoCA 49106": {},
"SPoCA 49144": {}
}
},
"EMPTY EVENT TYPE HEK": {}
},
CCMC: {
DONKI: {
CME: {
"Type:C 11 456km": {}
}
},
"Solar Flare Predictions": {
AMOS: {
"C+ 34.05% M+: 2.82% X: 0%": {},
"C+ 77.15% M+: 9.08% X: 0%": {}
},
"MAG4 Sharp FE": {
"M: 34.05% M+: 2.82% X: 0%": {},
"M: 77.15% M+: 9.08% X: 0%": {}
}
},
"EMPTY EVENT TYPE CCMC": {}
}
};

// mock events
await mockEvents(page, events);

// load helioviewer
let hv = new Helioviewer(page, info);

// Action 1 : BROWSE TO HELIOVIEWER
await hv.Load();
await hv.CloseAllNotifications();

// Action 2 : Open left sources panel
await hv.OpenSidebar();

// Parse event tree pieces
const hek = hv.parseTree("HEK");
const ccmc = hv.parseTree("CCMC");

// Action 3: toggle empty event source visibility for HEK layer
await hek.toggleVisibilityEmptyEventSources();

// Assert empty event types should be visible for ccmc but not for hek
await ccmc.assertEventTypeNodeVisible("EMPTY EVENT TYPE CCMC");
await hek.assertEventTypeNodeNotVisible("EMPTY EVENT TYPE HEK");

// Action 4: now toggle again to make empty event types appear for HEK
await hek.toggleVisibilityEmptyEventSources();
// Action 5: toggle to hide empty event types for CCMC this time
await ccmc.toggleVisibilityEmptyEventSources();

// Assert empty event types should be visible for ccmc but not for not hek
await ccmc.assertEventTypeNodeNotVisible("EMPTY EVENT TYPE CCMC");
await hek.assertEventTypeNodeVisible("EMPTY EVENT TYPE HEK");
});

/**
* This test mocks some random events including some empty event-types
* then validates they are visible eventhough they are not checked
* then toggle empty resource visibility,
* then validates they those empty event-type nodes are not visible anymore
*/
test("Toggle event source visibility should be preserved with state.", async ({ page, browser }, info) => {
// mocked event data
const events = {
HEK: {
"Active Region": {
SPoCA: {
"SPoCA 37775": {},
"SPoCA 37776": {}
},
"NOAA SWPC Observer": {
"NOAA 13814": {},
"NOAA 13815": {}
}
},
"Coronal Hole": {
SPoCA: {
"SPoCA 49106": {},
"SPoCA 49144": {}
}
},
"EMPTY EVENT TYPE HEK": {}
},
CCMC: {
DONKI: {
CME: {
"Type:C 11 456km": {}
}
},
"Solar Flare Predictions": {
AMOS: {
"C+ 34.05% M+: 2.82% X: 0%": {},
"C+ 77.15% M+: 9.08% X: 0%": {}
},
"MAG4 Sharp FE": {
"M: 34.05% M+: 2.82% X: 0%": {},
"M: 77.15% M+: 9.08% X: 0%": {}
}
},
"EMPTY EVENT TYPE CCMC": {}
}
};

// mock events
await mockEvents(page, events);

// load helioviewer
let hv = new Helioviewer(page, info);

// Action 1 : BROWSE TO HELIOVIEWER
await hv.Load();
await hv.CloseAllNotifications();

// Action 2 : Open left sources panel
await hv.OpenSidebar();

// Parse event tree pieces
const hek = hv.parseTree("HEK");
const ccmc = hv.parseTree("CCMC");

// Action 3: toggle to hide empty event-types for CCMC this time
await ccmc.toggleVisibilityEmptyEventSources();

// Assert empty event types should be visible for ccmc but not for not hek
await ccmc.assertEventTypeNodeNotVisible("EMPTY EVENT TYPE CCMC");
await hek.assertEventTypeNodeVisible("EMPTY EVENT TYPE HEK");

await hv.Load();
await hv.CloseAllNotifications();

// Parse event tree pieces
const hekReload = hv.parseTree("HEK");
const ccmcReload = hv.parseTree("CCMC");

await ccmcReload.assertEventTypeNodeNotVisible("EMPTY EVENT TYPE CCMC");
await hekReload.assertEventTypeNodeVisible("EMPTY EVENT TYPE HEK");
});
32 changes: 32 additions & 0 deletions tests/page_objects/event_tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class EventTree {
root: Locator;
markersRoot: Locator;
eventLayerRoot: Locator;
source: string;

constructor(source, page) {
this.page = page;
this.root = page.locator("#tree_" + source);
this.markersRoot = page.locator("#tree_" + source + "-event-container");
this.eventLayerRoot = page.locator("#event-layer-" + source);
this.source = source;
}

/**
Expand Down Expand Up @@ -264,6 +266,14 @@ class EventTree {
await expect(markerLabel).not.toHaveClass("event-label event-label-hover");
}

/**
* This function toggles "hiding of empty event sources" functionality for this event source layer
* @return {Promise<void>} you can await this promise to wait for toggleing to complete
**/
async toggleVisibilityEmptyEventSources(): Promise<void> {
return this.eventLayerRoot.locator("#visibilityAvailableBtn-event-layer-" + this.source).click();
}

/**
* This function triggers "check all" functionality for this event source layer
* "Check all" function turns on all events for this source,
Expand Down Expand Up @@ -380,6 +390,28 @@ class EventTree {
.filter({ has: eventInstanceLink });
await expect(eventInstanceNode).toHaveClass(/jstree-unchecked/);
}

/**
* This function checks if the given event_type node is visible in event tree.
* @param {string} event_type, The event type name pointing to the node in tree (e.g. "Active Region", "Corona Hole").
* @return {Promise<void>} A promise for you to wait for assertion to complete.
*/
async assertEventTypeNodeVisible(event_type: string): Promise<void> {
const eventTypeLink = this.page.getByRole("link", { name: event_type });
const eventTypeNode = await this.root.getByRole("listitem").filter({ has: eventTypeLink });
return expect(eventTypeNode).toBeVisible();
}

/**
* This function checks if the given event_type node is not visible in event tree.
* @param {string} event_type, The event type name pointing to the node in tree (e.g. "Active Region", "Corona Hole").
* @return {Promise<void>} A promise for you to wait for assertion to complete.
*/
async assertEventTypeNodeNotVisible(event_type: string): Promise<void> {
const eventTypeLink = this.page.getByRole("link", { name: event_type });
const eventTypeNode = await this.root.getByRole("listitem").filter({ has: eventTypeLink });
return expect(eventTypeNode).not.toBeVisible();
}
}

export { EventTree };
Loading