Skip to content

Commit

Permalink
test:replace assertPageSave with AssertAutoSave (#33972)
Browse files Browse the repository at this point in the history
This replaces assertPageSave with AssertAutoSave from Ts helper
EE PR: appsmithorg/appsmith-ee#4345

/ok-to-test tags="@tag.All"

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **Tests**
- Updated Cypress tests to use `agHelper.AssertAutoSave()` instead of
`cy.assertPageSave()` for validating auto-save functionality. This
change enhances the reliability of auto-save assertions across multiple
test scripts.
<!-- end of auto-generated comment: release notes by coderabbit.ai
--><!-- This is an auto-generated comment: Cypress test results -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/9370053807>
> Commit: ca15415
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9370053807&attempt=2"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->
  • Loading branch information
NandanAnantharamu committed Jun 6, 2024
1 parent a73082d commit 04ce4b8
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(
cy.get(commonlocators.singleSelectMenuItem)
.contains(pageid)
.click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
});

it("3. Validate NavigateTo Page functionality ", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe(
cy.get(commonlocators.singleSelectMenuItem)
.contains(pageid)
.click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
});

it("2. Validate NavigateTo Page functionality ", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe(
cy.get(commonlocators.singleSelectMenuItem)
.contains(pageid)
.click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
//Validate NavigateTo Page functionality
cy.wait(2000);
deployMode.DeployApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ describe(
});
});
cy.wait("@blockImport").then(() => {
cy.assertPageSave();
agHelper.AssertAutoSave();
// check that the widgets are present on the canvas
agHelper.AssertElementVisibility('[data-testid="t--ide-list"]');
agHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ describe("App Theming funtionality", { tags: ["@tag.Theme"] }, function () {
appSettings.OpenAppSettings();
appSettings.GoToThemeSettings();
cy.get(commonlocators.changeThemeBtn).click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
// select a theme
cy.get(commonlocators.themeCard).last().click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
// check for alert
cy.get(`${commonlocators.themeCard}`)
.last()
Expand Down Expand Up @@ -81,7 +81,7 @@ describe("App Theming funtionality", { tags: ["@tag.Theme"] }, function () {

// change app border radius
cy.get(commonlocators.themeAppBorderRadiusBtn).eq(1).click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
// check if border radius is changed on button
cy.get(commonlocators.themeAppBorderRadiusBtn)
.eq(1)
Expand Down Expand Up @@ -656,7 +656,7 @@ describe("App Theming funtionality", { tags: ["@tag.Theme"] }, function () {
"rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px",
);

cy.assertPageSave();
agHelper.AssertAutoSave();

//Add deploy mode verification here also!
deployMode.DeployApp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe(
//Changing the text on the Button
cy.testJsontext("label", this.dataSet.ButtonLabel);

cy.assertPageSave();
_.agHelper.AssertAutoSave();

//Verify the Button name and label
cy.get(widgetsPage.buttonWidget).trigger("mouseover");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { agHelper } from "../../../../../support/Objects/ObjectsCore";

const widgetName = "inputwidgetv2";
const widgetInput = `.t--widget-${widgetName} input`;

Expand Down Expand Up @@ -364,7 +366,7 @@ describe("Input widget V2 - ", { tags: ["@tag.Widget", "@tag.Input"] }, () => {
".t--property-control-text",
"{{appsmith.store.textPayloadOnSubmit}}",
);
cy.assertPageSave();
agHelper.AssertAutoSave();

cy.closePropertyPane();
cy.get(widgetInput).clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe(
x: 250,
y: 50,
});
cy.assertPageSave();
_.agHelper.AssertAutoSave();

// Verify drop
cy.get(publishLocators.inputWidget).should("exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe(
entityExplorer.DragDropWidgetNVerify(widget);
//cy.dragAndDropToWidget(widget, "listwidgetv2", { x: 350, y: 50 });
agHelper.GetNClick(propPane._deleteWidget);
cy.assertPageSave();
agHelper.AssertAutoSave();
cy.wait(800);
});
},
Expand All @@ -86,10 +86,10 @@ describe(
entityExplorer.DragDropWidgetNVerify(widget);

//cy.dragAndDropToWidget(widget, "listwidgetv2", { x: 350, y: 50 });
cy.assertPageSave();
agHelper.AssertAutoSave();
cy.get(`.t--draggable-${widget}`).should("exist");
cy.get(widgetsPage.removeWidget).click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
cy.wait(800);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Tab widget test", { tags: ["@tag.Widget", "@tag.Tab"] }, function () {
cy.get(Layoutpage.tabContainer)
.scrollIntoView({ easing: "linear" })
.should("be.visible");
cy.assertPageSave();
agHelper.AssertAutoSave();
deployMode.DeployApp();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe(
// select the green color

cy.wait("@updateLayout");
cy.assertPageSave();
_.agHelper.AssertAutoSave();
_.deployMode.DeployApp();
cy.wait(4000);

Expand All @@ -56,7 +56,7 @@ describe(
.clear({ force: true })
.type("purple", { force: true, delay: 0 });
cy.wait("@updateLayout");
cy.assertPageSave();
_.agHelper.AssertAutoSave();
_.deployMode.DeployApp();
cy.wait(4000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe(
// select the green color

cy.wait("@updateLayout");
cy.assertPageSave();
_.agHelper.AssertAutoSave();
_.deployMode.DeployApp();
cy.wait(4000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const testdata = require("../../../../fixtures/testdata.json");
const apiwidget = require("../../../../locators/apiWidgetslocator.json");

import {
agHelper,
apiPage,
entityExplorer,
} from "../../../../support/Objects/ObjectsCore";
Expand All @@ -20,7 +21,7 @@ describe(
cy.Createpage("SecondPage");
cy.CreateAPI("FirstAPI");
cy.enterDatasourceAndPath(testdata.baseUrl, "{{ '/random' }}");
cy.assertPageSave();
agHelper.AssertAutoSave();
cy.get("body").click(0, 0);
PageLeftPane.switchSegment(PagePaneSegment.Queries);
entityExplorer.ActionContextMenuByEntityName({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe(
widgetsPage.inputWidget,
widgetsPage.widgetNameSpan,
);
cy.assertPageSave();
agHelper.AssertAutoSave();
},
);

Expand All @@ -85,7 +85,7 @@ describe(
widgetsPage.inputWidget,
widgetsPage.widgetNameSpan,
);
cy.assertPageSave();
agHelper.AssertAutoSave();
},
);

Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/support/ApiCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Cypress.Commands.add("enterDatasource", (datasource) => {
.type(datasource, { parseSpecialCharSequences: false });
//.type("{esc}}");
cy.wait(2000);
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add("ResponseStatusCheck", (statusCode) => {
Expand Down
12 changes: 1 addition & 11 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ Cypress.Commands.add("dragAndDropToCanvas", (widgetType, { x, y }) => {
.trigger("mousemove", x, y, option)
.trigger("mousemove", x, y, option)
.trigger("mouseup", x, y, option);
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add(
Expand Down Expand Up @@ -919,16 +919,6 @@ Cypress.Commands.add("CheckForPageSaveError", () => {
});
});

Cypress.Commands.add("assertPageSave", (validateSavedState = true) => {
if (validateSavedState) {
cy.CheckForPageSaveError();
cy.get(commonlocators.saveStatusContainer).should("not.exist", {
timeout: 30000,
});
}
//assertHelper.AssertNetworkStatus("@sucessSave", 200);
});

Cypress.Commands.add(
"validateCodeEditorContent",
(selector, contentToValidate) => {
Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/support/gitSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Cypress.Commands.add("latestDeployPreview", () => {
// Wait before publish
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);
cy.assertPageSave();
agHelper.AssertAutoSave();

// Stubbing window.open to open in the same tab
cy.window().then((window) => {
Expand Down
16 changes: 8 additions & 8 deletions app/client/cypress/support/widgetCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Cypress.Commands.add("createModal", (ModalName, property) => {
cy.wait(2000);
cy.get(modalWidgetPage.createModalButton).click({ force: true });
cy.wait(3000);
cy.assertPageSave();
agHelper.AssertAutoSave();
// changing the model name verify
// cy.widgetText(
// ModalName,
Expand All @@ -162,7 +162,7 @@ Cypress.Commands.add("createModal", (ModalName, property) => {
cy.testCodeMirror(ModalName);
cy.moveToStyleTab();
cy.xpath(widgetsPage.textCenterAlign).first().click({ force: true });
cy.assertPageSave();
agHelper.AssertAutoSave();
cy.get(".bp3-overlay-backdrop").last().click({ force: true });
});

Expand All @@ -186,14 +186,14 @@ Cypress.Commands.add("CheckWidgetProperties", (checkboxCss) => {
cy.get(checkboxCss).check({
force: true,
});
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add("UncheckWidgetProperties", (checkboxCss) => {
cy.get(checkboxCss).uncheck({
force: true,
});
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add("EditWidgetPropertiesUsingJS", (checkboxCss, inputJS) => {
Expand All @@ -202,7 +202,7 @@ Cypress.Commands.add("EditWidgetPropertiesUsingJS", (checkboxCss, inputJS) => {
.should("exist")
.dblclick({ force: true })
.type(inputJS);
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add(
Expand All @@ -228,7 +228,7 @@ Cypress.Commands.add("verifyUpdatedWidgetName", (text, txtToVerify) => {
.click({ force: true })
.type(text)
.type("{enter}");
cy.assertPageSave();
agHelper.AssertAutoSave();
if (!txtToVerify) cy.get(".editable-text-container").contains(text);
else cy.get(".editable-text-container").contains(txtToVerify);
cy.wait(2000); //for widget name to reflect!
Expand Down Expand Up @@ -840,7 +840,7 @@ Cypress.Commands.add("SetDateToToday", () => {
cy.get(".react-datepicker .react-datepicker__day--today").click({
force: true,
});
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add("enterActionValue", (value, property) => {
Expand Down Expand Up @@ -916,7 +916,7 @@ Cypress.Commands.add("enterNavigatePageName", (value) => {

Cypress.Commands.add("ClearDate", () => {
cy.get(".t--property-control-defaultdate input").clear();
cy.assertPageSave();
agHelper.AssertAutoSave();
});

Cypress.Commands.add("ClearDateFooter", () => {
Expand Down

0 comments on commit 04ce4b8

Please sign in to comment.