-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
test: adding tests for JsObjects regression #38103
Changes from all commits
291e1d0
4006635
22c8b62
4000628
bef8061
1cf2727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import HomePage from "../../../../locators/HomePage"; | ||
import { | ||
agHelper, | ||
entityExplorer, | ||
jsEditor, | ||
propPane, | ||
draggableWidgets, | ||
locators, | ||
} from "../../../../support/ee/ObjectsCore_EE"; | ||
import EditorNavigation, { | ||
PageLeftPane, | ||
PagePaneSegment, | ||
} from "../../../../support/Pages/EditorNavigation"; | ||
import PageList from "../../../../support/Pages/PageList"; | ||
|
||
describe("Validate JSObj", {}, () => { | ||
before(() => {}); | ||
|
||
it("1. Verify adding JSObject and more actions options", () => { | ||
jsEditor.CreateJSObject( | ||
`setInterval(() => { | ||
showAlert("Hi", "error") | ||
}, 2500, "Int")`, | ||
{ | ||
paste: true, | ||
completeReplace: false, | ||
toRun: true, | ||
shouldCreateNewJSObj: true, | ||
}, | ||
); | ||
jsEditor.EnableDisableAsyncFuncSettings("myFun1"); | ||
|
||
// Add new JSObject | ||
PageList.AddNewPage("New blank page"); | ||
PageLeftPane.switchSegment(PagePaneSegment.JS); | ||
agHelper.GetNClick(locators._createNew); | ||
agHelper.GetNClick(jsEditor._addJSObj); | ||
agHelper.AssertContains("JSObject2", "exist", ".t--entity-name"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use data-testid attributes instead of class selectors Using class selectors (.t--entity-name) is against the provided coding guidelines. Use data-testid attributes instead. -agHelper.AssertContains("JSObject2", "exist", ".t--entity-name");
+agHelper.AssertContains("JSObject2", "exist", "[data-testid='entity-name']");
-agHelper.AssertContains("JSObject3", "exist", ".t--entity-name");
+agHelper.AssertContains("JSObject3", "exist", "[data-testid='entity-name']"); Also applies to: 43-43 |
||
agHelper.GetNClick(EditorNavigation.locators.MinimizeBtn); | ||
EditorNavigation.CloseAnnouncementModal(); | ||
agHelper.GetNClick(jsEditor._addJSObj); | ||
agHelper.GetNClick(EditorNavigation.locators.MaximizeBtn); | ||
agHelper.AssertContains("JSObject3", "exist", ".t--entity-name"); | ||
|
||
// Verify menu item | ||
agHelper.GetNClick(jsEditor._jsPageActions, 0, true); | ||
agHelper.AssertContains("Rename", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Show bindings", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Copy to page", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Move to page", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Delete", "exist", HomePage.portalMenuItem); | ||
|
||
agHelper.GetNClick(jsEditor._moreActions, 0, true); | ||
agHelper.AssertContains("Rename", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Copy to page", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Move to page", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Prettify code", "exist", HomePage.portalMenuItem); | ||
agHelper.AssertContains("Delete", "exist", HomePage.portalMenuItem); | ||
}); | ||
|
||
it("2. Verify alert message on page load", () => { | ||
// Verify alert message on page load | ||
EditorNavigation.NavigateToPage("Page1", true); | ||
agHelper.ValidateToastMessage("Hi"); | ||
}); | ||
Comment on lines
+61
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve test reliability by removing implicit waits The test relies on the alert message appearing after page navigation. Consider using Cypress's built-in retry-ability instead of implicit waits: -EditorNavigation.NavigateToPage("Page1", true);
-agHelper.ValidateToastMessage("Hi");
+EditorNavigation.NavigateToPage("Page1", true);
+agHelper.WaitUntilToastMessageAppears("Hi");
|
||
|
||
it("3. Verify moving JSObject to new page", () => { | ||
// Verify Move to Page | ||
agHelper.GetNClick(jsEditor._jsPageActions, 0, true); | ||
agHelper.HoverElement( | ||
`${HomePage.portalMenuItem}:contains("Move to page")`, | ||
); | ||
agHelper.GetNClick(`${HomePage.portalMenuItem}:contains("Page2")`); | ||
Comment on lines
+70
to
+73
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace string selectors with data attributes Using string concatenation and CSS contains selectors is against best practices. Use data-testid attributes instead. -agHelper.HoverElement(
- `${HomePage.portalMenuItem}:contains("Move to page")`,
-);
-agHelper.GetNClick(`${HomePage.portalMenuItem}:contains("Page2")`);
+agHelper.HoverElement("[data-testid='move-to-page-menu-item']");
+agHelper.GetNClick("[data-testid='page2-menu-item']");
-agHelper.GetNClick(`.t--entity-name:contains("JSObject11")`);
+agHelper.GetNClick("[data-testid='js-object-11']"); Also applies to: 76-76 |
||
|
||
// Verify 'Run on page load' on new page | ||
agHelper.GetNClick(`.t--entity-name:contains("JSObject11")`); | ||
jsEditor.VerifyAsyncFuncSettings("myFun1"); | ||
}); | ||
|
||
it("4. Verify JSObject binding", () => { | ||
PageLeftPane.switchSegment(PagePaneSegment.UI); | ||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON, 500, 100); | ||
propPane.EnterJSContext("onClick", "{{JSObject11.myFun1();}}", true, false); | ||
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
agHelper.ValidateToastMessage("Hi"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -32,7 +32,7 @@ export class JSEditor { | |||||||||||||
public ee = ObjectsRegistry.EntityExplorer; | ||||||||||||||
public propPane = ObjectsRegistry.PropertyPane; | ||||||||||||||
private assertHelper = ObjectsRegistry.AssertHelper; | ||||||||||||||
public runButtonLocator = "[data-testid='t--run-js-action']"; | ||||||||||||||
public runButtonLocator = ".run-js-action"; | ||||||||||||||
public settingsTriggerLocator = "[data-testid='t--js-settings-trigger']"; | ||||||||||||||
public contextMenuTriggerLocator = "[data-testid='t--more-action-trigger']"; | ||||||||||||||
public runFunctionSelectLocator = "[data-testid='t--js-function-run']"; | ||||||||||||||
|
@@ -89,6 +89,9 @@ export class JSEditor { | |||||||||||||
"//div[@data-testid='t--query-run-confirmation-modal']//span[text()='" + | ||||||||||||||
text + | ||||||||||||||
"']"; | ||||||||||||||
_addJSObj = '[data-testid="t--ide-tabs-add-button"]'; | ||||||||||||||
_jsPageActions = ".entity-context-menu"; | ||||||||||||||
_moreActions = '[data-testid="t--more-action-trigger"]'; | ||||||||||||||
Comment on lines
+92
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use data-testid instead of class selector The Apply this diff: _addJSObj = '[data-testid="t--ide-tabs-add-button"]';
- _jsPageActions = ".entity-context-menu";
+ _jsPageActions = '[data-testid="t--entity-context-menu"]';
_moreActions = '[data-testid="t--more-action-trigger"]'; 📝 Committable suggestion
Suggested change
|
||||||||||||||
//#endregion | ||||||||||||||
|
||||||||||||||
//#region constants | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove empty before hook
The empty before hook serves no purpose and should be removed as per best practices.
📝 Committable suggestion