Fixes #23057 Fixes #23054 ## Description TL;DR Added support for peeking on nested properties. e.g. `Api1.data[0].id`. This won't work when: - local variables are involved in the expression. e.g. `Api1.data[x].id` won't support peeking at the variable `[x]` or anything after that. - library code is involved e.g. `moment`, `_` etc... - when functions are called. e.g. Api1.data[0].id.toFixed() Because these cases requires evaluation. <img width="355" alt="image" src="https://github.com/appsmithorg/appsmith/assets/66776129/d09d1f0d-1692-46f5-8ec1-592f4fe75f7a"> #### Media (old vs new) https://www.loom.com/share/dedcf113439c4ee2a19028acca54045e ## Performance improvements: - Use AST to identify expressions instead marking text manually. - This reduces the number of markers we process (~ half). - Before  - After  - AST logs https://www.loom.com/share/ddde93233cc8470ea04309d8a8332240 #### Type of change - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) ## Testing > #### How Has This Been Tested? - [x] Manual - [x] Jest - [x] Cypress > > #### Test Plan https://github.com/appsmithorg/TestSmith/issues/2402 #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/23414#issuecomment-1553164908 ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [x] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [x] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [x] Cypress test cases have been added and approved by SDET/manual QA - [x] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
117 lines
3.5 KiB
TypeScript
117 lines
3.5 KiB
TypeScript
import { ObjectsRegistry } from "../Objects/Registry";
|
|
|
|
export class PeekOverlay {
|
|
private readonly locators = {
|
|
_overlayContainer: "#t--peek-overlay-container",
|
|
_dataContainer: "#t--peek-overlay-data",
|
|
|
|
// 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(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 });
|
|
});
|
|
}
|
|
|
|
IsOverlayOpen(checkIsOpen = true) {
|
|
checkIsOpen
|
|
? this.agHelper.AssertElementExist(this.locators._overlayContainer)
|
|
: this.agHelper.AssertElementAbsence(this.locators._overlayContainer);
|
|
}
|
|
|
|
HoverByPosition(position: { x: number; y: number }) {
|
|
this.agHelper.GetElement("body").realHover({ position });
|
|
this.agHelper.Sleep();
|
|
}
|
|
|
|
ResetHover() {
|
|
this.agHelper
|
|
.GetElement(".CodeMirror-code")
|
|
.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);
|
|
}
|
|
}
|