-
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: partial import export areas covered #37661
base: release
Are you sure you want to change the base?
Changes from 14 commits
8c9026c
5c0764d
528cd01
6cfcddb
6059c5f
7e5ecde
9295334
9f95a61
05baf44
4f96a8d
2440266
4349be6
55f40eb
08476de
ae283a6
ae42421
cb80ee9
5c3d72b
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,232 @@ | ||
import { | ||
agHelper, | ||
entityExplorer, | ||
homePage, | ||
partialImportExport, | ||
entityItems, | ||
locators, | ||
gitSync, | ||
apiPage, | ||
} from "../../../../support/Objects/ObjectsCore"; | ||
import { PageLeftPane } 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, | ||
); | ||
}); | ||
|
||
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.PartiallyExportFile( | ||
2, | ||
partialImportExport.locators.export.modelContents.queriesSection, | ||
["Api1"], | ||
); | ||
|
||
cy.wait(5000); | ||
PageList.AddNewPage("New blank page"); | ||
partialImportExport.OpenImportModal(); | ||
|
||
// Import Widgets | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
Comment on lines
+55
to
+56
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 Consolidate duplicate modal operations There are unnecessary duplicate calls to - partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile(
"PartialWidgetExport.json",
"Widgets",
["Table1", "Button1"],
);
// Import Queries
- partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile( Also applies to: 64-65 |
||
"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}}", | ||
}); | ||
|
||
PageLeftPane.switchSegment("Queries"); | ||
agHelper.GetNClick('[data-testid="t--entity-item-Api1"]'); | ||
apiPage.RunAPI(); | ||
PageLeftPane.switchSegment("UI"); | ||
agHelper.AssertElementExist('[data-colindex="0"][data-rowindex="0"]'); | ||
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 Move selectors to locator variables Avoid using hardcoded selectors. Move them to the locators object. +// Add to locators object
+const LOCATORS = {
+ API_ITEM: '[data-testid="t--entity-item-Api1"]',
+ TABLE_CELL: '[data-colindex="0"][data-rowindex="0"]'
+};
agHelper.selectAndValidateWidgetNameAndProperty({
widgetName: "Table1",
propFieldName: "Table data",
valueToValidate: "{{Api1.data}}",
});
PageLeftPane.switchSegment("Queries");
-agHelper.GetNClick('[data-testid="t--entity-item-Api1"]');
+agHelper.GetNClick(LOCATORS.API_ITEM);
apiPage.RunAPI();
PageLeftPane.switchSegment("UI");
-agHelper.AssertElementExist('[data-colindex="0"][data-rowindex="0"]');
+agHelper.AssertElementExist(LOCATORS.TABLE_CELL);
|
||
}); | ||
|
||
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( | ||
Comment on lines
+112
to
+113
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 Remove redundant modal operations Similar to the previous test, there are unnecessary duplicate calls to - partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile(
"PartialWidgetExport.json",
"Widgets",
["Table1", "Button1"],
);
// Import Queries
- partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile( Also applies to: 115-116 |
||
"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}}", | ||
}); | ||
|
||
PageLeftPane.switchSegment("Queries"); | ||
agHelper.GetNClick('[data-testid="t--entity-item-Api1"]'); | ||
apiPage.RunAPI(); | ||
PageLeftPane.switchSegment("UI"); | ||
agHelper.AssertElementExist('[data-colindex="0"][data-rowindex="0"]'); | ||
}); | ||
|
||
it("4. Should import the Page into new workspace", () => { | ||
homePage.CreateNewWorkspace("", true); | ||
|
||
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}}", | ||
}); | ||
|
||
PageLeftPane.switchSegment("Queries"); | ||
agHelper.GetNClick('[data-testid="t--entity-item-Api1"]'); | ||
apiPage.RunAPI(); | ||
PageLeftPane.switchSegment("UI"); | ||
agHelper.AssertElementExist('[data-colindex="0"][data-rowindex="0"]'); | ||
}); | ||
|
||
it("5. Import to Git branch", () => { | ||
homePage.NavigateToHome(); | ||
homePage.CreateNewApplication(); | ||
gitSync.CreateNConnectToGit(); | ||
gitSync.CreateGitBranch("New_Branch"); | ||
gitSync.CreateGitBranch(); | ||
Comment on lines
+178
to
+179
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. 💡 Codebase verification Remove redundant Git branch creation The second
🔗 Analysis chainClarify Git branch creation intent There are two consecutive 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Check the implementation of CreateGitBranch to understand the behavior without parameters
ast-grep --pattern 'CreateGitBranch($$$) {
$$$
}'
Length of output: 53 Script: #!/bin/bash
# Search for CreateGitBranch function definition in test helper files
fd "gitSync" --type f --exec rg -l "CreateGitBranch"
# After finding the files, let's look at the implementation
rg "CreateGitBranch" -A 5 -B 2
Length of output: 37095 |
||
|
||
partialImportExport.OpenImportModal(); | ||
|
||
// Import Widgets | ||
partialImportExport.OpenImportModal(); | ||
partialImportExport.ImportPartiallyExportedFile( | ||
Comment on lines
+184
to
+185
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 Remove redundant modal operations Multiple instances of unnecessary duplicate calls to - partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile(
"PartialWidgetExport.json",
"Widgets",
["Table1", "Button1"],
);
// Import Queries
- partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile( Also applies to: 147-148, 164-165, 172-173 |
||
"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}}", | ||
}); | ||
|
||
gitSync.CommitAndPush(); | ||
gitSync.SwitchGitBranch("New_Branch"); | ||
|
||
// 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}}", | ||
}); | ||
}); | ||
}, | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"artifactJsonType":"APPLICATION","clientSchemaVersion":1,"serverSchemaVersion":11,"customJSLibList":[],"actionList":[{"id":"Home_Api1","pluginType":"API","pluginId":"restapi-plugin","unpublishedAction":{"name":"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":{"datasource":{"userPermissions":[],"messages":[],"isValid":true},"messages":[],"confirmBeforeExecute":false,"userPermissions":[]}}],"actionCollectionList":[{"id":"Home_JSObject1","unpublishedCollection":{"name":"JSObject1","pageId":"Home","pluginId":"js-plugin","pluginType":"JS","actions":[],"archivedActions":[],"body":"export default {\n\tgenPDF: () => {\n\t\tconst doc = new jspdf.jsPDF();\n\tdoc.text('Users', 20, 20);\n\t\tdoc.table(20, 30, Table1.tableData, Table1.columnOrder, {autoSize: true});\n\t\tdownload(doc.output(), 'users_list.pdf');\n\t}\n}","variables":[],"userPermissions":[]}},{"id":"Home_JSObject2","unpublishedCollection":{"name":"JSObject2","pageId":"Home","pluginId":"js-plugin","pluginType":"JS","actions":[],"archivedActions":[],"body":"export default {\n\tmyVar1: [],\n\tmyVar2: {},\n\tmyFun1 () {\n\t\tshowAlert(moment().daysInMonth().toString());\n\t},\n\tasync myFun2 () {\n\t\t//\tuse async-await or promises\n\t\t//\tawait storeValue('varName', 'hello world')\n\t}\n}","variables":[{"name":"myVar1","value":"[]"},{"name":"myVar2","value":"{}"}],"userPermissions":[]}}],"widgets":"{\"layoutSystemType\":\"FIXED\",\"widgets\":[{\"hierarchy\":4,\"list\":[{\"isVisible\":true,\"type\":\"TABLE_WIDGET_V2\",\"flexVerticalAlignment\":\"start\",\"responsiveBehavior\":\"fill\",\"minWidth\":450,\"canFreezeColumn\":true,\"columnUpdatedAt\":1732544015069,\"animateLoading\":true,\"defaultSelectedRowIndex\":0,\"defaultSelectedRowIndices\":[0],\"label\":\"Data\",\"widgetName\":\"Table1\",\"searchKey\":\"\",\"textSize\":\"0.875rem\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"totalRecordsCount\":0,\"defaultPageSize\":0,\"dynamicPropertyPathList\":[{\"key\":\"tableData\"}],\"borderColor\":\"#E0DEDE\",\"borderWidth\":\"1\",\"dynamicBindingPathList\":[{\"key\":\"accentColor\"},{\"key\":\"borderRadius\"},{\"key\":\"boxShadow\"},{\"key\":\"tableData\"},{\"key\":\"primaryColumns.address.computedValue\"},{\"key\":\"primaryColumns.avatar.computedValue\"},{\"key\":\"primaryColumns.email.computedValue\"},{\"key\":\"primaryColumns.gender.computedValue\"},{\"key\":\"primaryColumns.id.computedValue\"},{\"key\":\"primaryColumns.name.computedValue\"},{\"key\":\"primaryColumns.status.computedValue\"}],\"primaryColumns\":{\"address\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":0,\"width\":150,\"originalId\":\"address\",\"id\":\"address\",\"alias\":\"address\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"address\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"address\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"avatar\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":1,\"width\":150,\"originalId\":\"avatar\",\"id\":\"avatar\",\"alias\":\"avatar\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"avatar\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"avatar\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"email\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":2,\"width\":150,\"originalId\":\"email\",\"id\":\"email\",\"alias\":\"email\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"email\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"email\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"gender\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":3,\"width\":150,\"originalId\":\"gender\",\"id\":\"gender\",\"alias\":\"gender\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"gender\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"gender\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"id\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":4,\"width\":150,\"originalId\":\"id\",\"id\":\"id\",\"alias\":\"id\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"number\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"id\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"id\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"name\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":5,\"width\":150,\"originalId\":\"name\",\"id\":\"name\",\"alias\":\"name\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"name\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"name\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"},\"status\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":6,\"width\":150,\"originalId\":\"status\",\"id\":\"status\",\"alias\":\"status\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"text\",\"textSize\":\"0.875rem\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"status\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"status\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\"}},\"tableData\":\"{{Api1.data}}\",\"columnWidthMap\":{},\"columnOrder\":[\"address\",\"avatar\",\"email\",\"gender\",\"id\",\"name\",\"status\"],\"enableClientSideSearch\":true,\"isVisibleSearch\":true,\"isVisibleFilters\":false,\"isVisibleDownload\":true,\"isVisiblePagination\":true,\"isSortable\":true,\"delimiter\":\",\",\"version\":2,\"inlineEditingSaveOption\":\"ROW_LEVEL\",\"customIsLoading\":false,\"customIsLoadingValue\":\"\",\"key\":\"kf8hr71nup\",\"needsErrorInfo\":false,\"widgetId\":\"u35g21sru2\",\"renderMode\":\"CANVAS\",\"accentColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"boxShadow\":\"{{appsmith.theme.boxShadow.appBoxShadow}}\",\"childStylesheet\":{\"button\":{\"buttonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"boxShadow\":\"none\"},\"menuButton\":{\"menuColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"boxShadow\":\"none\"},\"iconButton\":{\"buttonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"boxShadow\":\"none\"},\"editActions\":{\"saveButtonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"saveBorderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"discardButtonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"discardBorderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\"}},\"isLoading\":false,\"parentColumnSpace\":8.65625,\"parentRowSpace\":10,\"leftColumn\":11,\"rightColumn\":45,\"topRow\":11,\"bottomRow\":39,\"mobileLeftColumn\":11,\"mobileRightColumn\":45,\"mobileTopRow\":11,\"mobileBottomRow\":39,\"parentId\":\"0\",\"dynamicTriggerPathList\":[]}],\"parentId\":\"0\",\"widgetId\":\"u35g21sru2\",\"widgetPositionInfo\":null},{\"hierarchy\":4,\"list\":[{\"isVisible\":true,\"type\":\"BUTTON_WIDGET\",\"animateLoading\":true,\"text\":\"Submit\",\"buttonVariant\":\"PRIMARY\",\"placement\":\"CENTER\",\"widgetName\":\"Button1\",\"isDisabled\":false,\"isDefaultClickDisabled\":true,\"disabledWhenInvalid\":false,\"resetFormOnClick\":false,\"recaptchaType\":\"V3\",\"version\":1,\"responsiveBehavior\":\"hug\",\"minWidth\":120,\"key\":\"q8mlo01tzz\",\"needsErrorInfo\":false,\"widgetId\":\"imzxuk30nh\",\"renderMode\":\"CANVAS\",\"buttonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"boxShadow\":\"none\",\"isLoading\":false,\"parentColumnSpace\":8.65625,\"parentRowSpace\":10,\"leftColumn\":24,\"rightColumn\":40,\"topRow\":44,\"bottomRow\":48,\"mobileLeftColumn\":24,\"mobileRightColumn\":40,\"mobileTopRow\":44,\"mobileBottomRow\":48,\"parentId\":\"0\",\"dynamicBindingPathList\":[{\"key\":\"buttonColor\"},{\"key\":\"borderRadius\"}],\"onClick\":\"{{JSObject1.genPDF();}}\",\"dynamicTriggerPathList\":[{\"key\":\"onClick\"}]}],\"parentId\":\"0\",\"widgetId\":\"imzxuk30nh\",\"widgetPositionInfo\":null}],\"flexLayers\":[]}"} | ||
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 JavaScript object implementations
Suggested implementation for JSObject1: export default {
genPDF: () => {
+ try {
+ if (!Table1.tableData || !Table1.columnOrder) {
+ throw new Error('Table data or column order is missing');
+ }
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');
+ } catch (error) {
+ showAlert('Failed to generate PDF: ' + error.message);
+ }
}
}
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"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":""} |
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.
Replace cy.wait with proper assertions
Using cy.wait is against best practices. Replace with proper assertions or waitUntil conditions.