create-mercato-app 0.4.6-develop-7722ab3d39 → 0.4.6-develop-e321a4e2a1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { test, expect } from '@playwright/test'
|
|
2
|
+
|
|
3
|
+
test.describe('TC-UMES-006: transformFormData applyToForm opt-in', () => {
|
|
4
|
+
test('TC-UMES-E20: default path — transformed payload does not update visible form fields', async ({
|
|
5
|
+
page,
|
|
6
|
+
}) => {
|
|
7
|
+
const { login } = await import(
|
|
8
|
+
'@open-mercato/core/modules/core/__integration__/helpers/auth'
|
|
9
|
+
)
|
|
10
|
+
await login(page, 'admin')
|
|
11
|
+
await page.goto('/backend/umes-handlers')
|
|
12
|
+
await page.waitForLoadState('domcontentloaded')
|
|
13
|
+
await expect(page.getByTestId('widget-transform-form-data')).toBeVisible()
|
|
14
|
+
|
|
15
|
+
const titleInput = page.locator('[data-crud-field-id="title"] input').first()
|
|
16
|
+
await titleInput.fill(' spaces around ')
|
|
17
|
+
await page.keyboard.press('Tab')
|
|
18
|
+
|
|
19
|
+
await page.locator('form button[type="submit"]').first().click()
|
|
20
|
+
|
|
21
|
+
// Payload should contain trimmed value
|
|
22
|
+
await expect
|
|
23
|
+
.poll(async () => page.getByTestId('phase-c-submit-result').textContent(), { timeout: 8_000 })
|
|
24
|
+
.toContain('"title":"spaces around"')
|
|
25
|
+
|
|
26
|
+
// Visible form field must NOT be updated — still shows the user-typed value
|
|
27
|
+
await expect(titleInput).toHaveValue(' spaces around ')
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
test('TC-UMES-E21: opt-in path — applyToForm: true reflects transformed values back into visible form fields', async ({
|
|
31
|
+
page,
|
|
32
|
+
}) => {
|
|
33
|
+
const { login } = await import(
|
|
34
|
+
'@open-mercato/core/modules/core/__integration__/helpers/auth'
|
|
35
|
+
)
|
|
36
|
+
await login(page, 'admin')
|
|
37
|
+
await page.goto('/backend/umes-handlers')
|
|
38
|
+
await page.waitForLoadState('domcontentloaded')
|
|
39
|
+
await expect(page.getByTestId('widget-transform-form-data')).toBeVisible()
|
|
40
|
+
|
|
41
|
+
const noteInput = page.locator('[data-crud-field-id="note"] input').first()
|
|
42
|
+
await noteInput.fill('transform: make me uppercase')
|
|
43
|
+
await page.keyboard.press('Tab')
|
|
44
|
+
|
|
45
|
+
await page.locator('form button[type="submit"]').first().click()
|
|
46
|
+
|
|
47
|
+
// Payload should contain transformed value
|
|
48
|
+
await expect
|
|
49
|
+
.poll(async () => page.getByTestId('phase-c-submit-result').textContent(), { timeout: 8_000 })
|
|
50
|
+
.toContain('"note":"MAKE ME UPPERCASE"')
|
|
51
|
+
|
|
52
|
+
// Visible form field MUST be updated because applyToForm: true was returned
|
|
53
|
+
await expect(noteInput).toHaveValue('MAKE ME UPPERCASE')
|
|
54
|
+
})
|
|
55
|
+
})
|
|
@@ -128,6 +128,9 @@ const widget: InjectionWidgetModule<any, any> = {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
sharedState?.set('lastTransformFormData', trimmed)
|
|
131
|
+
if (shouldTransform) {
|
|
132
|
+
return { data: trimmed as typeof data, applyToForm: true }
|
|
133
|
+
}
|
|
131
134
|
return trimmed as typeof data
|
|
132
135
|
}
|
|
133
136
|
return data
|