Skip to content

Commit

Permalink
Merge branch 'main' into add-autofixer-for-rem-spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
Haberkamp authored Feb 5, 2025
2 parents b071943 + b61039b commit 797cd13
Show file tree
Hide file tree
Showing 18 changed files with 729 additions and 347 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-toes-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Stop emitting onUpdate:modelValue event when blurring the mt-url-field
5 changes: 5 additions & 0 deletions .changeset/cool-kings-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": minor
---

Add types for event of mt-url-field component
5 changes: 5 additions & 0 deletions .changeset/large-apples-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Add types for slots for mt-url-field
5 changes: 5 additions & 0 deletions .changeset/loud-donkeys-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Announce tooltip content when focusing tooltip trigger
5 changes: 5 additions & 0 deletions .changeset/twelve-bulldogs-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-ag/meteor-component-library": patch
---

Stop announcing tooltip triangle to screen readers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/component-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"@types/node": "^18.18.5",
"@types/punycode": "^2.1.3",
"@vitejs/plugin-vue": "^4.4.0",
"@vitest/ui": "^1.1.3",
"@vitest/ui": "^3.0.5",
"@vue/eslint-config-typescript": "^12.0.0",
"@vue/test-utils": "^2.4.2",
"@vue/tsconfig": "^0.4.0",
Expand Down Expand Up @@ -130,7 +130,7 @@
"vite": "^4.4.11",
"vite-plugin-dts": "^4.5.0",
"vite-plugin-svgstring": "^1.0.0",
"vitest": "^1.1.3",
"vitest": "^3.0.5",
"vue-tsc": "^2.2.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { userEvent, within } from "@storybook/test";
import { fn, userEvent, within, expect } from "@storybook/test";
import meta, { type MtUrlFieldMeta, type MtUrlFieldStory } from "./mt-url-field.stories";

export default {
Expand All @@ -18,6 +18,20 @@ export const VisualTestFocused: MtUrlFieldStory = {
},
};

export const VisualTestPlaceholder: MtUrlFieldStory = {
name: "With placeholder",
args: {
placeholder: "Placeholder",
},
};

export const VisualTestRequired: MtUrlFieldStory = {
name: "Required",
args: {
required: true,
},
};

export const VisualTestHttps: MtUrlFieldStory = {
name: "shows HTTPS mode",
args: {
Expand Down Expand Up @@ -83,3 +97,37 @@ export const VisualTestSmall: MtUrlFieldStory = {
size: "small",
},
};

export const VisualTestHelpText: MtUrlFieldStory = {
name: "Helptext",
args: {
modelValue: "https://example.com",
helpText: "This is help text",
},
};

export const VisualTestHint: MtUrlFieldStory = {
name: "Hint",
args: {
hint: "This is a hint",
},
};

export const VisualTestCopyToClipboard: MtUrlFieldStory = {
name: "Copy to clipboard",
args: {
modelValue: "https://www.example.com",
copyable: true,
},
async play({ canvasElement }) {
const handler = fn();
navigator.clipboard.writeText = handler;

const canvas = within(canvasElement);

await userEvent.click(canvas.getByRole("button", { name: "Copy URL to clipboard" }));

await expect(handler).toHaveBeenCalledOnce();
await expect(handler).toHaveBeenCalledWith("www.example.com");
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -74,7 +73,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "",
// @ts-expect-error -- Event is not typed, yet
onChange: handler,
},
});
Expand Down Expand Up @@ -171,24 +169,39 @@ describe("mt-url-field", async () => {
props: {
modelValue: "www.example.com",
disabled: true,
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});

// ACT
await userEvent.type(screen.getByRole("textbox"), "www.shopware.com");

// Is needed to emit the "onUpdate:modelValue" event
await userEvent.tab();

// ASSERT
expect(screen.getByRole("textbox")).toHaveValue("www.example.com");
expect(screen.getByRole("textbox")).toBeDisabled();

expect(handler).not.toHaveBeenCalled();
});

it("does not emit an onUpdate:modelValue event when removing focus from the input", async () => {
// ARRANGE
const handler = vi.fn();

render(MtUrlField, {
props: {
modelValue: "www.example.com",
"onUpdate:modelValue": handler,
},
});

// ACT
await userEvent.click(screen.getByRole("textbox"));
await userEvent.tab();

// ASSERT
expect(handler).not.toHaveBeenCalled();
});

it("cannot be switched to the http protocol when the field is disabled", async () => {
// ARRANGE
const handler = vi.fn();
Expand All @@ -197,7 +210,6 @@ describe("mt-url-field", async () => {
props: {
modelValue: "https://www.example.com",
disabled: true,
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -218,7 +230,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "https://www.example.com",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -239,7 +250,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "http://www.example.com",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand Down Expand Up @@ -285,7 +295,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "",
// @ts-expect-error -- Event is not typed, yet
onChange: handler,
},
});
Expand All @@ -305,15 +314,15 @@ describe("mt-url-field", async () => {

render(MtUrlField, {
props: {
label: "URL",
isInheritanceField: true,
isInherited: true,
// @ts-expect-error
"onInheritance-remove": handler,
},
});

// ACT
await userEvent.click(screen.getByTestId("mt-inheritance-switch-icon"));
await userEvent.click(screen.getByRole("button", { name: "Unlink inheritance" }));

// ASSERT
expect(handler).toHaveBeenCalledOnce();
Expand All @@ -325,15 +334,15 @@ describe("mt-url-field", async () => {

render(MtUrlField, {
props: {
label: "URL",
isInheritanceField: true,
isInherited: false,
// @ts-expect-error
"onInheritance-restore": handler,
},
});

// ACT
await userEvent.click(screen.getByTestId("mt-icon__regular-link-horizontal-slash"));
await userEvent.click(screen.getByRole("button", { name: "Link inheritance" }));

// ASSERT
expect(handler).toHaveBeenCalledOnce();
Expand All @@ -348,7 +357,6 @@ describe("mt-url-field", async () => {
isInheritanceField: true,
isInherited: true,
modelValue: "www.example.com",
// @ts-expect-error
"onUpdate:modelValue": handler,
},
});
Expand All @@ -373,7 +381,6 @@ describe("mt-url-field", async () => {
isInheritanceField: true,
isInherited: false,
modelValue: "",
// @ts-expect-error
"onUpdate:modelValue": handler,
},
});
Expand All @@ -398,7 +405,6 @@ describe("mt-url-field", async () => {
isInheritanceField: true,
isInherited: true,
modelValue: "http://www.example.com",
// @ts-expect-error
"onUpdate:modelValue": handler,
},
});
Expand All @@ -421,7 +427,6 @@ describe("mt-url-field", async () => {
props: {
modelValue: "https://www.example.com?foo=bar",
omitUrlSearch: true,
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -439,7 +444,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "https://www.example.com?foo=bar",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -458,7 +462,6 @@ describe("mt-url-field", async () => {
props: {
modelValue: "https://www.example.com#foo",
omitUrlHash: true,
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -476,7 +479,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "https://www.example.com#foo",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -494,7 +496,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "www.example.com ",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand All @@ -512,7 +513,6 @@ describe("mt-url-field", async () => {
render(MtUrlField, {
props: {
modelValue: "localhost/h%C3%A4ndler",
// @ts-expect-error -- Event is not typed, yet
"onUpdate:modelValue": handler,
},
});
Expand Down
Loading

0 comments on commit 797cd13

Please sign in to comment.