Skip to content
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 test for partial import/export within new page/App #37388

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace cy.wait with proper assertions.

Using cy.wait is against our coding guidelines. Instead, wait for specific elements or network requests to complete.

-      cy.wait(5000);
+      agHelper.WaitUntilToastDisappear();
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
cy.wait(5000);
agHelper.WaitUntilToastDisappear();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NandanAnantharamu Why we need this sleep?

PageList.AddNewPage("New blank page");
partialImportExport.OpenImportModal();

// Import Widgets
partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile(
Comment on lines +59 to +60
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove redundant OpenImportModal call.

The import modal is already opened in line 55.

-      partialImportExport.OpenImportModal();
       partialImportExport.ImportPartiallyExportedFile(
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
partialImportExport.OpenImportModal();
partialImportExport.ImportPartiallyExportedFile(
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
@@ -0,0 +1 @@
{"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":""}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"artifactJsonType":"APPLICATION","clientSchemaVersion":1,"serverSchemaVersion":11,"widgets":"{\"layoutSystemType\":\"FIXED\",\"widgets\":[{\"hierarchy\":4,\"list\":[{\"boxShadow\":\"{{appsmith.theme.boxShadow.appBoxShadow}}\",\"borderColor\":\"#E0DEDE\",\"isVisibleDownload\":true,\"topRow\":1,\"isSortable\":true,\"type\":\"TABLE_WIDGET_V2\",\"inlineEditingSaveOption\":\"ROW_LEVEL\",\"animateLoading\":true,\"dynamicBindingPathList\":[{\"key\":\"accentColor\"},{\"key\":\"borderRadius\"},{\"key\":\"boxShadow\"},{\"key\":\"tableData\"},{\"key\":\"primaryColumns.rowIndex.computedValue\"},{\"key\":\"primaryColumns.Currency.computedValue\"}],\"leftColumn\":7,\"delimiter\":\",\",\"customIsLoadingValue\":\"\",\"defaultSelectedRowIndex\":0,\"flexVerticalAlignment\":\"start\",\"accentColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"isVisibleFilters\":false,\"isVisible\":true,\"enableClientSideSearch\":true,\"version\":2,\"totalRecordsCount\":0,\"isLoading\":false,\"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}}\"}},\"customIsLoading\":false,\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"columnUpdatedAt\":1731311884410,\"defaultSelectedRowIndices\":[0],\"needsErrorInfo\":false,\"mobileBottomRow\":62,\"widgetName\":\"Table1\",\"defaultPageSize\":0,\"columnOrder\":[\"rowIndex\",\"Currency\"],\"dynamicPropertyPathList\":[{\"key\":\"tableData\"}],\"bottomRow\":34,\"columnWidthMap\":{},\"parentRowSpace\":10,\"mobileRightColumn\":41,\"parentColumnSpace\":30.5625,\"dynamicTriggerPathList\":[],\"borderWidth\":\"1\",\"primaryColumns\":{\"rowIndex\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":1,\"width\":150,\"originalId\":\"rowIndex\",\"id\":\"rowIndex\",\"alias\":\"rowIndex\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"number\",\"textColor\":\"\",\"textSize\":\"0.875rem\",\"fontStyle\":\"\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"rowIndex\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"rowIndex\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\",\"cellBackground\":\"\"},\"Currency\":{\"allowCellWrapping\":false,\"allowSameOptionsInNewRow\":true,\"index\":9,\"width\":150,\"originalId\":\"Currency\",\"id\":\"Currency\",\"alias\":\"Currency\",\"horizontalAlignment\":\"LEFT\",\"verticalAlignment\":\"CENTER\",\"columnType\":\"number\",\"textColor\":\"\",\"textSize\":\"0.875rem\",\"fontStyle\":\"\",\"enableFilter\":true,\"enableSort\":true,\"isVisible\":true,\"isDisabled\":false,\"isCellEditable\":false,\"isEditable\":false,\"isCellVisible\":true,\"isDerived\":false,\"label\":\"Currency\",\"isSaveVisible\":true,\"isDiscardVisible\":true,\"computedValue\":\"{{Table1.processedTableData.map((currentRow, currentIndex) => ( currentRow[\\\"Currency\\\"]))}}\",\"sticky\":\"\",\"validation\":{},\"currencyCode\":\"USD\",\"decimals\":0,\"thousandSeparator\":true,\"notation\":\"standard\",\"cellBackground\":\"\"}},\"key\":\"iwmm57yz9c\",\"canFreezeColumn\":true,\"rightColumn\":41,\"textSize\":\"0.875rem\",\"widgetId\":\"6auq1k5wf7\",\"minWidth\":450,\"tableData\":\"{{Api1.data}}\",\"label\":\"Data\",\"searchKey\":\"\",\"parentId\":\"0\",\"renderMode\":\"CANVAS\",\"mobileTopRow\":34,\"horizontalAlignment\":\"LEFT\",\"isVisibleSearch\":true,\"responsiveBehavior\":\"fill\",\"mobileLeftColumn\":7,\"isVisiblePagination\":true,\"verticalAlignment\":\"CENTER\"}],\"parentId\":\"0\",\"widgetId\":\"6auq1k5wf7\",\"widgetPositionInfo\":null},{\"hierarchy\":4,\"list\":[{\"resetFormOnClick\":false,\"needsErrorInfo\":false,\"boxShadow\":\"none\",\"mobileBottomRow\":79,\"widgetName\":\"Button1\",\"onClick\":\"{{JSObject1.genPDF();}}\",\"buttonColor\":\"{{appsmith.theme.colors.primaryColor}}\",\"topRow\":42,\"bottomRow\":46,\"parentRowSpace\":10,\"type\":\"BUTTON_WIDGET\",\"mobileRightColumn\":38,\"animateLoading\":true,\"parentColumnSpace\":30.5625,\"dynamicTriggerPathList\":[{\"key\":\"onClick\"}],\"leftColumn\":22,\"dynamicBindingPathList\":[{\"key\":\"buttonColor\"},{\"key\":\"borderRadius\"}],\"text\":\"Submit\",\"isDisabled\":false,\"key\":\"dlbj0skcwr\",\"rightColumn\":38,\"isDefaultClickDisabled\":true,\"widgetId\":\"vdsey2khz4\",\"minWidth\":120,\"isVisible\":true,\"recaptchaType\":\"V3\",\"version\":1,\"parentId\":\"0\",\"renderMode\":\"CANVAS\",\"isLoading\":false,\"mobileTopRow\":75,\"responsiveBehavior\":\"hug\",\"disabledWhenInvalid\":false,\"borderRadius\":\"{{appsmith.theme.borderRadius.appBorderRadius}}\",\"mobileLeftColumn\":22,\"buttonVariant\":\"PRIMARY\",\"placement\":\"CENTER\"}],\"parentId\":\"0\",\"widgetId\":\"vdsey2khz4\",\"widgetPositionInfo\":null}],\"flexLayers\":[]}"}
2 changes: 1 addition & 1 deletion app/client/cypress/limited-tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To run only limited tests - give the spec names in below format:
cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js
cypress/e2e/Regression/ClientSide/PartialImportExport/PartialImportExportWithinNewPageAndApp.ts
# For running all specs - uncomment below:
#cypress/e2e/**/**/*

Expand Down
Loading