## Description **Fixed below flaky tests** - Fork_Template_spec.js - JSOnLoad2_Spec.ts - Omnibar_spec.js - RangeSlider_spec.ts ## Type of change - Flaky test fix ## How Has This Been Tested? - Cypress test runs ## Checklist: ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
110 lines
3.4 KiB
TypeScript
110 lines
3.4 KiB
TypeScript
import { ObjectsRegistry } from "../Objects/Registry";
|
|
|
|
export class PeekOverlay {
|
|
private readonly PEEKABLE_ATTRIBUTE = "peek-data";
|
|
private readonly locators = {
|
|
_overlayContainer: "#t--peek-overlay-container",
|
|
_dataContainer: "#t--peek-overlay-data",
|
|
_peekableCode: (peekableAttr: string) =>
|
|
`[${this.PEEKABLE_ATTRIBUTE}="${peekableAttr}"]`,
|
|
|
|
// 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",
|
|
_fileOperation: (operation: string) =>
|
|
`.t--file-operation:contains("${operation}")`,
|
|
};
|
|
private readonly agHelper = ObjectsRegistry.AggregateHelper;
|
|
|
|
HoverCode(peekableAttribute: string, visibleText?: string) {
|
|
(visibleText
|
|
? this.agHelper.GetNAssertContains(
|
|
this.locators._peekableCode(peekableAttribute),
|
|
visibleText,
|
|
)
|
|
: this.agHelper.GetElement(this.locators._peekableCode(peekableAttribute))
|
|
).realHover();
|
|
this.agHelper.Sleep();
|
|
}
|
|
|
|
IsOverlayOpen(checkIsOpen = true) {
|
|
checkIsOpen
|
|
? this.agHelper.AssertElementExist(this.locators._overlayContainer)
|
|
: this.agHelper.AssertElementAbsence(this.locators._overlayContainer);
|
|
}
|
|
|
|
ResetHover() {
|
|
this.agHelper.GetElement("body").realHover({ position: "bottomLeft" });
|
|
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
|
|
.GetElement(this.locators._overlayContainer)
|
|
.children("div")
|
|
.eq(0)
|
|
.should("have.text", type);
|
|
}
|
|
}
|