2023-02-17 16:03:34 +00:00
|
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
|
|
|
|
|
|
|
|
|
export class PeekOverlay {
|
|
|
|
|
private readonly locators = {
|
|
|
|
|
_overlayContainer: "#t--peek-overlay-container",
|
|
|
|
|
_dataContainer: "#t--peek-overlay-data",
|
2025-02-14 16:27:08 +00:00
|
|
|
_dataTypeContainer: '[data-testid="t--peek-overlay-data-type"]',
|
2023-02-17 16:03:34 +00:00
|
|
|
|
|
|
|
|
// react json viewer selectors
|
|
|
|
|
_rjv_variableValue: ".variable-value",
|
|
|
|
|
_rjv_topLevelArrayData:
|
|
|
|
|
".pushed-content.object-container .object-content .object-key-val",
|
|
|
|
|
_rjv_firstLevelBraces:
|
|
|
|
|
".pretty-json-container > .object-content:first-of-type > .object-key-val:first-of-type > span",
|
2023-05-11 07:31:13 +00:00
|
|
|
_fileOperation: (operation: string) =>
|
|
|
|
|
`.t--file-operation:contains("${operation}")`,
|
2023-02-17 16:03:34 +00:00
|
|
|
};
|
|
|
|
|
private readonly agHelper = ObjectsRegistry.AggregateHelper;
|
|
|
|
|
|
2023-05-26 11:42:10 +00:00
|
|
|
HoverCode(lineNumber: number, tokenNumber: number, verifyText: string) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(".CodeMirror-line")
|
|
|
|
|
.eq(lineNumber)
|
|
|
|
|
.children()
|
|
|
|
|
.children()
|
|
|
|
|
.eq(tokenNumber)
|
|
|
|
|
.should("have.text", verifyText)
|
|
|
|
|
.then(($el) => {
|
|
|
|
|
const pos = $el[0].getBoundingClientRect();
|
|
|
|
|
this.HoverByPosition({ x: pos.left, y: pos.top });
|
|
|
|
|
});
|
2023-02-17 16:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IsOverlayOpen(checkIsOpen = true) {
|
|
|
|
|
checkIsOpen
|
|
|
|
|
? this.agHelper.AssertElementExist(this.locators._overlayContainer)
|
|
|
|
|
: this.agHelper.AssertElementAbsence(this.locators._overlayContainer);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-26 11:42:10 +00:00
|
|
|
HoverByPosition(position: { x: number; y: number }) {
|
|
|
|
|
this.agHelper.GetElement("body").realHover({ position });
|
|
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-17 16:03:34 +00:00
|
|
|
ResetHover() {
|
2023-05-26 11:42:10 +00:00
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(".CodeMirror-code")
|
|
|
|
|
.realHover({ position: "bottomLeft" });
|
2023-02-17 16:03:34 +00:00
|
|
|
this.agHelper.Sleep();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CheckPrimitiveValue(data: string) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.children("div")
|
|
|
|
|
.should("have.text", data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CheckPrimitveArrayInOverlay(array: Array<string | number>) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_variableValue)
|
|
|
|
|
.should("have.length", array.length);
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(0)
|
|
|
|
|
.contains("[");
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(1)
|
|
|
|
|
.contains("]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CheckObjectArrayInOverlay(array: Array<Record<string, any>>) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_topLevelArrayData)
|
|
|
|
|
.should("have.length", array.length);
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(0)
|
|
|
|
|
.contains("[");
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(1)
|
|
|
|
|
.contains("]");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CheckBasicObjectInOverlay(object: Record<string, string | number>) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_variableValue)
|
|
|
|
|
.should("have.length", Object.entries(object).length);
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(0)
|
|
|
|
|
.contains("{");
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetElement(this.locators._dataContainer)
|
|
|
|
|
.find(this.locators._rjv_firstLevelBraces)
|
|
|
|
|
.eq(1)
|
|
|
|
|
.contains("}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VerifyDataType(type: string) {
|
|
|
|
|
this.agHelper
|
2025-02-14 16:27:08 +00:00
|
|
|
.GetElement(this.locators._dataTypeContainer)
|
2023-02-17 16:03:34 +00:00
|
|
|
.eq(0)
|
|
|
|
|
.should("have.text", type);
|
|
|
|
|
}
|
|
|
|
|
}
|