diff --git a/code/addons/interactions/package.json b/code/addons/interactions/package.json
index 2ba5ed1f7826..b7e7ad90da52 100644
--- a/code/addons/interactions/package.json
+++ b/code/addons/interactions/package.json
@@ -88,8 +88,8 @@
},
"devDependencies": {
"@devtools-ds/object-inspector": "^1.1.2",
- "@storybook/jest": "future",
- "@storybook/testing-library": "future",
+ "@storybook/jest": "next",
+ "@storybook/testing-library": "next",
"@types/node": "^16.0.0",
"formik": "^2.2.9",
"typescript": "~4.9.3"
diff --git a/code/addons/interactions/src/components/MethodCall.tsx b/code/addons/interactions/src/components/MethodCall.tsx
index 7bb2f6503916..bbf2d6e3018b 100644
--- a/code/addons/interactions/src/components/MethodCall.tsx
+++ b/code/addons/interactions/src/components/MethodCall.tsx
@@ -141,7 +141,14 @@ export const Node = ({
/* eslint-enable no-underscore-dangle */
case Object.prototype.toString.call(value) === '[object Object]':
- return ;
+ return (
+
+ );
default:
return ;
}
@@ -222,11 +229,13 @@ export const ArrayNode = ({
export const ObjectNode = ({
showInspector,
value,
+ callsById,
nested = false,
}: {
showInspector?: boolean;
value: object;
nested?: boolean;
+ callsById?: Map;
}) => {
const isDarkMode = useTheme().base === 'dark';
const colors = useThemeColors();
@@ -253,7 +262,7 @@ export const ObjectNode = ({
.map(([k, v]) => (
{k}:
-
+
)),
,
diff --git a/code/addons/interactions/template/stories/basics.stories.ts b/code/addons/interactions/template/stories/basics.stories.ts
index c8ddea0b6ea3..0bf84ad495a8 100644
--- a/code/addons/interactions/template/stories/basics.stories.ts
+++ b/code/addons/interactions/template/stories/basics.stories.ts
@@ -31,10 +31,9 @@ export const Step = {
export const TypeAndClear = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- // TODO: seems like userEvent.type + userEvent.clear + userEvent.type is not working for Svelte and Vue2/3. We should probably investigate, might be a bug in userEvent or in our implementation.
- await fireEvent.input(canvas.getByTestId('value'), { target: { value: 'initial value' } });
- await fireEvent.input(canvas.getByTestId('value'), { target: { value: '' } });
- await fireEvent.input(canvas.getByTestId('value'), { target: { value: 'final value' } });
+ await userEvent.type(canvas.getByTestId('value'), 'initial value');
+ await userEvent.clear(canvas.getByTestId('value'));
+ await userEvent.type(canvas.getByTestId('value'), 'final value');
},
};
@@ -96,3 +95,28 @@ export const Validation = {
await expect(args.onSuccess).not.toHaveBeenCalled();
},
};
+
+export const UserEventSetup = {
+ play: async (context) => {
+ const { args, canvasElement, step } = context;
+ const user = userEvent.setup();
+ const canvas = within(canvasElement);
+ await step('Select, type and paste on input using user-event v14 setup', async () => {
+ const input = await canvas.getByRole('textbox');
+ await user.click(input);
+ await user.type(input, 'Pasting: ');
+ await user.paste('foobar');
+ });
+ await step('Tab and press enter on submit button', async () => {
+ await user.pointer([
+ { keys: '[TouchA>]', target: await canvas.getByRole('textbox') },
+ { keys: '[/TouchA]' },
+ ]);
+ await user.tab();
+ await user.keyboard('{enter}');
+ const submitButton = await canvas.findByRole('button');
+ await expect(submitButton).toHaveFocus();
+ await expect(args.onSuccess).toHaveBeenCalled();
+ });
+ },
+};
diff --git a/code/e2e-tests/addon-interactions.spec.ts b/code/e2e-tests/addon-interactions.spec.ts
index 8e2c24b74484..063cfd14cefd 100644
--- a/code/e2e-tests/addon-interactions.spec.ts
+++ b/code/e2e-tests/addon-interactions.spec.ts
@@ -66,9 +66,9 @@ test.describe('addon-interactions', () => {
const panel = sbPage.panelContent();
const runStatusBadge = await panel.locator('[aria-label="Status of the test run"]');
await expect(runStatusBadge).toContainText(/Pass/);
- await expect(panel).toContainText(/value: "initial value"/);
- await expect(panel).toContainText(/value: ""/);
- await expect(panel).toContainText(/value: "final value"/);
+ await expect(panel).toContainText(/"initial value"/);
+ await expect(panel).toContainText(/clear/);
+ await expect(panel).toContainText(/"final value"/);
await expect(panel).toBeVisible();
// Test interactions debugger - Stepping through works, count is correct and values are as expected
@@ -94,6 +94,9 @@ test.describe('addon-interactions', () => {
// Test rerun state (from addon panel) - Interactions have rerun, count is correct and values are as expected
const rerunInteractionButton = await panel.locator('[aria-label="Rerun"]');
await rerunInteractionButton.click();
+
+ await expect(formInput).toHaveValue('final value');
+
await interactionsRow.first().isVisible();
await interactionsRow.nth(1).isVisible();
await interactionsRow.nth(2).isVisible();
@@ -108,5 +111,6 @@ test.describe('addon-interactions', () => {
await interactionsRow.nth(2).isVisible();
await expect(interactionsTab).toContainText(/(3)/);
await expect(interactionsTab).toBeVisible();
+ await expect(formInput).toHaveValue('final value');
});
});
diff --git a/code/frameworks/angular/template/components/form.component.ts b/code/frameworks/angular/template/components/form.component.ts
index 2bc4c00298e8..b3415c745430 100644
--- a/code/frameworks/angular/template/components/form.component.ts
+++ b/code/frameworks/angular/template/components/form.component.ts
@@ -6,7 +6,7 @@ import { Component, Output, EventEmitter } from '@angular/core';
`;
- container.innerHTML = getInnerHTML({ complete: false });
+ container.innerHTML = getInnerHTML({ complete: false, value: '' });
const form = container.querySelector('form');
form.addEventListener('submit', (e) => {
e.preventDefault();
+ const { value } = form.querySelector('input'); // Store the current value
+
setTimeout(() => {
- container.innerHTML = getInnerHTML({ complete: true });
+ container.innerHTML = getInnerHTML({ complete: true, value });
}, 500);
setTimeout(() => {
- container.innerHTML = getInnerHTML({ complete: false });
+ container.innerHTML = getInnerHTML({ complete: false, value });
}, 1500);
- onSuccess(e);
+ onSuccess(value);
});
return container;
diff --git a/code/renderers/preact/template/components/Form.jsx b/code/renderers/preact/template/components/Form.jsx
index f12e905f0dba..fb58cbb10508 100644
--- a/code/renderers/preact/template/components/Form.jsx
+++ b/code/renderers/preact/template/components/Form.jsx
@@ -24,7 +24,7 @@ export const Form = ({ onSuccess }) => {
data-testid="value"
value={value}
required
- onChange={(event) => setValue(event.target.value)}
+ onInput={(event) => setValue(event.target.value)}
/>
diff --git a/code/renderers/svelte/template/components/Form.svelte b/code/renderers/svelte/template/components/Form.svelte
index 467c31d4974b..3b2f7a5b9d97 100644
--- a/code/renderers/svelte/template/components/Form.svelte
+++ b/code/renderers/svelte/template/components/Form.svelte
@@ -26,8 +26,8 @@
+
\ No newline at end of file
diff --git a/code/renderers/vue/template/components/Form.vue b/code/renderers/vue/template/components/Form.vue
index fc46f159e337..2375a381eb7a 100644
--- a/code/renderers/vue/template/components/Form.vue
+++ b/code/renderers/vue/template/components/Form.vue
@@ -2,7 +2,13 @@