Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -28,8 +28,7 @@ describe(
EditorNavigation.SelectEntityByName("Chart1", EntityType.Widget, {}, [
"Container1",
]);
cy.get(viewWidgetsPage.chartType).last().click({ force: true });
cy.get(".t--dropdown-option").children().contains("Column chart").click();
cy.selectDropdownValue(viewWidgetsPage.chartType, "Column chart");
cy.get(
".t--property-control-charttype span.rc-select-selection-item span",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,13 @@ describe(

it("Update Placement and Verify buttons alignments", function () {
// check first button placement
cy.selectDropdownValue(
".t--property-control-placement .rc-select-selection-item",
"Between",
);
cy.selectDropdownValue(".t--property-control-placement", "Between");
// 1st btn
cy.get(firstButton)
.last()
.should("have.css", "justify-content", "space-between");
// update dropdown value
cy.selectDropdownValue(
".t--property-control-placement .rc-select-selection-item",
"Start",
);
cy.selectDropdownValue(".t--property-control-placement", "Start");
cy.get(firstButton).last().should("have.css", "justify-content", "start");
// other button style stay same
cy.get(menuButton).should("have.css", "justify-content", "center");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ describe(

it("2. should check for type of value and widget", () => {
cy.openPropertyPane(widgetName);
cy.get(".t--property-control-currency").click();
cy.get(".t--property-control-currency").type("usd");
cy.openSelectDropdown(".t--property-control-currency");
cy.searchSelectDropdown("usd");
cy.selectDropdownValue(
".t--property-control-currency input",
".t--property-control-currency",
"USD - US Dollar",
);

function enterAndTest(text, expected) {
cy.get(widgetInput).clear();
cy.wait(300);
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

Use data- attributes for selectors.*

According to the coding guidelines, use data-* attributes instead of class selectors.

Example refactor:

-cy.get(widgetInput).clear();
+cy.get('[data-cy="currency-input"]').clear();

Also applies to: 39-39, 40-40, 41-41, 42-42, 43-43, 44-44

Expand All @@ -53,7 +54,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "1");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "1");

[
//[input, {{CurrencyInput1.text}}:{{CurrencyInput1.value}}:{{CurrencyInput1.isValid}}:{{typeof CurrencyInput1.text}}:{{typeof CurrencyInput1.value}}:{{CurrencyInput1.countryCode}}:{{CurrencyInput1.currencyCode}}]
Expand All @@ -66,7 +67,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "2");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "2");

[
//[input, {{CurrencyInput1.text}}:{{CurrencyInput1.value}}:{{CurrencyInput1.isValid}}:{{typeof CurrencyInput1.text}}:{{typeof CurrencyInput1.value}}:{{CurrencyInput1.countryCode}}:{{CurrencyInput1.currencyCode}}]
Expand All @@ -80,10 +81,10 @@ describe(
cy.get(".currency-change-dropdown-trigger").should("contain", "$");

cy.openPropertyPane(widgetName);
cy.get(".t--property-control-currency").click();
cy.get(".t--property-control-currency").type("ind");
cy.openSelectDropdown(".t--property-control-currency");
cy.searchSelectDropdown("ind");
cy.selectDropdownValue(
".t--property-control-currency input",
".t--property-control-currency",
"INR - Indian Rupee",
);
enterAndTest("100.22", "100.22:100.22:true:string:number:IN:INR");
Expand All @@ -100,12 +101,13 @@ describe(
.last()
.click();
enterAndTest("100.22", "100.22:100.22:true:string:number:GB:GBP");
enterAndTest("100.22", "100.22:100.22:true:string:number:GB:GBP");
cy.get(".t--input-currency-change").should("contain", "£");
});

it("3. should accept 0 decimal option", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "0");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "0");
cy.closePropertyPane();
cy.wait(500);
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

Remove cy.wait() commands and use proper assertions.

Replace cy.wait() with proper assertions that wait for elements to be in the expected state.

Example refactor:

-cy.wait(300);
+cy.get(widgetInput).should('not.be.disabled');

Also applies to: 121-121, 191-191, 192-192, 193-193, 194-194, 195-195, 196-196, 197-197, 198-198

cy.openPropertyPane(widgetName);
Expand Down Expand Up @@ -142,7 +144,7 @@ describe(
`{{CurrencyInput1.text}}:{{CurrencyInput1.value}}`,
);
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "0");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "0");

[
//[input, {{CurrencyInput1.text}}:{{CurrencyInput1.value}}]
Expand All @@ -157,7 +159,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "1");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "1");
[
//[input, {{CurrencyInput1.text}}:{{CurrencyInput1.value}}]
["100", "100:100"],
Expand All @@ -171,7 +173,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "2");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "2");
[
//[input, {{CurrencyInput1.text}}:{{CurrencyInput1.value}}]
["100", "100:100"],
Expand Down Expand Up @@ -205,7 +207,7 @@ describe(
}

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "0");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "0");

[
//[input, expected]
Expand All @@ -221,7 +223,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "1");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "1");
[
//[input, expected]
["100", "100"],
Expand All @@ -238,7 +240,7 @@ describe(
});

cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-decimalsallowed input", "2");
cy.selectDropdownValue(".t--property-control-decimalsallowed", "2");
[
//[input, expected]
["100", "100"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe(
);

agHelper.AssertText(
commonlocators.filePickerDataFormat,
`${commonlocators.filePickerDataFormat} .rc-select-selection-item .ads-v2-text`,
"text",
"Array of Objects (CSV, XLS(X), JSON, TSV)",
);
Comment on lines 31 to 35
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

Simplify the complex selector path.

The selector path could be simplified by using a data-* attribute as per coding guidelines.

- agHelper.AssertText(
-   `${commonlocators.filePickerDataFormat} .rc-select-selection-item .ads-v2-text`,
-   "text",
-   "Array of Objects (CSV, XLS(X), JSON, TSV)",
- );
+ // Add data-testid to the element and use it directly
+ agHelper.AssertText(
+   "[data-testid=file-picker-format-text]",
+   "text",
+   "Array of Objects (CSV, XLS(X), JSON, TSV)",
+ );
📝 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
agHelper.AssertText(
commonlocators.filePickerDataFormat,
`${commonlocators.filePickerDataFormat} .rc-select-selection-item .ads-v2-text`,
"text",
"Array of Objects (CSV, XLS(X), JSON, TSV)",
);
// Add data-testid to the element and use it directly
agHelper.AssertText(
"[data-testid=file-picker-format-text]",
"text",
"Array of Objects (CSV, XLS(X), JSON, TSV)",
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ describe(

it("3. Validate DataType - NUMBER can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");

cy.get(".t--property-control-required label")
.last()
.click({ force: true });

cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");
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 duplicate dropdown selection.

The dropdown value is already selected in line 55. This duplicate selection is unnecessary.

-cy.selectDropdownValue(".t--property-control-datatype", "Number");
📝 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.selectDropdownValue(".t--property-control-datatype", "Number");
// (The duplicate dropdown selection has been removed)

[
{
input: "invalid",
Expand Down Expand Up @@ -101,7 +101,7 @@ describe(

it("4. Validate DataType - PASSWORD can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Password");
cy.selectDropdownValue(".t--property-control-datatype", "Password");
[
{
input: "test",
Expand Down Expand Up @@ -136,7 +136,7 @@ describe(

it("5. Validate DataType - EMAIL can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Email");
cy.selectDropdownValue(".t--property-control-datatype", "Email");

cy.get(".t--property-control-required label")
.last()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe(
cy.wait(300);
cy.get(widgetInput).should("contain.value", "");

cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");

cy.get(widgetInput).clear();
cy.get(widgetInput).type("1.0010{enter}"); //Clicking enter submits the form here
Expand All @@ -37,7 +37,7 @@ describe(

it("3. Validate DataType - TEXT can be entered into Input widget", () => {
cy.selectDropdownValue(
".t--property-control-datatype input",
".t--property-control-datatype",
"Single-line text",
);
[
Expand Down Expand Up @@ -112,7 +112,7 @@ describe(

it("4. Validate DataType - NUMBER can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");
[
{
input: "invalid",
Expand Down Expand Up @@ -157,7 +157,7 @@ describe(
.last()
.click({ force: true });

cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");
[
{
input: "invalid",
Expand Down Expand Up @@ -200,7 +200,7 @@ describe(

it("5. Validate DataType - PASSWORD can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Password");
cy.selectDropdownValue(".t--property-control-datatype", "Password");
[
{
input: "test",
Expand Down Expand Up @@ -273,7 +273,7 @@ describe(

it("6. Validate DataType - EMAIL can be entered into Input widget", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(".t--property-control-datatype input", "Email");
cy.selectDropdownValue(".t--property-control-datatype", "Email");
[
{
input: "test",
Expand Down Expand Up @@ -361,7 +361,7 @@ describe(
it("8. onSubmit should be triggered with the whole input value", () => {
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(
".t--property-control-datatype input",
".t--property-control-datatype",
"Single-line text",
);
cy.get(".t--property-control-required label")
Expand Down Expand Up @@ -415,7 +415,7 @@ describe(
"anotherText:anotherText:true",
);

cy.selectDropdownValue(".t--property-control-datatype input", "Number");
cy.selectDropdownValue(".t--property-control-datatype", "Number");

cy.updateCodeInput(".t--property-control-defaultvalue", `{{1}}`);
// wait for evaluations
Expand All @@ -439,7 +439,7 @@ describe(
// Init isDirty
cy.openPropertyPane(widgetName);
cy.selectDropdownValue(
".t--property-control-datatype input",
".t--property-control-datatype",
"Single-line text",
);
cy.updateCodeInput(".t--property-control-defaultvalue", "a");
Expand Down Expand Up @@ -490,7 +490,7 @@ describe(
cy.get(widgetInput).should("have.attr", "autocomplete", "off");

//select a non email or password option
cy.selectDropdownValue(".t--property-control-datatype input", "text");
cy.selectDropdownValue(".t--property-control-datatype", "text");
//autofill toggle should not be present as this restores autofill to be enabled
cy.get(".t--property-control-allowautofill input").should("not.exist");
//autocomplete attribute should not be present in the text widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@ import * as _ from "../../../../../support/Objects/ObjectsCore";

const widgetName = "phoneinputwidget";
const widgetInput = `.t--widget-${widgetName} input`;
const searchAndSelectOption = (optionValue) => {
cy.get(".t--property-control-defaultcountrycode input")
.last()
.scrollIntoView()
.click({ force: true })
.type(optionValue.substring(0, 3));
cy.get(".t--dropdown-option")
.children()
.contains(optionValue)
.click({ force: true });
};

describe(
"Phone input widget - ",
{ tags: ["@tag.Widget", "@tag.PhoneInput", "@tag.Binding"] },
Expand All @@ -21,7 +11,7 @@ describe(
_.agHelper.AddDsl("emptyDSL");
});

it("1. Add new dropdown widget", () => {
it("1. Add new phone input widget", () => {
cy.dragAndDropToCanvas(widgetName, { x: 300, y: 300 });
cy.get(`.t--widget-${widgetName}`).should("exist");
cy.dragAndDropToCanvas("textwidget", { x: 300, y: 500 });
Expand All @@ -39,7 +29,12 @@ describe(
cy.get(".t--widget-textwidget").should("contain", "(999) 999-9999:US:+1");

cy.openPropertyPane(widgetName);
searchAndSelectOption("Afghanistan (+93)");
cy.openSelectDropdown(".t--property-control-defaultcountrycode");
cy.searchSelectDropdown("Afg");
cy.selectDropdownValue(
".t--property-control-defaultcountrycode",
"Afghanistan (+93)",
);
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("1234567890");
Expand All @@ -62,14 +57,24 @@ describe(
cy.get(".t--property-control-enableformatting label")
.last()
.click({ force: true });
searchAndSelectOption("United States / Canada (+1)");
cy.openSelectDropdown(".t--property-control-defaultcountrycode");
cy.searchSelectDropdown("United States / Canada");
cy.selectDropdownValue(
".t--property-control-defaultcountrycode",
"United States / Canada (+1)",
);
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("9999999999");
cy.get(".t--widget-textwidget").should("contain", "9999999999:US:+1");

cy.openPropertyPane(widgetName);
searchAndSelectOption("India (+91)");
cy.openSelectDropdown(".t--property-control-defaultcountrycode");
cy.searchSelectDropdown("India");
cy.selectDropdownValue(
".t--property-control-defaultcountrycode",
"India (+91)",
);
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("1234567890");
Expand Down Expand Up @@ -131,13 +136,11 @@ describe(

// Select the Currency dropdown option from property pane
// and enter a value that has space and returns 0 results
cy.get(".t--property-control-defaultcountrycode input")
.first()
.click()
.type("AFDB (+93)");
cy.openSelectDropdown(".t--property-control-defaultcountrycode");
cy.searchSelectDropdown("AFDB");

// assert that the dropdown is still option
cy.get(".t--property-control-defaultcountrycode input").should(
cy.get(".ads-v2-select__dropdown .rc-select-item-empty").should(
"be.visible",
);
});
Expand Down
4 changes: 2 additions & 2 deletions app/client/cypress/locators/ViewWidgets.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"imageWidget": ".t--draggable-imagewidget",
"chartWidget": ".t--draggable-chartwidget",
"chartType": ".t--property-control-charttype input",
"chartType": ".t--property-control-charttype",
"chartTypeText": ".t--property-control-charttype",
"mapType": ".t--property-control-maptype .rc-select-selection-item",
"destin": ".appsmith_widget_01ewdomru7",
Expand Down Expand Up @@ -36,4 +36,4 @@
"pickMyLocation": ".t--draggable-mapwidget div[title='Pick My Location']",
"mapChartEntityLabels": ".t--draggable-mapchartwidget text",
"listWidget": ".t--draggable-listwidget"
}
}
Loading
Loading