-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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/custom lib tests #37900
Test/custom lib tests #37900
Changes from all commits
8c9026c
5c0764d
528cd01
6cfcddb
6059c5f
7e5ecde
eb88d9b
a2a2ed2
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,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"); | ||
}); | ||
}, | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { featureFlagIntercept } from "../../../../support/Objects/FeatureFlags"; | ||
import { | ||
agHelper, | ||
entityExplorer, | ||
homePage, | ||
partialImportExport, | ||
entityItems, | ||
locators, | ||
} from "../../../../support/Objects/ObjectsCore"; | ||
import { EntityType } from "../../../../support/Pages/EditorNavigation"; | ||
import PageList from "../../../../support/Pages/PageList"; | ||
|
||
const fixtureName = "ImportExport.json"; | ||
|
||
describe( | ||
"Partial import and export functionality", | ||
{ tags: ["@tag.ImportExport", "@tag.Git"] }, | ||
() => { | ||
before(() => { | ||
agHelper.GenerateUUID(); | ||
partialImportExport.OpenImportModal(); | ||
homePage.ImportApp(`PartialImportExport/${fixtureName}`, "", true); | ||
homePage.RenameApplication("ImportExport"); | ||
entityExplorer.RenameEntityFromExplorer( | ||
"Page1", | ||
"Home", | ||
false, | ||
entityItems.Page, | ||
); | ||
}); | ||
|
||
beforeEach(() => {}); | ||
|
||
it("1. Should export all the selected elements and import it to new Page", () => { | ||
partialImportExport.OpenExportModal(); | ||
|
||
// Export Widgets | ||
partialImportExport.PartiallyExportFile( | ||
4, | ||
partialImportExport.locators.export.modelContents.widgetsSection, | ||
["Table1", "Button1"], | ||
); | ||
|
||
// Export Queries | ||
partialImportExport.OpenExportModal(); | ||
partialImportExport.ExportAndCompareDownloadedFile( | ||
"queries", | ||
2, | ||
partialImportExport.locators.export.modelContents.queriesSection, | ||
"PartialQueryExport.json", | ||
fixtureName, | ||
); | ||
|
||
cy.wait(5000); | ||
PageList.AddNewPage("New blank page"); | ||
partialImportExport.OpenImportModal(); | ||
|
||
// Import Widgets | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
"PartialWidgetExport.json", | ||
"Widgets", | ||
["Table1", "Button1"], | ||
); | ||
|
||
// Import Queries | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
"PartialQueryExport.json", | ||
"Queries", | ||
["Api1"], | ||
); | ||
|
||
agHelper.selectAndValidateWidgetNameAndProperty({ | ||
widgetName: "Table1", | ||
propFieldName: "Table data", | ||
valueToValidate: "{{Api1.data}}", | ||
}); | ||
}); | ||
|
||
it("2. Should be able to import again in the same Page", () => { | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
"PartialWidgetExport.json", | ||
"Widgets", | ||
["Table1", "Button1"], | ||
); | ||
|
||
agHelper.selectAndValidateWidgetNameAndProperty({ | ||
widgetName: "Table1", | ||
propFieldName: "Table data", | ||
valueToValidate: "{{Api1.data}}", | ||
}); | ||
|
||
agHelper.AssertElementLength( | ||
`${locators._widgetInDeployed("tablewidgetv2")}`, | ||
2, | ||
); | ||
agHelper.AssertElementLength( | ||
`${locators._widgetInDeployed("buttonwidget")}`, | ||
2, | ||
); | ||
}); | ||
|
||
it("3. Should import the Page into new application", () => { | ||
homePage.NavigateToHome(); | ||
homePage.CreateNewApplication(); | ||
|
||
// Import Widgets | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
"PartialWidgetExport.json", | ||
"Widgets", | ||
["Table1", "Button1"], | ||
); | ||
|
||
// Import Queries | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
"PartialQueryExport.json", | ||
"Queries", | ||
["Api1"], | ||
); | ||
|
||
agHelper.selectAndValidateWidgetNameAndProperty({ | ||
widgetName: "Table1", | ||
propFieldName: "Table data", | ||
valueToValidate: "{{Api1.data}}", | ||
}); | ||
}); | ||
}, | ||
); |
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
{"artifactJsonType":"APPLICATION","clientSchemaVersion":1,"serverSchemaVersion":11,"actionList":[{"id":"Home_Api1","pluginType":"API","pluginId":"restapi-plugin","unpublishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"name":"DEFAULT_REST_DATASOURCE","pluginId":"restapi-plugin","datasourceConfiguration":{"url":"http://host.docker.internal:5001"},"invalids":[],"messages":[],"isValid":true},"pageId":"Home","actionConfiguration":{"timeoutInMillisecond":10000,"paginationType":"NONE","path":"/v1/mock-api","headers":[],"autoGeneratedHeaders":[],"encodeParamsToggle":true,"queryParameters":[{"key":"records","value":"10"}],"body":"","bodyFormData":[],"httpMethod":"GET","httpVersion":"HTTP11","pluginSpecifiedTemplates":[{"value":true}],"formData":{"apiContentType":"none"}},"executeOnLoad":true,"dynamicBindingPathList":[],"isValid":true,"invalids":[],"messages":[],"jsonPathKeys":[],"confirmBeforeExecute":false,"userPermissions":[]},"publishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"messages":[],"isValid":true},"pageId":"Home","messages":[],"confirmBeforeExecute":false,"userPermissions":[]}}],"widgets":""} | ||
<<<<<<< HEAD | ||
{"artifactJsonType":"APPLICATION","clientSchemaVersion":1,"serverSchemaVersion":11,"actionList":[{"id":"Home_Api1","pluginType":"SAAS","pluginId":"google-sheets-plugin","unpublishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"name":"Untitled datasource 2","pluginId":"google-sheets-plugin","messages":[],"isValid":true},"pageId":"Home","actionConfiguration":{"timeoutInMillisecond":10000,"paginationType":"NONE","encodeParamsToggle":true,"formData":{"command":{"data":"FETCH_MANY"},"entityType":{"data":"ROWS"},"tableHeaderIndex":{"data":"1"},"projection":{"data":["Currency"]},"queryFormat":{"data":"ROWS"},"range":{"data":""},"where":{"data":{"condition":"AND","children":[{"condition":"LT"}]}},"pagination":{"data":{"limit":"20","offset":"0"}},"smartSubstitution":{"data":true},"sheetUrl":{"data":"https://docs.google.com/spreadsheets/d/1DLNNumIhXhbajHGAEhWfzlgixcAu259gzAOVvLtWVpA/edit"},"sheetName":{"data":"Sheet1"},"sortBy":{"data":[{"column":"","order":"Ascending"}]}}},"executeOnLoad":true,"dynamicBindingPathList":[],"isValid":true,"invalids":[],"messages":[],"jsonPathKeys":[],"confirmBeforeExecute":false,"userPermissions":[]},"publishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"name":"Untitled datasource 2","pluginId":"google-sheets-plugin","messages":[],"isValid":true},"pageId":"Home","actionConfiguration":{"timeoutInMillisecond":10000,"paginationType":"NONE","encodeParamsToggle":true,"formData":{"command":{"data":"FETCH_MANY"},"entityType":{"data":"ROWS"},"tableHeaderIndex":{"data":"1"},"projection":{"data":["Currency"]},"queryFormat":{"data":"ROWS"},"range":{"data":""},"where":{"data":{"condition":"AND","children":[{"condition":"LT"}]}},"pagination":{"data":{"limit":"20","offset":"0"}},"smartSubstitution":{"data":true},"sheetUrl":{"data":"https://docs.google.com/spreadsheets/d/1DLNNumIhXhbajHGAEhWfzlgixcAu259gzAOVvLtWVpA/edit"},"sheetName":{"data":"Sheet1"},"sortBy":{"data":[{"column":"","order":"Ascending"}]}}},"executeOnLoad":true,"dynamicBindingPathList":[],"isValid":true,"invalids":[],"messages":[],"jsonPathKeys":[],"confirmBeforeExecute":false,"userPermissions":[]}}],"widgets":""} | ||
======= | ||
{"artifactJsonType":"APPLICATION","clientSchemaVersion":1,"serverSchemaVersion":11,"actionList":[{"id":"Home_Api1","pluginType":"API","pluginId":"restapi-plugin","unpublishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"name":"DEFAULT_REST_DATASOURCE","pluginId":"restapi-plugin","datasourceConfiguration":{"url":"http://host.docker.internal:5001"},"invalids":[],"messages":[],"isValid":true},"pageId":"Home","actionConfiguration":{"timeoutInMillisecond":10000,"paginationType":"NONE","path":"/v1/mock-api","headers":[],"autoGeneratedHeaders":[],"encodeParamsToggle":true,"queryParameters":[{"key":"records","value":"10"}],"body":"","bodyFormData":[],"httpMethod":"GET","httpVersion":"HTTP11","pluginSpecifiedTemplates":[{"value":true}],"formData":{"apiContentType":"none"}},"executeOnLoad":true,"dynamicBindingPathList":[],"isValid":true,"invalids":[],"messages":[],"jsonPathKeys":[],"confirmBeforeExecute":false,"userPermissions":[]},"publishedAction":{"name":"Api1","fullyQualifiedName":"Api1","datasource":{"userPermissions":[],"messages":[],"isValid":true},"pageId":"Home","messages":[],"confirmBeforeExecute":false,"userPermissions":[]}}],"widgets":""} | ||
>>>>>>> refs/remotes/origin/release | ||
Comment on lines
+1
to
+5
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. Resolve merge conflicts in the JSON file There are unresolved merge conflict markers in this file. Please resolve them to ensure the JSON is valid. 🧰 Tools🪛 Biome (1.9.4)[error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: unexpected character (parse) [error] 1-1: String values must be double quoted. (parse) [error] 1-2: End of file expected Use an array for a sequence of values: (parse) [error] 2-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-3: unexpected character (parse) [error] 3-4: End of file expected Use an array for a sequence of values: (parse) [error] 4-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: unexpected character (parse) [error] 5-5: String values must be double quoted. (parse) [error] 5-5: unexpected character (parse) [error] 5-5: String values must be double quoted. (parse) [error] 5-5: unexpected character (parse) [error] 5-5: String values must be double quoted. (parse) [error] 5-5: unexpected character (parse) [error] 5-5: String values must be double quoted. (parse) |
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
Avoid using
cy.wait
Please avoid using
cy.wait(5000);
. Replace it with proper wait mechanisms likeagHelper.WaitUntilAllToastsDisappear();
or assertions to ensure synchronization.Apply this diff: