-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Adding tests for custom library
- Loading branch information
“NandanAnantharamu”
committed
Dec 2, 2024
1 parent
eb88d9b
commit a2a2ed2
Showing
2 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
129 changes: 129 additions & 0 deletions
129
app/client/cypress/e2e/Regression/ClientSide/JSLibrary/Custom_library_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { | ||
agHelper, | ||
entityExplorer, | ||
jsEditor, | ||
deployMode, | ||
installer, | ||
draggableWidgets, | ||
propPane, | ||
locators, | ||
apiPage, | ||
table, | ||
} from "../../../../support/Objects/ObjectsCore"; | ||
import EditorNavigation, { | ||
AppSidebar, | ||
AppSidebarButton, | ||
EntityType, | ||
} from "../../../../support/Pages/EditorNavigation"; | ||
|
||
describe( | ||
"Tests JS Libraries", | ||
{ tags: ["@tag.excludeForAirgap", "@tag.JS", "@tag.Binding"] }, | ||
() => { | ||
before(() => { | ||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.BUTTON, 500, 100); | ||
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TABLE, 200, 200); | ||
apiPage.CreateAndFillApi( | ||
"http://host.docker.internal:5001/v1/mock-api?records=5", | ||
); | ||
apiPage.RunAPI(); | ||
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget); | ||
propPane.EnterJSContext("tabledata", `{{Api1.data}}`, true, false); | ||
}); | ||
|
||
it("1. Verify moment library", () => { | ||
jsEditor.CreateJSObject(`showAlert(moment().daysInMonth().toString())`, { | ||
paste: true, | ||
completeReplace: false, | ||
toRun: true, | ||
shouldCreateNewJSObj: true, | ||
prettify: true, | ||
}); | ||
|
||
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget); | ||
propPane.EnterJSContext( | ||
"onClick", | ||
`{{JSObject1.myFun1();}}`, | ||
true, | ||
false, | ||
); | ||
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
agHelper.WaitUntilAllToastsDisappear(); | ||
|
||
// Deploy | ||
// deployMode.DeployApp(); | ||
// agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
// agHelper.WaitUntilAllToastsDisappear(); | ||
// deployMode.NavigateBacktoEditor(); | ||
}); | ||
|
||
it("2. Verify install/uninstall of Library ", () => { | ||
AppSidebar.navigate(AppSidebarButton.Libraries); | ||
installer.OpenInstaller(); | ||
installer.InstallLibraryViaURL( | ||
"https://cdn.jsdelivr.net/npm/swiper@11.1.14/+esm", | ||
"swiper", | ||
); | ||
agHelper.WaitUntilAllToastsDisappear(); | ||
installer.uninstallLibrary("swiper"); | ||
installer.assertUnInstall("swiper"); | ||
}); | ||
|
||
it("3. Verify jspdf library", () => { | ||
AppSidebar.navigate(AppSidebarButton.Libraries); | ||
installer.OpenInstaller(); | ||
installer.InstallLibrary("jspdf", "jspdf"); | ||
jsEditor.CreateJSObject( | ||
`export default { | ||
genPDF: () => { | ||
const doc = new jspdf.jsPDF(); | ||
doc.text('Users', 20, 20); | ||
doc.table(20, 30, Table1.tableData, Table1.columnOrder, {autoSize: true}); | ||
download(doc.output(), 'users_list.pdf'); | ||
} | ||
}`, | ||
{ | ||
paste: true, | ||
completeReplace: true, | ||
toRun: false, | ||
shouldCreateNewJSObj: true, | ||
prettify: true, | ||
}, | ||
); | ||
|
||
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget); | ||
propPane.EnterJSContext( | ||
"onClick", | ||
`{{JSObject2.genPDF();}}`, | ||
true, | ||
false, | ||
); | ||
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
table.ValidateDownloadNVerify("users_list.pdf"); | ||
|
||
// Deploy | ||
// deployMode.DeployApp(); | ||
// agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
// table.ValidateDownloadNVerify("users_list.pdf"); | ||
// deployMode.NavigateBacktoEditor(); | ||
}); | ||
|
||
it("4. Verify deleting jspdf library deletes all its references as well", () => { | ||
AppSidebar.navigate(AppSidebarButton.Libraries); | ||
installer.uninstallLibrary("jspdf"); | ||
installer.assertUnInstall("jspdf"); | ||
|
||
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget); | ||
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
agHelper.ValidateToastMessage("jspdf is not defined"); | ||
|
||
// Install jspdf and verify references are working | ||
AppSidebar.navigate(AppSidebarButton.Libraries); | ||
installer.OpenInstaller(); | ||
installer.InstallLibrary("jspdf", "jspdf"); | ||
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget); | ||
agHelper.GetNClick(locators._widgetInDeployed("buttonwidget")); | ||
table.ValidateDownloadNVerify("users_list.pdf"); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters