test: replace togglebarDisable with CheckUncheck (#34069)

This replaces togglebarDisable with CheckUncheck from Ts helper

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

EE PR: https://github.com/appsmithorg/appsmith-ee/pull/4393

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

- **Refactor**
- Updated test scripts to use a new method for interacting with checkbox
elements, improving consistency and reliability.
- **Chores**
- Added new locators for client-side search and fixed footer input
fields for better test coverage.
<!-- 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/9438128926>
> Commit: dcdb3ab2c366de74cdea844517ff67864b379551
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9438128926&attempt=2"
target="_blank">Click here!</a>

<!-- end of auto-generated comment: Cypress test results  -->
This commit is contained in:
NandanAnantharamu 2024-06-10 19:55:17 +05:30 committed by GitHub
parent e0de1f7038
commit 3a895f9dd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 70 additions and 73 deletions

View File

@ -69,9 +69,7 @@ describe(
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget, {}, [
"Container3",
]);
cy.togglebarDisable(
".t--property-control-clientsidesearch input[type='checkbox']",
);
agHelper.CheckUncheck(commonlocators.clientSideSearch, false);
cy.get(".t--widget-tablewidgetv2 .t--search-input")
.first()
.type("Currey");

View File

@ -1,4 +1,5 @@
import * as _ from "../../../../support/Objects/ObjectsCore";
const commonlocators = require("../../../../locators/commonlocators.json");
describe(
"Test Create Api and Bind to Table widget V2",
@ -32,9 +33,7 @@ describe(
expect(tabData).to.eq("#2");
});
// Disable Client Search
cy.togglebarDisable(
".t--property-control-clientsidesearch input[type='checkbox']",
);
_.agHelper.CheckUncheck(commonlocators.clientSideSearch, false);
cy.wait(1000); //wait & then read the table value
// Verify Client Search doesnt work
cy.readTableV2dataPublish("0", "0").then((tabData) => {

View File

@ -70,9 +70,7 @@ describe(
EditorNavigation.SelectEntityByName("Table1", EntityType.Widget, {}, [
"Container3",
]);
cy.togglebarDisable(
".t--property-control-enableclientsidesearch input[type='checkbox']",
);
agHelper.CheckUncheck(commonlocators.enableClientSideSearch, false);
cy.get(".t--widget-tablewidget .t--search-input").first().type("Currey");
cy.wait(3000);

View File

@ -1,4 +1,5 @@
import * as _ from "../../../../support/Objects/ObjectsCore";
const commonlocators = require("../../../../locators/commonlocators.json");
describe(
"Test Create Api and Bind to Table widget",
@ -33,9 +34,7 @@ describe(
expect(tabData).to.eq("#2");
});
// Disable Client Search
cy.togglebarDisable(
".t--property-control-enableclientsidesearch input[type='checkbox']",
);
_.agHelper.CheckUncheck(commonlocators.enableClientSideSearch, false);
cy.wait(1000); //wait & then read the table value
// Verify Client Search doesnt work
cy.readTabledataPublish("0", "0").then((tabData) => {

View File

@ -51,13 +51,13 @@ describe(
});
it("Checkbox Functionality To Check Enabled Widget", function () {
cy.openPropertyPane("checkboxwidget");
cy.togglebarDisable(commonlocators.Disablejs + " " + "input");
_.agHelper.CheckUncheck(commonlocators.Disablejs + " " + "input", false);
_.deployMode.DeployApp();
cy.get(publish.checkboxWidget + " " + "input").should("be.enabled");
});
it("Checkbox Functionality To Unchecked Visible Widget", function () {
cy.openPropertyPane("checkboxwidget");
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
cy.get(publish.checkboxWidget + " " + "input").should("not.exist");
});

View File

@ -79,7 +79,10 @@ describe(
cy.moveToContentTab();
// Enable and publish
cy.togglebarDisable(commonlocators.disableCheckbox);
_.agHelper.CheckUncheck(
commonlocators.disableCheckbox,
false,
);
_.deployMode.DeployApp();
// Disabled icon should NOT be visible
@ -109,7 +112,7 @@ describe(
cy.moveToContentTab();
// Visibilty OFF and publish
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
// Video should NOT be streaming
@ -206,7 +209,7 @@ describe(
cy.moveToContentTab();
// Enable and publish
cy.togglebarDisable(commonlocators.disableCheckbox);
_.agHelper.CheckUncheck(commonlocators.disableCheckbox, false);
_.deployMode.DeployApp();
// Button should be enabled
@ -229,7 +232,7 @@ describe(
cy.moveToContentTab();
// Visibilty OFF and publish
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
// Button should NOT be visible

View File

@ -153,7 +153,7 @@ describe(
it("Dropdown Functionality To Check disabled Widget", function () {
cy.openPropertyPane("selectwidget");
// Disable the visible JS
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
// Verify the disabled visible JS
cy.get(publish.selectwidget + " " + "input").should("not.exist");

View File

@ -105,7 +105,7 @@ describe(
it("4. Form Widget Functionality To Unchecked Visible Widget", function () {
cy.openPropertyPane("formwidget");
// Uncheck the visble JS
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
// Verify the unchecked visible JS
cy.get(publish.formWidget).should("not.exist");

View File

@ -59,7 +59,7 @@ describe(
it("3. Image Widget Functionality To Check/Uncheck Visible Widget", function () {
deployMode.NavigateBacktoEditor();
cy.openPropertyPane("imagewidget");
cy.togglebarDisable(commonlocators.visibleCheckbox);
agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
deployMode.DeployApp();
cy.get(publish.imageWidget).should("not.exist");
deployMode.NavigateBacktoEditor();

View File

@ -91,7 +91,7 @@ describe(
//isSpellCheck: false
cy.openPropertyPane("inputwidgetv2");
cy.togglebarDisable(commonlocators.spellCheck + " " + "input");
_.agHelper.CheckUncheck(commonlocators.spellCheck + " " + "input", false);
_.deployMode.DeployApp();
cy.get(publish.inputWidget + " " + "input")
.invoke("attr", "spellcheck")
@ -108,14 +108,14 @@ describe(
//Input Widget Functionality To Check Enabled Widget
cy.openPropertyPane("inputwidgetv2");
cy.togglebarDisable(commonlocators.Disablejs + " " + "input");
_.agHelper.CheckUncheck(commonlocators.Disablejs + " " + "input", false);
_.deployMode.DeployApp();
cy.get(publish.inputWidget + " " + "input").should("be.enabled");
_.deployMode.NavigateBacktoEditor();
});
it("5. Input Functionality To Unchecked Visible Widget", function () {
cy.openPropertyPane("inputwidgetv2");
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
cy.get(publish.inputWidget + " " + "input").should("not.exist");
_.deployMode.NavigateBacktoEditor();

View File

@ -136,7 +136,7 @@ describe(
deployMode.NavigateBacktoEditor();
EditorNavigation.SelectEntityByName("JSONForm1", EntityType.Widget);
cy.openFieldConfiguration("name");
cy.togglebarDisable(widgetsLocators.selectWidgetDisabled);
agHelper.CheckUncheck(widgetsLocators.selectWidgetDisabled, false);
validateAutocompleteAttributeInJSONForm();
});
@ -175,7 +175,7 @@ describe(
cy.get(`${fieldPrefix}-check input`).should("be.checked");
// hides field when visible switched off
cy.togglebarDisable(widgetsLocators.visible);
agHelper.CheckUncheck(widgetsLocators.visible, false);
deployMode.DeployApp();
cy.get(`${fieldPrefix}-check`).should("not.exist");
deployMode.NavigateBacktoEditor();

View File

@ -194,7 +194,7 @@ describe(
cy.get(`${fieldPrefix}-radio input`).should("have.value", "Y");
// hides field when visible switched off"
cy.togglebarDisable(widgetsLocators.visible);
agHelper.CheckUncheck(widgetsLocators.visible, false);
cy.get(`${fieldPrefix}-radio`).should("not.exist");
cy.wait(500);
agHelper.CheckUncheck(widgetsLocators.visible);

View File

@ -1,5 +1,5 @@
import * as _ from "../../../../../support/Objects/ObjectsCore";
const commonlocators = require("../../../../../locators/commonlocators.json");
describe(
"JSONForm Footer spec",
{ tags: ["@tag.Widget", "@tag.JSONForm"] },
@ -42,7 +42,7 @@ describe(
it("2. sticks to the content when fixed footer is off", () => {
// Disable fixed footer
cy.togglebarDisable(".t--property-control-fixedfooter input");
_.agHelper.CheckUncheck(commonlocators.fixedFooterInput, false);
// Check if there is a gap between body and footer
cy.get(".t--jsonform-body").then(($body) => {
@ -82,7 +82,7 @@ describe(
it("4. floats to the bottom when fixed footer is false and content overflows", () => {
// Disable fixed footer
cy.togglebarDisable(".t--property-control-fixedfooter input");
_.agHelper.CheckUncheck(commonlocators.fixedFooterInput, false);
// Check if footer is floating
cy.get(".t--draggable-jsonformwidget")

View File

@ -240,7 +240,7 @@ describe(
// migrant.visible -> false
cy.openFieldConfiguration("migrant", false);
cy.togglebarDisable(`${propertyControlPrefix}-visible input`);
agHelper.CheckUncheck(`${propertyControlPrefix}-visible input`, false);
cy.get(backBtn).click({ force: true }).wait(500);
// address.street.required -> true
@ -258,7 +258,7 @@ describe(
agHelper.CheckUncheck(`${propertyControlPrefix}-required input`);
cy.get(backBtn).click({ force: true }).wait(500);
cy.openFieldConfiguration("year", false);
cy.togglebarDisable(`${propertyControlPrefix}-visible input`);
agHelper.CheckUncheck(`${propertyControlPrefix}-visible input`, false);
cy.get(backBtn).click({ force: true }).wait(500);
cy.closePropertyPane();

View File

@ -193,7 +193,7 @@ describe(
);
cy.openFieldConfiguration("age");
cy.togglebarDisable(`${propertyControlPrefix}-visible input`);
agHelper.CheckUncheck(`${propertyControlPrefix}-visible input`, false);
cy.openPropertyPane("textwidget");
cy.testJsontext("text", "{{JSON.stringify(JSONForm1.formData)}}");
@ -216,10 +216,13 @@ describe(
cy.openPropertyPane("jsonformwidget");
propPane.EnterJSContext("Source data", JSON.stringify(schema), true);
cy.togglebarDisable(`${propertyControlPrefix}-hiddenfieldsindata input`);
agHelper.CheckUncheck(
`${propertyControlPrefix}-hiddenfieldsindata input`,
false,
);
cy.openFieldConfiguration("age");
cy.togglebarDisable(`${propertyControlPrefix}-visible input`);
agHelper.CheckUncheck(`${propertyControlPrefix}-visible input`, false);
cy.openPropertyPane("textwidget");
cy.testJsontext("text", "{{JSON.stringify(JSONForm1.formData)}}");

View File

@ -155,11 +155,11 @@ describe(
// hide education field
cy.openFieldConfiguration("education");
cy.togglebarDisable(widgetsPage.visible);
agHelper.CheckUncheck(widgetsPage.visible, false);
cy.get(backBtn).click({ force: true }).wait(500);
// hide name field
cy.openFieldConfiguration("name");
cy.togglebarDisable(widgetsPage.visible);
agHelper.CheckUncheck(widgetsPage.visible, false);
// publish the app
deployMode.DeployApp();

View File

@ -13,7 +13,7 @@ describe("List v2- Tabs Widget", { tags: ["@tag.Widget", "@tag.List"] }, () => {
cy.get(".t--page-switch-tab.is-active").contains("Tab 1");
// Disable Scroll Content
cy.togglebarDisable(commonlocators.scrollView);
_.agHelper.CheckUncheck(commonlocators.scrollView, false);
// Check if disabled
cy.get(commonlocators.scrollView).parent().should("not.be.checked");
// Check if Tab 1 still selected

View File

@ -146,7 +146,10 @@ describe(
cy.get(commonlocators.listPaginateActivePage).should("have.text", "1"),
);
cy.togglebarDisable(commonlocators.serverSidePaginationCheckbox);
_.agHelper.CheckUncheck(
commonlocators.serverSidePaginationCheckbox,
false,
);
});
},
);

View File

@ -1,6 +1,7 @@
/// <reference types="Cypress" />
const commonlocators = require("../../../../../locators/commonlocators.json");
const widgetsPage = require("../../../../../locators/Widgets.json");
const formWidgetsPage = require("../../../../../locators/FormWidgets.json");
const publish = require("../../../../../locators/publishWidgetspage.json");
import data from "../../../../../fixtures/TestDataSet1.json";
@ -103,9 +104,7 @@ describe(
it("4. Does not clear the search field when widget is closed and serverSideFiltering is on", () => {
// Turn on server side filtering for the widget
_.agHelper.CheckUncheck(
'.t--property-control-serversidefiltering input[type="checkbox"]',
);
_.agHelper.CheckUncheck(widgetsPage.serversideFilteringInput);
// open the widget
cy.get(formWidgetsPage.multiselectwidgetv2)
.find(".rc-select-selection-search-input")
@ -131,11 +130,12 @@ describe(
.invoke("val")
.should("not.be.empty");
// Turn off the filterable property for the widget
cy.togglebarDisable(commonlocators.allowsearchingInputTypeCheckbox);
// Turn off server side filtering for the widget
cy.togglebarDisable(
'.t--property-control-serversidefiltering input[type="checkbox"]',
_.agHelper.CheckUncheck(
commonlocators.allowsearchingInputTypeCheckbox,
false,
);
// Turn off server side filtering for the widget
_.agHelper.CheckUncheck(widgetsPage.serversideFilteringInput, false);
});
it("5. Dropdown Functionality To Validate Options", function () {
@ -299,7 +299,7 @@ describe(
});
it("8. Dropdown Functionality To Unchecked Visible Widget", function () {
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
cy.get(publish.multiselectwidgetv2 + " " + ".rc-select-selector").should(
"not.exist",

View File

@ -108,9 +108,7 @@ describe(
it("4. multi Select widget selection is not cleared when the widget is server side filtered", () => {
// Turn off server side filtering for the widget
cy.togglebarDisable(
'.t--property-control-serversidefiltering input[type="checkbox"]',
);
_.agHelper.CheckUncheck(widgetsPage.serversideFilteringInput, false);
_.propPane.UpdatePropertyFieldValue("Source Data", "");

View File

@ -100,7 +100,7 @@ describe(
});
it("5. To Unchecked Visible Widget", function () {
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
cy.get(
publish.multiselecttreewidget + " " + ".rc-tree-select-multiple",

View File

@ -29,7 +29,7 @@ describe(
.should("exist")
.should("have.css", "animation");
// disable infinite loading
cy.togglebarDisable(widgets.infiniteLoading);
agHelper.CheckUncheck(widgets.infiniteLoading, false);
// show determinate linear progress
cy.get("[data-testid='50']").should("exist");
});
@ -49,7 +49,7 @@ describe(
// show label
cy.get("[data-testid='60']").first().next().should("contain.text", "60");
// disable show result
cy.togglebarDisable(widgets.showResult);
agHelper.CheckUncheck(widgets.showResult, false);
// does not show any label
cy.get("[data-testid='60']").first().next().should("not.exist");
});
@ -77,7 +77,7 @@ describe(
.should("exist")
.should("have.css", "animation");
// disable infinite loading
cy.togglebarDisable(widgets.infiniteLoading);
agHelper.CheckUncheck(widgets.infiniteLoading, false);
cy.wait("@updateLayout").should(
"have.nested.property",
"response.body.responseMeta.status",
@ -100,7 +100,7 @@ describe(
// show label
cy.get("[data-testid='circular-label']").should("contain.text", "50");
// disable show result
cy.togglebarDisable(widgets.showResult);
agHelper.CheckUncheck(widgets.showResult, false);
// does not show any label
cy.get("[data-testid='circular-label']").should("not.exist");
});
@ -120,7 +120,7 @@ describe(
.invoke("css", "stroke-dashoffset")
.and("match", /-/);
// disable counterclockwise
cy.togglebarDisable(widgets.counterclockwise);
agHelper.CheckUncheck(widgets.counterclockwise, false);
// show the progress in a clockwise
cy.get("[data-testvalue='50']")
.invoke("css", "stroke-dashoffset")

View File

@ -55,14 +55,14 @@ describe(
//Switch Functionality To Check Enabled Widget
cy.openPropertyPane("switchwidget");
cy.togglebarDisable(commonlocators.Disablejs + " " + "input");
_.agHelper.CheckUncheck(commonlocators.Disablejs + " " + "input", false);
_.deployMode.DeployApp();
cy.get(publish.switchwidget + " " + "input").should("be.enabled");
_.deployMode.NavigateBacktoEditor();
//Switch Functionality To Unchecked Visible Widget
cy.openPropertyPane("switchwidget");
cy.togglebarDisable(commonlocators.visibleCheckbox);
_.agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
_.deployMode.DeployApp();
cy.get(publish.switchwidget + " " + "input").should("not.exist");
_.deployMode.NavigateBacktoEditor();

View File

@ -63,7 +63,7 @@ describe("Tab widget test", { tags: ["@tag.Widget", "@tag.Tab"] }, function () {
it("3. Tab Widget Functionality To Unchecked Visible Widget", function () {
cy.openPropertyPane("tabswidget");
cy.togglebarDisable(commonlocators.visibleCheckbox);
agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
deployMode.DeployApp();
cy.get(publish.tabWidget).should("not.exist");
deployMode.NavigateBacktoEditor();

View File

@ -100,7 +100,7 @@ describe(
cy.openPropertyPane("tablewidget");
// Disable isSortable
// Confirm if isSortable is false
cy.togglebarDisable(commonlocators.isSortable_tablev1);
_.agHelper.CheckUncheck(commonlocators.isSortable_tablev1, false);
// Publish App
_.deployMode.DeployApp();

View File

@ -87,7 +87,7 @@ describe(
cy.openPropertyPane("tablewidgetv2");
// Disable isSortable
// Confirm if isSortable is false
cy.togglebarDisable(commonlocators.isSortable);
_.agHelper.CheckUncheck(commonlocators.isSortable, false);
// Publish App
_.deployMode.DeployApp();

View File

@ -95,7 +95,7 @@ describe(
});
it("5. To Unchecked Visible Widget", function () {
cy.togglebarDisable(commonlocators.visibleCheckbox);
agHelper.CheckUncheck(commonlocators.visibleCheckbox, false);
deployMode.DeployApp();
cy.get(
publish.singleselecttreewidget + " " + ".rc-tree-select-single",

View File

@ -53,7 +53,7 @@ describe(
it("3. toggle of allow clear selection", () => {
cy.openPropertyPane("singleselecttreewidget");
// toggle off allow clear selection
cy.togglebarDisable(commonlocators.allowclearingValueInput);
_.agHelper.CheckUncheck(commonlocators.allowclearingValueInput, false);
// assert if cancel icon does not exists on the widget input
cy.get(formWidgetsPage.singleselecttreeWidget)
.find(".rc-tree-select-clear")

View File

@ -237,5 +237,8 @@
"allowclearingValueInput": ".t--property-control-allowclearingvalue input[type='checkbox']",
"allowcountrycodechangeInput": ".t--property-control-allowcountrycodechange input[type='checkbox']",
"allowsearchingInput": ".t--property-control-allowsearching input",
"allowsearchingInputTypeCheckbox": ".t--property-control-allowsearching input[type='checkbox']"
"allowsearchingInputTypeCheckbox": ".t--property-control-allowsearching input[type='checkbox']",
"clientSideSearch": ".t--property-control-clientsidesearch input[type='checkbox']",
"enableClientSideSearch": ".t--property-control-enableclientsidesearch input[type='checkbox']",
"fixedFooterInput": ".t--property-control-fixedfooter input"
}

View File

@ -128,7 +128,7 @@ Cypress.Commands.add("testSelfSignedCertificateSettingsInREST", (isOAuth2) => {
} else {
cy.get(datasource.useCertInAuth).should("not.exist");
}
cy.togglebarDisable(datasource.useSelfSignedCert);
agHelper.CheckUncheck(datasource.useSelfSignedCert, false);
});
Cypress.Commands.add("addBasicProfileDetails", (username, password) => {

View File

@ -1018,13 +1018,6 @@ Cypress.Commands.add("getAlert", (eventName, value = "hello") => {
);
});
Cypress.Commands.add("togglebar", (value) => {
cy.get(value).check({ force: true }).should("be.checked");
});
Cypress.Commands.add("togglebarDisable", (value) => {
cy.get(value).uncheck({ force: true }).should("not.checked");
});
Cypress.Commands.add("addQueryFromLightningMenu", (QueryName) => {
cy.get(commonlocators.dropdownSelectButton)
.first()
@ -1180,7 +1173,7 @@ Cypress.Commands.add("ExportVerify", (togglecss, name) => {
cy.get(".t--draggable-tablewidget button")
.invoke("attr", "aria-label")
.should("contain", name);
cy.togglebarDisable(togglecss);
agHelper.CheckUncheck(togglecss, false);
});
Cypress.Commands.add("getTableDataSelector", (rowNum, colNum) => {