fix: error showing in currency input (#14958)

This commit is contained in:
Bhavin K 2022-07-20 11:36:33 +05:30 committed by GitHub
parent 5d568b7a6f
commit 23c449ac27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 198 additions and 9 deletions

View File

@ -0,0 +1,131 @@
{
"clientSchemaVersion": 1.0,
"serverSchemaVersion": 5.0,
"exportedApplication": {
"name": "Currency Input Issue",
"isPublic": false,
"pages": [{ "id": "Page1", "isDefault": true }],
"publishedPages": [{ "id": "Page1", "isDefault": true }],
"viewMode": false,
"appIsExample": false,
"unreadCommentThreads": 0.0,
"clonedFromApplicationId": "62b9902720ae3225cef293f1",
"color": "#C7F3E3",
"icon": "medical",
"slug": "currency-input-issue",
"applicationVersion": 2.0,
"isManualUpdate": false,
"deleted": false
},
"datasourceList": [],
"pageList": [
{
"unpublishedPage": {
"name": "Page1",
"slug": "page1",
"layouts": [
{
"viewMode": false,
"dsl": {
"widgetName": "MainContainer",
"backgroundColor": "none",
"rightColumn": 1224.0,
"snapColumns": 64.0,
"detachFromLayout": true,
"widgetId": "0",
"topRow": 0.0,
"bottomRow": 640.0,
"containerStyle": "none",
"snapRows": 64.0,
"parentRowSpace": 1.0,
"type": "CANVAS_WIDGET",
"canExtend": true,
"version": 59.0,
"minHeight": 650.0,
"parentColumnSpace": 1.0,
"dynamicBindingPathList": [],
"leftColumn": 0.0,
"children": [
{
"boxShadow": "none",
"widgetName": "CurrencyInput1",
"displayName": "Currency Input",
"iconSVG": "/static/media/icon.f312efcb48ce4dafb08c20291635b30b.svg",
"searchTags": ["amount", "total"],
"topRow": 4.0,
"bottomRow": 8.0,
"defaultCurrencyCode": "USD",
"parentRowSpace": 10.0,
"labelWidth": 5.0,
"autoFocus": false,
"type": "CURRENCY_INPUT_WIDGET",
"hideCard": false,
"animateLoading": true,
"parentColumnSpace": 18.0625,
"dynamicTriggerPathList": [],
"resetOnSubmit": true,
"leftColumn": 2.0,
"dynamicBindingPathList": [
{ "key": "accentColor" },
{ "key": "borderRadius" }
],
"labelPosition": "Left",
"labelStyle": "",
"isDisabled": false,
"key": "rhpg46n9mr",
"labelTextSize": "0.875rem",
"isRequired": true,
"isDeprecated": false,
"rightColumn": 22.0,
"widgetId": "bk4hqop0jo",
"accentColor": "{{appsmith.theme.colors.primaryColor}}",
"isVisible": true,
"label": "Label",
"allowCurrencyChange": false,
"version": 1.0,
"parentId": "0",
"labelAlignment": "left",
"renderMode": "CANVAS",
"isLoading": false,
"borderRadius": "{{appsmith.theme.borderRadius.appBorderRadius}}",
"decimals": 0.0,
"iconAlign": "left",
"defaultText": ""
}
]
},
"layoutOnLoadActions": [],
"validOnPageLoadActions": true,
"id": "Page1",
"deleted": false,
"policies": [],
"userPermissions": []
}
],
"userPermissions": [],
"policies": []
},
"deleted": false,
"gitSyncId": "62b996e68a38bf3f8d030646_62bac6018a38bf3f8d030683"
}
],
"actionList": [],
"actionCollectionList": [],
"updatedResources": {
"actionList": [],
"pageList": ["Page1"],
"actionCollectionList": []
},
"editModeTheme": {
"name": "Default",
"displayName": "Modern",
"isSystemTheme": true,
"deleted": false
},
"publishedTheme": {
"name": "Default",
"displayName": "Modern",
"isSystemTheme": true,
"deleted": false
}
}

View File

@ -0,0 +1,50 @@
/// <reference types="Cypress" />
import { ObjectsRegistry } from "../../../support/Objects/Registry";
import reconnectDatasourceModal from "../../../locators/ReconnectLocators";
const themelocators = require("../../../locators/ThemeLocators.json");
let homePage = ObjectsRegistry.HomePage,
agHelper = ObjectsRegistry.AggregateHelper;
const widgetName = "currencyinputwidget";
const wiggetClass = `.t--widget-${widgetName}`;
const widgetInput = `${wiggetClass} input`;
describe("Currency Input Issue", function() {
before(function() {
agHelper.ClearLocalStorageCache();
});
beforeEach(function() {
agHelper.RestoreLocalStorageCache();
});
afterEach(function() {
agHelper.SaveLocalStorageCache();
});
it("1. Import application json", function() {
cy.visit("/applications");
homePage.ImportApp("CurrencyInputIssueExport.json");
cy.wait("@importNewApplication").then((interception) => {
agHelper.Sleep();
const { isPartialImport } = interception.response.body.data;
if (isPartialImport) {
cy.get(reconnectDatasourceModal.SkipToAppBtn).click({
force: true,
});
cy.wait(2000);
} else {
homePage.AssertImport();
}
});
});
it("2. should check that the widget input is not showing any error", function() {
cy.get(widgetInput).type("123456789");
cy.focused().then(() => {
cy.get(themelocators.popover).should("not.exist");
});
});
});

View File

@ -51,7 +51,7 @@ describe("Binding the Table and input Widget", function() {
it("3. validation of column id displayed in input widgets based on sorted column", function() {
cy.SearchEntityandOpen("Input1");
cy.testJsontext("defaulttext", testdata.sortedColumn+ "}}");
cy.testJsontext("defaulttext", testdata.sortedColumn + "}}");
cy.wait("@updateLayout").should(
"have.nested.property",
"response.body.responseMeta.status",

View File

@ -51,7 +51,7 @@ describe("Binding the Table and input Widget", function() {
it("3. Validation of column id displayed in input widgets based on sorted column", function() {
cy.SearchEntityandOpen("Input1");
cy.testJsontext("defaulttext", testdata.sortedColumn+ "}}");
cy.testJsontext("defaulttext", testdata.sortedColumn + "}}");
cy.wait("@updateLayout").should(
"have.nested.property",
"response.body.responseMeta.status",

View File

@ -1,5 +1,6 @@
const dsl = require("../../../../fixtures/emptyDSL.json");
const explorer = require("../../../../locators/explorerlocators.json");
const themelocators = require("../../../../locators/ThemeLocators.json");
const widgetName = "currencyinputwidget";
const widgetInput = `.t--widget-${widgetName} input`;
@ -272,4 +273,11 @@ describe("Currency widget - ", () => {
// Check if isDirty is reset to false
cy.get(".t--widget-textwidget").should("contain", "false");
});
it("Should check that widget input is not showing any errors on input", function() {
cy.get(widgetInput).type("123456789");
cy.focused().then(() => {
cy.get(themelocators.popover).should("not.exist");
});
});
});

View File

@ -24,9 +24,9 @@ Cypress.Commands.add("enterDatasource", (datasource) => {
cy.get(apiwidget.resourceUrl)
.first()
.click({ force: true })
.type(datasource, { parseSpecialCharSequences: false })
//.type("{esc}}");
cy.assertPageSave();
.type(datasource, { parseSpecialCharSequences: false });
//.type("{esc}}");
cy.assertPageSave();
});
Cypress.Commands.add("ResponseStatusCheck", (statusCode) => {

View File

@ -736,8 +736,8 @@ Cypress.Commands.add("dragAndDropToCanvas", (widgetType, { x, y }) => {
.trigger("mousemove", x, y, { eventConstructor: "MouseEvent" })
.trigger("mousemove", x, y, { eventConstructor: "MouseEvent" })
.trigger("mouseup", x, y, { eventConstructor: "MouseEvent" });
cy.assertPageSave();
});
cy.assertPageSave();
});
Cypress.Commands.add(
"dragAndDropToWidget",

View File

@ -73,8 +73,8 @@ export default {
if (text) {
const parsed = parseFloat(
text
.replace(new RegExp("\\" + getLocaleThousandSeparator(), "g"), "")
.replace(new RegExp("\\" + getLocaleDecimalSeperator()), "."),
.replace(new RegExp(`[${getLocaleThousandSeparator()}]`, "g"), "")
.replace(new RegExp(`[${getLocaleDecimalSeperator()}]`), "."),
);
if (_.isNaN(parsed)) {