feat: Multiple Options Paste and Routing Form improvements related to Select fields (#15706)
* Add handlePaste function and integrate it with options fields * Prevents function running if user does not paste a list, allows list items to be pasted without deleting following items * Subs useState for rhf useWatch to fix issues with multiple form fields * Sets options array as optional property in zod schema * Assigns default value to options array to fix possibly undefined type errors * Sets placedholder property as optional * maps selectText to options on mount * Removes comma & semicolon delimiting for pasted lists (new line only) & defines regex as a constant * Sets default value of placeholder to empty string, provides default fallback for component text field if placeholder is omitted. * Fix type error on placeholder * Extracts handlePaste to service function & tests thoroughly * Some improvements and tests arent needed * More fixes * Fix reporting as well * TS fixes * Do transforms to and fro from label * Add unit tests * Unit test reporting * Test Improvements * Self review feedback addressed --------- Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]>
This commit is contained in:
27 files changed
+1221
-228
No files matched your search
@@ -33,6 +33,10 @@ export const createRoutingFormsFixture = () => {
|
||||
label: string;
|
||||
identifier?: string;
|
||||
required: boolean;
|
||||
options?: {
|
||||
label: string;
|
||||
id: string | null;
|
||||
}[];
|
||||
}[];
|
||||
}) {
|
||||
return await prisma.app_RoutingForms_Form.create({
|
||||
|
||||
@@ -301,6 +301,10 @@ export const createUsersFixture = (
|
||||
}
|
||||
|
||||
if (scenario.seedRoutingForms) {
|
||||
const option2Uuid = "d1302635-9f12-17b1-9153-c3a854649182";
|
||||
const option1Uuid = "d1292635-9f12-17b1-9153-c3a854649182";
|
||||
const multiSelectLegacyFieldUuid = "d4292635-9f12-17b1-9153-c3a854649182";
|
||||
const multiSelectFieldUuid = "d9892635-9f12-17b1-9153-c3a854649182";
|
||||
await prisma.app_RoutingForms_Form.create({
|
||||
data: {
|
||||
routes: [
|
||||
@@ -366,6 +370,26 @@ export const createUsersFixture = (
|
||||
},
|
||||
{
|
||||
id: "aa8ba8b9-0123-4456-b89a-b182623406d8",
|
||||
action: { type: "customPageMessage", value: "Multiselect(Legacy) chosen" },
|
||||
queryValue: {
|
||||
id: "aa8ba8b9-0123-4456-b89a-b182623406d8",
|
||||
type: "group",
|
||||
children1: {
|
||||
"b98a8abb-cdef-4012-b456-718262343d27": {
|
||||
type: "rule",
|
||||
properties: {
|
||||
field: multiSelectLegacyFieldUuid,
|
||||
value: [["Option-2"]],
|
||||
operator: "multiselect_equals",
|
||||
valueSrc: ["value"],
|
||||
valueType: ["multiselect"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "bb9ea8b9-0123-4456-b89a-b182623406d8",
|
||||
action: { type: "customPageMessage", value: "Multiselect chosen" },
|
||||
queryValue: {
|
||||
id: "aa8ba8b9-0123-4456-b89a-b182623406d8",
|
||||
@@ -374,8 +398,8 @@ export const createUsersFixture = (
|
||||
"b98a8abb-cdef-4012-b456-718262343d27": {
|
||||
type: "rule",
|
||||
properties: {
|
||||
field: "d4292635-9f12-17b1-9153-c3a854649182",
|
||||
value: [["Option-2"]],
|
||||
field: multiSelectFieldUuid,
|
||||
value: [[option2Uuid]],
|
||||
operator: "multiselect_equals",
|
||||
valueSrc: ["value"],
|
||||
valueType: ["multiselect"],
|
||||
@@ -399,13 +423,30 @@ export const createUsersFixture = (
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
id: "d4292635-9f12-17b1-9153-c3a854649182",
|
||||
id: multiSelectLegacyFieldUuid,
|
||||
type: "multiselect",
|
||||
label: "Multi Select",
|
||||
label: "Multi Select(with Legacy `selectText`)",
|
||||
identifier: "multi",
|
||||
selectText: "Option-1\nOption-2",
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
id: multiSelectFieldUuid,
|
||||
type: "multiselect",
|
||||
label: "Multi Select",
|
||||
identifier: "multi-new-format",
|
||||
options: [
|
||||
{
|
||||
id: option1Uuid,
|
||||
label: "Option-1",
|
||||
},
|
||||
{
|
||||
id: option2Uuid,
|
||||
label: "Option-2",
|
||||
},
|
||||
],
|
||||
required: false,
|
||||
},
|
||||
],
|
||||
user: {
|
||||
connect: {
|
||||
|
||||
@@ -647,6 +647,7 @@ test.describe("FORM_SUBMITTED", async () => {
|
||||
responses: {
|
||||
name: {
|
||||
value: "John Doe",
|
||||
response: "John Doe",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -673,14 +674,33 @@ test.describe("FORM_SUBMITTED", async () => {
|
||||
identifier: "name",
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
type: "multiselect",
|
||||
label: "Multi Select",
|
||||
identifier: "multi",
|
||||
required: true,
|
||||
options: [
|
||||
{
|
||||
label: "Option-1",
|
||||
id: "1",
|
||||
},
|
||||
{
|
||||
label: "Option-2",
|
||||
id: "2",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
await gotoRoutingLink({ page, formId: form.id });
|
||||
const fieldName = "name";
|
||||
await page.fill(`[data-testid="form-field-${fieldName}"]`, "John Doe");
|
||||
const textFieldIdentifier = "name";
|
||||
const multiSelectFieldIdentifier = "multi";
|
||||
await page.fill(`[data-testid="form-field-${textFieldIdentifier}"]`, "John Doe");
|
||||
await page.click(`[data-testid="form-field-${multiSelectFieldIdentifier}"]`); // Open dropdown
|
||||
await page.click("text=Option-2"); // Select option
|
||||
page.click('button[type="submit"]');
|
||||
|
||||
await webhookReceiver.waitForRequestCount(1);
|
||||
@@ -699,10 +719,23 @@ test.describe("FORM_SUBMITTED", async () => {
|
||||
responses: {
|
||||
name: {
|
||||
value: "John Doe",
|
||||
response: "John Doe",
|
||||
},
|
||||
multi: {
|
||||
value: ["Option-2"],
|
||||
response: [
|
||||
{
|
||||
id: "2",
|
||||
label: "Option-2",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* Legacy fields Start */
|
||||
name: "John Doe",
|
||||
multi: ["Option-2"],
|
||||
/* Legacy fields End */
|
||||
});
|
||||
|
||||
webhookReceiver.close();
|
||||
|
||||
Reference in new issue
Block a user