diff --git a/package.json b/package.json index 3a73d4dee4..bb67e57baf 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "ejs": "4.0.1", "eslint": "9.39.2", "franc-min": "^6.2.0", - "glob": "13.0.0", "happy-dom": "20.5.0", "license-checker-rseidelsohn": "4.4.2", "node-fetch": "3.3.2", diff --git a/packages/design-system/package.json b/packages/design-system/package.json index a23d57611a..8ef19b7941 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -125,7 +125,6 @@ "@tailwindcss/vite": "^4.1.11", "@vitejs/plugin-vue": "6.0.4", "clean-publish": "^6.0.0", - "glob": "^13.0.0", "markdown-it-container": "^4.0.0", "postcss": "^8.5.2", "process": "^0.11.10", diff --git a/packages/design-system/src/components/OcIcon/OcIcon.spec.ts b/packages/design-system/src/components/OcIcon/OcIcon.spec.ts index 8befda6646..0764d1db45 100644 --- a/packages/design-system/src/components/OcIcon/OcIcon.spec.ts +++ b/packages/design-system/src/components/OcIcon/OcIcon.spec.ts @@ -1,24 +1,49 @@ -import { mount } from '@opencloud-eu/web-test-helpers' +import { mount, PartialComponentProps } from '@opencloud-eu/web-test-helpers' import OcIcon from './OcIcon.vue' -import { glob } from 'glob' -import path from 'path' describe('OcIcon', () => { - test('render and update', async () => { - const icons = glob.sync(path.resolve(__dirname, '..', 'assets', 'icons', '*.svg')).map((p) => ({ - name: path.basename(p, '.svg'), - path: path.relative(__dirname, p) - })) - - const wrapper = mount(OcIcon) - await wrapper.vm.$nextTick() + describe('type', () => { + it.each(['span', 'div'])('renders the icon based in its type', (type) => { + const { wrapper } = getWrapper({ type }) + expect(wrapper.find(type).exists()).toBe(true) + }) + it('should apply bg-transparent and min-h-0 class when type is button', () => { + const { wrapper } = getWrapper({ type: 'button' }) + expect(wrapper.find('button').classes()).toContain('bg-transparent') + expect(wrapper.find('button').classes()).toContain('min-h-0') + }) + }) + describe('src', () => { + it('should use the provided name to render the correct fill svg icon', () => { + const { wrapper } = getWrapper({ name: 'settings' }) + const inlineSvg = wrapper.findComponent({ name: 'inline-svg' }) + expect(inlineSvg.exists()).toBe(true) + expect(inlineSvg.attributes('src')).toEqual('icons/settings-fill.svg') + }) + it('should use the provided name to render the correct line svg icon', () => { + const { wrapper } = getWrapper({ name: 'settings', fillType: 'line' }) + const inlineSvg = wrapper.findComponent({ name: 'inline-svg' }) + expect(inlineSvg.exists()).toBe(true) + expect(inlineSvg.attributes('src')).toEqual('icons/settings-line.svg') + }) + }) + it('should emit the loaded event when the svg is being loaded', async () => { + const { wrapper } = getWrapper() const inlineSvg = wrapper.findComponent({ name: 'inline-svg' }) - for (const icon of icons) { - await wrapper.setProps({ name: icon.name }) - await inlineSvg.emitted('unloaded') - await inlineSvg.emitted('loaded') - expect(wrapper.find('text').text()).toBe(icon.name) - } + await inlineSvg.vm.$emit('loaded') + + expect(wrapper.emitted('loaded')).toBeTruthy() + expect(wrapper.emitted('loaded')).toHaveLength(1) }) }) + +const getWrapper = (props: PartialComponentProps = {}) => { + return { + wrapper: mount(OcIcon, { + props: { + ...props + } + }) + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4df13bfc99..74560db221 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -24,7 +24,7 @@ importers: devDependencies: '@axe-core/playwright': specifier: ^4.10.2 - version: 4.11.0(playwright-core@1.58.1) + version: 4.11.1(playwright-core@1.58.1) '@babel/core': specifier: 7.29.0 version: 7.29.0 @@ -112,9 +112,6 @@ importers: franc-min: specifier: ^6.2.0 version: 6.2.0 - glob: - specifier: 13.0.0 - version: 13.0.0 happy-dom: specifier: 20.5.0 version: 20.5.0 @@ -263,9 +260,6 @@ importers: clean-publish: specifier: ^6.0.0 version: 6.0.1 - glob: - specifier: ^13.0.0 - version: 13.0.0 markdown-it-container: specifier: ^4.0.0 version: 4.0.0 @@ -1282,8 +1276,8 @@ packages: resolution: {integrity: sha512-z1oyLq5/UVkohVXNDEY70mJbT/sv/t6HYtCvCwNrOri6pxBJDomP9R83KOlwcat+xqBQEdJHjbrPh36f1avmZA==} engines: {node: '>= 14.0.0'} - '@axe-core/playwright@4.11.0': - resolution: {integrity: sha512-70vBT/Ylqpm65RQz2iCG2o0JJCEG/WCNyefTr2xcOcr1CoSee60gNQYUMZZ7YukoKkFLv26I/jjlsvwwp532oQ==} + '@axe-core/playwright@4.11.1': + resolution: {integrity: sha512-mKEfoUIB1MkVTht0BGZFXtSAEKXMJoDkyV5YZ9jbBmZCcWDz71tegNsdTkIN8zc/yMi5Gm2kx7Z5YQ9PfWNAWw==} peerDependencies: playwright-core: '>= 1.0.0' @@ -2382,8 +2376,8 @@ packages: resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==} engines: {node: 20 || >=22} - '@isaacs/brace-expansion@5.0.0': - resolution: {integrity: sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==} + '@isaacs/brace-expansion@5.0.1': + resolution: {integrity: sha512-WMz71T1JS624nWj2n2fnYAuPovhv7EUhk69R6i9dsVyzxt5eM3bjwvgk9L+APE1TRscGysAVMANkB0jh0LQZrQ==} engines: {node: 20 || >=22} '@isaacs/cliui@8.0.2': @@ -4599,15 +4593,16 @@ packages: glob@10.5.0: resolution: {integrity: sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==} + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me hasBin: true - glob@13.0.0: - resolution: {integrity: sha512-tvZgpqk6fz4BaNZ66ZsRaZnbHvP/jG3uKJvAZOwEVUL4RTA5nJeeLYfyN9/VA8NX/V3IBG+hkeuGpKjvELkVhA==} + glob@13.0.1: + resolution: {integrity: sha512-B7U/vJpE3DkJ5WXTgTpTRN63uV42DseiXXKMwG14LQBXmsdeIoHAPbU/MEo6II0k5ED74uc2ZGTC6MwHFQhF6w==} engines: {node: 20 || >=22} glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} - deprecated: Glob versions prior to v9 are no longer supported + deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me global-dirs@3.0.1: resolution: {integrity: sha512-NBcGGFbBA9s1VzD41QXDG+3++t9Mn5t1FpLdhESY6oKY4gYTFpX4wO3sqGUa0Srjtbfj3szX0RnemmrVRUdULA==} @@ -5291,8 +5286,8 @@ packages: resolution: {integrity: sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==} engines: {node: 20 || >=22} - minimatch@10.1.1: - resolution: {integrity: sha512-enIvLvRAFZYXJzkCYG5RKmPfrFArdLv+R+lbQ53BmIMLIry74bjKzX6iHAm8WYamJkhSSEabrWN5D97XnKObjQ==} + minimatch@10.1.2: + resolution: {integrity: sha512-fu656aJ0n2kcXwsnwnv9g24tkU5uSmOlTjd6WyyaKm2Z+h1qmY6bAjrcaIxF/BslFqbZ8UBtbJi7KgQOZD2PTw==} engines: {node: 20 || >=22} minimatch@3.1.2: @@ -7022,7 +7017,7 @@ snapshots: dependencies: '@algolia/client-common': 5.47.0 - '@axe-core/playwright@4.11.0(playwright-core@1.58.1)': + '@axe-core/playwright@4.11.1(playwright-core@1.58.1)': dependencies: axe-core: 4.11.1 playwright-core: 1.58.1 @@ -7998,7 +7993,7 @@ snapshots: debug: 4.4.3(supports-color@8.1.1) error-stack-parser: 2.1.4 figures: 3.2.0 - glob: 13.0.0 + glob: 13.0.1 has-ansi: 4.0.1 indent-string: 4.0.0 is-installed-globally: 0.4.0 @@ -8360,7 +8355,7 @@ snapshots: '@isaacs/balanced-match@4.0.1': {} - '@isaacs/brace-expansion@5.0.0': + '@isaacs/brace-expansion@5.0.1': dependencies: '@isaacs/balanced-match': 4.0.1 @@ -9160,7 +9155,7 @@ snapshots: '@types/minimatch@6.0.0': dependencies: - minimatch: 10.1.1 + minimatch: 10.1.2 '@types/node@25.2.0': dependencies: @@ -10832,9 +10827,9 @@ snapshots: package-json-from-dist: 1.0.1 path-scurry: 1.11.1 - glob@13.0.0: + glob@13.0.1: dependencies: - minimatch: 10.1.1 + minimatch: 10.1.2 minipass: 7.1.2 path-scurry: 2.0.1 @@ -11500,11 +11495,11 @@ snapshots: minimatch@10.0.3: dependencies: - '@isaacs/brace-expansion': 5.0.0 + '@isaacs/brace-expansion': 5.0.1 - minimatch@10.1.1: + minimatch@10.1.2: dependencies: - '@isaacs/brace-expansion': 5.0.0 + '@isaacs/brace-expansion': 5.0.1 minimatch@3.1.2: dependencies: