Skip to content

Commit

Permalink
feat: Provide option in phone input widget to turn off auto formatting (
Browse files Browse the repository at this point in the history
  • Loading branch information
sbalaji1192 authored Feb 11, 2022
1 parent c992bd5 commit 85cc3f3
Show file tree
Hide file tree
Showing 7 changed files with 1,131 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe("Phone input widget - ", () => {

it("should check for the format and dialCode", () => {
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(300);
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("9999999999");
cy.get(".t--widget-textwidget").should("contain", "(999) 999-9999:US:+1");

Expand All @@ -33,9 +33,9 @@ describe("Phone input widget - ", () => {
"Afghanistan (+93)",
);
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(300);
cy.get(`.t--widget-${widgetName} input`).type("1111111111");
cy.get(".t--widget-textwidget").should("contain", "1111111111:AF:+93");
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("1234567890");
cy.get(".t--widget-textwidget").should("contain", "1234567890:AF:+93");
cy.get(".t--input-country-code-change").should("contain", "🇦🇫+93");

cy.get(".t--property-control-allowcountrycodechange label")
Expand All @@ -50,10 +50,34 @@ describe("Phone input widget - ", () => {
.last()
.click();
cy.get(`.t--widget-${widgetName} input`).clear();
cy.wait(300);
cy.wait(500);
cy.get(`.t--widget-${widgetName} input`).type("9999999999");
cy.get(".t--widget-textwidget").should("contain", "99999 99999:IN:+91");
cy.get(".t--input-country-code-change").should("contain", "🇮🇳+91");

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

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);
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");
cy.get(".t--widget-textwidget").should("contain", "1234567890:IN:+91");
cy.get(".t--input-country-code-change").should("contain", "🇮🇳+91");
});

it("should check that widget input resets on submit", () => {
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/constants/WidgetConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const layoutConfigurations: LayoutConfigurations = {
FLUID: { minWidth: -1, maxWidth: -1 },
};

export const LATEST_PAGE_VERSION = 51;
export const LATEST_PAGE_VERSION = 52;

export const GridDefaults = {
DEFAULT_CELL_SIZE: 1,
Expand Down
6 changes: 6 additions & 0 deletions app/client/src/utils/DSLMigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { migrateMapWidgetIsClickedMarkerCentered } from "./migrations/MapWidget"
import { DSLWidget } from "widgets/constants";
import { migrateRecaptchaType } from "./migrations/ButtonWidgetMigrations";
import { PrivateWidgets } from "entities/DataTree/dataTreeFactory";
import { migratePhoneInputWidgetAllowFormatting } from "./migrations/PhoneInputWidgetMigrations";

/**
* adds logBlackList key for all list widget children
Expand Down Expand Up @@ -1042,6 +1043,11 @@ export const transformDSL = (
* We're skipping this to fix a bad table migration - migrateTableWidgetNumericColumnName
* it overwrites the computedValue of the table columns
*/
currentDSL.version = 51;
}

if (currentDSL.version === 51) {
currentDSL = migratePhoneInputWidgetAllowFormatting(currentDSL);
currentDSL.version = LATEST_PAGE_VERSION;
}

Expand Down
Loading

0 comments on commit 85cc3f3

Please sign in to comment.