2022-10-20 12:08:48 +00:00
|
|
|
import { ObjectsRegistry } from "../Objects/Registry";
|
|
|
|
|
|
|
|
|
|
export enum PageType {
|
|
|
|
|
Canvas,
|
|
|
|
|
API,
|
|
|
|
|
Query,
|
|
|
|
|
JsEditor,
|
2023-04-10 12:59:14 +00:00
|
|
|
DataSources,
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class DebuggerHelper {
|
|
|
|
|
private agHelper = ObjectsRegistry.AggregateHelper;
|
|
|
|
|
private commonLocators = ObjectsRegistry.CommonLocators;
|
|
|
|
|
|
|
|
|
|
// ActionExecutionResizerHeight -> in repo
|
2023-05-19 18:37:06 +00:00
|
|
|
private readonly bottomPaneHeight = 360;
|
2022-10-20 12:08:48 +00:00
|
|
|
// from design system
|
|
|
|
|
private readonly TAB_MIN_HEIGHT = 36;
|
|
|
|
|
|
|
|
|
|
public readonly locators = {
|
2023-05-19 18:37:06 +00:00
|
|
|
_debuggerIcon: ".t--debugger-count",
|
|
|
|
|
_debuggerToggle: "[data-testid=t--debugger-toggle]",
|
|
|
|
|
_debuggerDownStreamErrMsg: "[data-testid=t--debugger-downStreamErrorMsg]",
|
2022-10-20 12:08:48 +00:00
|
|
|
_tabsContainer: ".t--debugger-tabs-container",
|
|
|
|
|
_closeButton: ".t--close-debugger",
|
|
|
|
|
_logMessage: ".t--debugger-log-message",
|
2023-02-06 07:38:09 +00:00
|
|
|
_logEntityLink: ".t--debugger-log-entity-link",
|
2022-10-20 12:08:48 +00:00
|
|
|
_logState: ".t--debugger-log-state",
|
|
|
|
|
_errorCount: ".t--debugger-count",
|
|
|
|
|
_clearLogs: ".t--debugger-clear-logs",
|
|
|
|
|
_logMessageOccurence: ".t--debugger-log-message-occurence",
|
2023-05-19 18:37:06 +00:00
|
|
|
_debuggerMessage: "[data-testid=t--debugger-log-message]",
|
2023-02-18 12:55:46 +00:00
|
|
|
_contextMenuIcon: ".t--debugger-contextual-error-menu ",
|
2022-10-20 12:08:48 +00:00
|
|
|
_contextMenuItem: ".t--debugger-contextual-menuitem",
|
|
|
|
|
_debuggerLabel: "span.debugger-label",
|
|
|
|
|
_bottomPaneContainer: {
|
|
|
|
|
[PageType.API]: ".t--api-bottom-pane-container",
|
|
|
|
|
[PageType.Query]: ".t--query-bottom-pane-container",
|
|
|
|
|
[PageType.JsEditor]: ".t--js-editor-bottom-pane-container",
|
2023-04-10 12:59:14 +00:00
|
|
|
[PageType.DataSources]: ".t--datasource-bottom-pane-container",
|
2022-10-20 12:08:48 +00:00
|
|
|
},
|
|
|
|
|
_debuggerList: ".debugger-list",
|
2023-05-19 18:37:06 +00:00
|
|
|
_debuggerFilter: "input[data-testid=t--debugger-search]",
|
|
|
|
|
_debuggerSelectedTab: ".ads-v2-tabs__list-tab",
|
2023-06-01 14:06:57 +00:00
|
|
|
_helpButton: "[data-testid='t--help-button']",
|
|
|
|
|
_intercomOption: "#intercom-trigger",
|
|
|
|
|
_intercomConsentText: "[data-testid='t--intercom-consent-text']",
|
2022-10-20 12:08:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ClickDebuggerIcon(
|
|
|
|
|
index?: number,
|
|
|
|
|
force?: boolean,
|
|
|
|
|
waitTimeInterval?: number,
|
|
|
|
|
) {
|
|
|
|
|
this.agHelper.GetNClick(
|
|
|
|
|
this.locators._debuggerIcon,
|
|
|
|
|
index,
|
|
|
|
|
force,
|
|
|
|
|
waitTimeInterval,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-18 12:55:46 +00:00
|
|
|
ClickDebuggerToggle(expand = true, index = 0) {
|
|
|
|
|
cy.get(this.locators._debuggerToggle)
|
|
|
|
|
.eq(index)
|
2023-05-19 18:37:06 +00:00
|
|
|
.invoke("attr", "data-isopen")
|
2023-02-18 12:55:46 +00:00
|
|
|
.then((arrow) => {
|
|
|
|
|
if (expand && arrow == "false")
|
|
|
|
|
cy.get(this.locators._debuggerToggle)
|
|
|
|
|
.eq(index)
|
|
|
|
|
.trigger("click", { multiple: true })
|
|
|
|
|
.wait(1000);
|
|
|
|
|
else if (!expand && arrow == "true")
|
|
|
|
|
cy.get(this.locators._debuggerToggle)
|
|
|
|
|
.eq(index)
|
|
|
|
|
.trigger("click", { multiple: true })
|
|
|
|
|
.wait(1000);
|
|
|
|
|
else this.agHelper.Sleep(500);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
ClickResponseTab() {
|
|
|
|
|
this.agHelper.GetNClick(this.commonLocators._responseTab);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 12:59:14 +00:00
|
|
|
CloseBottomBar() {
|
|
|
|
|
this.agHelper.GetNClick(this.locators._closeButton);
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssertOpen(pageType: PageType) {
|
|
|
|
|
switch (pageType) {
|
|
|
|
|
case PageType.Canvas:
|
|
|
|
|
this.agHelper.AssertElementExist(this.locators._tabsContainer);
|
|
|
|
|
break;
|
|
|
|
|
case PageType.API:
|
|
|
|
|
case PageType.JsEditor:
|
|
|
|
|
case PageType.Query:
|
2023-04-10 12:59:14 +00:00
|
|
|
case PageType.DataSources:
|
2023-05-24 12:30:39 +00:00
|
|
|
this.agHelper.AssertElementVisible(
|
2022-10-20 12:08:48 +00:00
|
|
|
this.locators._bottomPaneContainer[pageType],
|
|
|
|
|
);
|
2023-05-24 12:30:39 +00:00
|
|
|
// this.agHelper.AssertHeight(
|
|
|
|
|
// this.locators._bottomPaneContainer[pageType],
|
|
|
|
|
// this.bottomPaneHeight,
|
|
|
|
|
// );
|
2022-10-20 12:08:48 +00:00
|
|
|
break;
|
2023-05-24 12:30:39 +00:00
|
|
|
// case PageType.Query:
|
|
|
|
|
// case PageType.DataSources:
|
|
|
|
|
// this.agHelper.AssertElementVisible(
|
|
|
|
|
// this.locators._bottomPaneContainer[pageType],
|
|
|
|
|
// );
|
|
|
|
|
// // this.agHelper.AssertHeight(
|
|
|
|
|
// // this.locators._bottomPaneContainer[pageType],
|
|
|
|
|
// // this.bottomPaneHeight - 1, // -1 to offset error
|
|
|
|
|
// // );
|
|
|
|
|
// break;
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-10 12:59:14 +00:00
|
|
|
AssertClosed() {
|
|
|
|
|
this.agHelper.AssertElementAbsence(this.locators._tabsContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssertSelectedTab(text: string) {
|
|
|
|
|
this.agHelper.GetNAssertContains(this.locators._debuggerSelectedTab, text);
|
2023-05-19 18:37:06 +00:00
|
|
|
this.agHelper.AssertSelectedTab(this.locators._debuggerSelectedTab, "true");
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DoesConsoleLogExist(
|
|
|
|
|
text: string,
|
|
|
|
|
exists = true,
|
|
|
|
|
index?: number,
|
|
|
|
|
timeout?: number,
|
|
|
|
|
) {
|
|
|
|
|
this.agHelper.GetNAssertContains(
|
|
|
|
|
this.locators._logMessage,
|
|
|
|
|
text,
|
|
|
|
|
exists ? "exist" : "not.exist",
|
|
|
|
|
index,
|
|
|
|
|
timeout,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-19 18:37:06 +00:00
|
|
|
DebuggerLogsFilter(text: string) {
|
2023-02-11 18:33:20 +00:00
|
|
|
this.agHelper.RemoveCharsNType(this.locators._debuggerFilter, -1, text);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
LogStateContains(text: string, index?: number) {
|
|
|
|
|
this.agHelper.GetNAssertContains(
|
|
|
|
|
this.locators._logState,
|
|
|
|
|
text,
|
|
|
|
|
"exist",
|
|
|
|
|
index,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssertErrorCount(count: number) {
|
2023-04-10 12:59:14 +00:00
|
|
|
this.agHelper.GetNAssertContains(this.locators._errorCount, count);
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClearLogs() {
|
|
|
|
|
this.agHelper.GetNClick(this.locators._clearLogs);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-17 10:25:37 +00:00
|
|
|
AssertConsecutiveConsoleLogCount(count: number) {
|
2022-10-20 12:08:48 +00:00
|
|
|
count > 0
|
|
|
|
|
? this.agHelper.GetNAssertContains(
|
|
|
|
|
this.locators._logMessageOccurence,
|
|
|
|
|
count,
|
|
|
|
|
)
|
|
|
|
|
: this.agHelper.AssertElementAbsence(this.locators._logMessageOccurence);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssertVisibleErrorMessagesCount(count: number) {
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
this.agHelper.AssertElementVisible(this.locators._debuggerMessage);
|
|
|
|
|
this.agHelper.AssertElementLength(this.locators._debuggerMessage, count);
|
|
|
|
|
} else {
|
|
|
|
|
this.agHelper.AssertElementAbsence(this.locators._debuggerMessage);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ClickErrorMessage(index?: number) {
|
|
|
|
|
this.agHelper.GetNClick(this.locators._debuggerMessage, index);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 07:38:09 +00:00
|
|
|
ClicklogEntityLink(index?: number) {
|
|
|
|
|
this.agHelper.GetNClick(this.locators._logEntityLink, index);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
AssertContextMenuItemVisible() {
|
|
|
|
|
this.agHelper.AssertElementVisible(this.locators._contextMenuItem);
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-21 04:27:56 +00:00
|
|
|
AssertDebugError(
|
|
|
|
|
label: string,
|
|
|
|
|
message: string,
|
|
|
|
|
shouldOpenDebugger = true,
|
|
|
|
|
shouldToggleDebugger = true,
|
|
|
|
|
) {
|
|
|
|
|
if (shouldOpenDebugger) {
|
|
|
|
|
this.ClickDebuggerIcon();
|
|
|
|
|
}
|
2022-10-20 12:08:48 +00:00
|
|
|
this.agHelper.GetNClick(this.commonLocators._errorTab, 0, true, 0);
|
2023-02-21 04:27:56 +00:00
|
|
|
|
|
|
|
|
if (shouldToggleDebugger) {
|
|
|
|
|
this.ClickDebuggerToggle();
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-20 12:08:48 +00:00
|
|
|
this.agHelper
|
|
|
|
|
.GetText(this.locators._debuggerLabel, "text", 0)
|
|
|
|
|
.then(($text) => {
|
|
|
|
|
expect($text).to.eq(label);
|
|
|
|
|
});
|
2023-02-21 04:27:56 +00:00
|
|
|
|
|
|
|
|
if (message) {
|
|
|
|
|
this.agHelper
|
|
|
|
|
.GetText(this.locators._debuggerDownStreamErrMsg, "text", 0)
|
|
|
|
|
.then(($text) => {
|
|
|
|
|
expect($text).to.contains(message);
|
|
|
|
|
});
|
|
|
|
|
}
|
2022-10-20 12:08:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DebuggerListDoesnotContain(text: string) {
|
|
|
|
|
this.agHelper.AssertContains(
|
|
|
|
|
text,
|
|
|
|
|
"not.exist",
|
|
|
|
|
this.locators._debuggerList,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|