@forsakringskassan/vue-lib-template 1.6.1 → 1.6.2
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/files/docs/guide/cat-info.md +3 -3
- package/files/docs/package.json +1 -1
- package/files/etc/lib.api.md +1 -1
- package/files/etc/selectors.api.md +1 -1
- package/files/package.json +18 -18
- package/files/project-guide/development.md +8 -8
- package/files/project-guide/documentation.md +8 -8
- package/files/project-guide/index.md +6 -6
- package/files/project-guide/testing.md +4 -4
- package/files/src/components/guide/README.md +1 -1
- package/files/src/components/guide/{FcCatInfo → cat-info}/cat-data.ts +1 -1
- package/files/src/components/guide/{FcCatInfo → cat-info}/cat-info-logic.ts +1 -1
- package/files/src/components/guide/{FcCatInfo/FcCatInfoComponent.cy.ts → cat-info/cat-info.cy.ts} +7 -7
- package/files/src/components/guide/{FcCatInfo/FcCatInfoComponent.vue → cat-info/cat-info.vue} +2 -2
- package/files/src/components/guide/{FcCatInfo/examples/FcCatInfoComponentExample.vue → cat-info/examples/cat-info-example.vue} +2 -2
- package/files/src/components/guide/{FcCatInfo/examples/FcCatInfoComponentLiveExample.vue → cat-info/examples/cat-info-live-example.vue} +4 -4
- package/files/src/components/guide/cat-info/index.ts +1 -0
- package/files/src/components/guide/index.ts +1 -1
- package/files/src/mocks/guide/cat-api.mock.mts +2 -2
- package/files/src/selectors/guide/{FcCatInfoComponent.selectors.spec.ts → cat-info.selectors.spec.ts} +15 -17
- package/files/src/selectors/guide/{FcCatInfoComponent.selectors.ts → cat-info.selectors.ts} +4 -4
- package/files/src/selectors/guide/index.ts +1 -1
- package/index.js +1 -1
- package/package.json +44 -17
- package/files/src/components/guide/FcCatInfo/index.ts +0 -1
- /package/files/src/components/guide/{FcCatInfo → cat-info}/cat-api.spec.ts +0 -0
- /package/files/src/components/guide/{FcCatInfo → cat-info}/cat-api.ts +0 -0
- /package/files/src/components/guide/{FcCatInfo/CatInfoEdit.vue → cat-info/cat-info-edit.vue} +0 -0
- /package/files/src/components/guide/{FcCatInfo → cat-info}/cat-info-logic.spec.ts +0 -0
- /package/files/src/components/guide/{FcCatInfo/CatInfoShow.vue → cat-info/cat-info-show.vue} +0 -0
- /package/files/src/components/guide/{FcCatInfo → cat-info}/cat-types.ts +0 -0
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
title: Kattinformation
|
|
3
3
|
status: Draft
|
|
4
4
|
layout: component
|
|
5
|
-
component:
|
|
5
|
+
component: FcCatInfo
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
Komponenten kan visa kattdata i visningsläge eller i ett redigerbart läge.
|
|
9
9
|
Den hämtar kattdata från ett mockat backend.
|
|
10
10
|
|
|
11
11
|
```import live-example
|
|
12
|
-
|
|
12
|
+
cat-info-live-example.vue
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Tänk på att
|
|
@@ -24,5 +24,5 @@ FcCatInfoComponentLiveExample.vue
|
|
|
24
24
|
## API
|
|
25
25
|
|
|
26
26
|
::: api
|
|
27
|
-
vue:
|
|
27
|
+
vue:cat-info
|
|
28
28
|
:::
|
package/files/docs/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@fkui/icon-lib-default": "6.60.0",
|
|
14
14
|
"@fkui/vue": "6.60.0",
|
|
15
15
|
"@forsakringskassan/apimock-express": "4.2.1",
|
|
16
|
-
"@forsakringskassan/docs-generator": "3.
|
|
16
|
+
"@forsakringskassan/docs-generator": "3.16.0",
|
|
17
17
|
"@tsconfig/node24": "24.0.5",
|
|
18
18
|
"@tsconfig/recommended": "1.0.13",
|
|
19
19
|
"http-server": "14.1.1",
|
package/files/etc/lib.api.md
CHANGED
|
@@ -12,7 +12,7 @@ import { PublicProps } from 'vue';
|
|
|
12
12
|
// Warning: (ae-forgotten-export) The symbol "__VLS_export" needs to be exported by the entry point index.d.ts
|
|
13
13
|
//
|
|
14
14
|
// @public (undocumented)
|
|
15
|
-
export const
|
|
15
|
+
export const FcCatInfo: typeof __VLS_export;
|
|
16
16
|
|
|
17
17
|
// (No @packageDocumentation comment for this package)
|
|
18
18
|
|
package/files/package.json
CHANGED
|
@@ -97,29 +97,29 @@
|
|
|
97
97
|
"@forsakringskassan/commitlint-config": "4.2.8",
|
|
98
98
|
"@forsakringskassan/cypress-config": "1.10.0",
|
|
99
99
|
"@forsakringskassan/cypress-visual-regression": "5.2.0",
|
|
100
|
-
"@forsakringskassan/docs-generator": "3.
|
|
101
|
-
"@forsakringskassan/docs-live-example": "3.0.
|
|
102
|
-
"@forsakringskassan/eslint-config": "15.11.
|
|
103
|
-
"@forsakringskassan/eslint-config-cli": "15.11.
|
|
104
|
-
"@forsakringskassan/eslint-config-cypress": "15.11.
|
|
100
|
+
"@forsakringskassan/docs-generator": "3.16.0",
|
|
101
|
+
"@forsakringskassan/docs-live-example": "3.0.3",
|
|
102
|
+
"@forsakringskassan/eslint-config": "15.11.12",
|
|
103
|
+
"@forsakringskassan/eslint-config-cli": "15.11.11",
|
|
104
|
+
"@forsakringskassan/eslint-config-cypress": "15.11.10",
|
|
105
105
|
"@forsakringskassan/eslint-config-jest": "15.11.1",
|
|
106
|
-
"@forsakringskassan/eslint-config-typescript": "15.11.
|
|
107
|
-
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.11.
|
|
108
|
-
"@forsakringskassan/eslint-config-vitest": "15.11.
|
|
109
|
-
"@forsakringskassan/eslint-config-vue": "15.11.
|
|
106
|
+
"@forsakringskassan/eslint-config-typescript": "15.11.10",
|
|
107
|
+
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.11.7",
|
|
108
|
+
"@forsakringskassan/eslint-config-vitest": "15.11.11",
|
|
109
|
+
"@forsakringskassan/eslint-config-vue": "15.11.11",
|
|
110
110
|
"@forsakringskassan/prettier-config": "3.7.11",
|
|
111
|
-
"@forsakringskassan/stylelint-config": "3.5.
|
|
112
|
-
"@forsakringskassan/vite-lib-config": "5.
|
|
113
|
-
"@forsakringskassan/vitest-config-jsdom": "5.0.
|
|
114
|
-
"@forsakringskassan/vue-lib-template": "1.6.
|
|
111
|
+
"@forsakringskassan/stylelint-config": "3.5.1",
|
|
112
|
+
"@forsakringskassan/vite-lib-config": "5.13.0",
|
|
113
|
+
"@forsakringskassan/vitest-config-jsdom": "5.0.1",
|
|
114
|
+
"@forsakringskassan/vue-lib-template": "1.6.2",
|
|
115
115
|
"@html-validate/release-scripts": "7.6.12",
|
|
116
|
-
"@types/node": "24.19.
|
|
116
|
+
"@types/node": "24.19.1",
|
|
117
117
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
118
118
|
"@vue/server-renderer": "3.5.43",
|
|
119
119
|
"@vue/test-utils": "2.5.1",
|
|
120
120
|
"cloneman": "1.26.0",
|
|
121
121
|
"core-js": "3.50.0",
|
|
122
|
-
"cypress": "16.1.
|
|
122
|
+
"cypress": "16.1.1",
|
|
123
123
|
"html-validate": "11.16.1",
|
|
124
124
|
"html-validate-markdown": "6.0.0",
|
|
125
125
|
"html-validate-vue": "9.3.1",
|
|
@@ -128,10 +128,10 @@
|
|
|
128
128
|
"npm-run-all2": "9.0.3",
|
|
129
129
|
"rimraf": "6.1.3",
|
|
130
130
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
131
|
-
"vite": "8.3.
|
|
132
|
-
"vitest": "5.0.
|
|
131
|
+
"vite": "8.3.2",
|
|
132
|
+
"vitest": "5.0.3",
|
|
133
133
|
"vue": "3.5.43",
|
|
134
|
-
"vue-tsc": "3.3.
|
|
134
|
+
"vue-tsc": "3.3.12"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
137
|
"@fkui/design": "^6.0.0",
|
|
@@ -11,24 +11,24 @@ To get up and running quickly:
|
|
|
11
11
|
|
|
12
12
|
## Architecture: Three Layers
|
|
13
13
|
|
|
14
|
-
We recommend separating Appearance, Logic, and Types into three distinct layers to keep the codebase maintainable. You can find an example component, [`
|
|
14
|
+
We recommend separating Appearance, Logic, and Types into three distinct layers to keep the codebase maintainable. You can find an example component, [`FcCatInfo`](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info.vue), which demonstrates how this structure can be applied in practice:
|
|
15
15
|
|
|
16
16
|
### 1. Type Layer
|
|
17
17
|
|
|
18
|
-
In the example [cat-types.ts](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
18
|
+
In the example [cat-types.ts](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-types.ts), we define _what_ the data is using TypeScript interfaces.
|
|
19
19
|
|
|
20
20
|
- **Why?** It ensures that both the logic and the component know exactly which fields (e.g., `name`, `age`) exist.
|
|
21
21
|
|
|
22
22
|
### 2. Logic Layer
|
|
23
23
|
|
|
24
|
-
In the example [cat-info-logic.ts](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
24
|
+
In the example [cat-info-logic.ts](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info-logic.ts), we create a so-called "composable" (a function that starts with `use...`, e.g., `useCatInfo`).
|
|
25
25
|
|
|
26
26
|
- This is where we handle API calls, state (loading, error), and calculations.
|
|
27
27
|
- **Why?** It makes the logic easy to test with Vitest without needing to start a full browser.
|
|
28
28
|
|
|
29
29
|
### 3. UI Layer
|
|
30
30
|
|
|
31
|
-
Refer to [
|
|
31
|
+
Refer to [cat-info.vue](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info.vue) for the actual Vue component. This should be "thin".
|
|
32
32
|
|
|
33
33
|
- It imports the logic from `useCatInfo`.
|
|
34
34
|
- It uses components from `@fkui/vue` (such as `FCard` or `FLoader`) to follow the design system.
|
|
@@ -36,19 +36,19 @@ Refer to [FcCatInfoComponent.vue](https://github.com/Forsakringskassan/vue-lib-t
|
|
|
36
36
|
|
|
37
37
|
## Implementation Flow
|
|
38
38
|
|
|
39
|
-
1. **Create the files**: Create `
|
|
39
|
+
1. **Create the files**: Create `my-component.vue`, `my-component-logic.ts`, and `my-component-types.ts`.
|
|
40
40
|
2. **Implement logic**: Create your `useMyComponent` function and export it.
|
|
41
41
|
3. **Build UI**: Import the logic into the `.vue` file and connect variables to the template.
|
|
42
42
|
4. **Export**: Open `src/components/index.ts` and add:
|
|
43
43
|
|
|
44
44
|
```typescript
|
|
45
|
-
export { default as
|
|
45
|
+
export { default as FcMyComponent } from "./my-component.vue";
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## Styling
|
|
49
49
|
|
|
50
50
|
- For small amounts of styling, it is perfectly fine to use `<style lang="scss"></style>` directly within the `.vue` file.
|
|
51
|
-
- For more extensive styles, create a dedicated SCSS file for the component (e.g., `
|
|
51
|
+
- For more extensive styles, create a dedicated SCSS file for the component (e.g., `my-component.scss`) and import it in the `.vue` file.
|
|
52
52
|
- Use `style.scss` for styles that should apply to the entire library.
|
|
53
53
|
|
|
54
54
|
## Common commands
|
|
@@ -82,7 +82,7 @@ You can run a specific example file directly by passing a name to the start comm
|
|
|
82
82
|
npm start catinfo
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
This uses fuzzy search to find and start the best matching file in `src/examples/` (e.g., `
|
|
85
|
+
This uses fuzzy search to find and start the best matching file in `src/examples/` (e.g., `cat-info-example.vue`).
|
|
86
86
|
|
|
87
87
|
## API URL configuration
|
|
88
88
|
|
|
@@ -15,7 +15,7 @@ Put the component page in `docs/components/` and give it the same base name as t
|
|
|
15
15
|
title: Cat information
|
|
16
16
|
status: Draft
|
|
17
17
|
layout: component
|
|
18
|
-
component:
|
|
18
|
+
component: FcCatInfo
|
|
19
19
|
---
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -29,21 +29,21 @@ A standard runnable example is included with an `import` fence:
|
|
|
29
29
|
|
|
30
30
|
````md
|
|
31
31
|
```import
|
|
32
|
-
|
|
32
|
+
my-component-example.vue
|
|
33
33
|
```
|
|
34
34
|
````
|
|
35
35
|
|
|
36
|
-
The corresponding example is [`
|
|
36
|
+
The corresponding example is [`cat-info-example.vue`](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/examples/cat-info-example.vue). Keep the example focused on a realistic use case and make its initial state useful without extra setup.
|
|
37
37
|
|
|
38
|
-
Prefer a live example when the documentation needs interactive controls or a richer demonstration. Include a file ending in
|
|
38
|
+
Prefer a live example when the documentation needs interactive controls or a richer demonstration. Include a kebab-case file ending in `-live-example.vue` with the `live-example` variant:
|
|
39
39
|
|
|
40
40
|
````md
|
|
41
41
|
```import live-example
|
|
42
|
-
|
|
42
|
+
cat-info-live-example.vue
|
|
43
43
|
```
|
|
44
44
|
````
|
|
45
45
|
|
|
46
|
-
The reference implementation shows this pattern in [
|
|
46
|
+
The reference implementation shows this pattern in [cat-info-live-example.vue](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/examples/cat-info-live-example.vue) and its [documentation page](https://github.com/Forsakringskassan/vue-lib-template/blob/main/docs/guide/cat-info.md).
|
|
47
47
|
|
|
48
48
|
See the [docs-live-example README](https://github.com/Forsakringskassan/docs-live-example/blob/main/README.md) for the implementation details behind interactive examples.
|
|
49
49
|
|
|
@@ -70,10 +70,10 @@ Add the Vue API block for every component page:
|
|
|
70
70
|
## API
|
|
71
71
|
|
|
72
72
|
::: api
|
|
73
|
-
vue:
|
|
73
|
+
vue:cat-info
|
|
74
74
|
:::
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
The component name must match the Vue
|
|
77
|
+
The component name must match the Vue SFC's base filename. Public props, events, slots, and documented types are extracted from the component source and its declarations. Keep public API comments accurate because they are part of the generated documentation.
|
|
78
78
|
|
|
79
79
|
If the component has translation keys, add the corresponding translation API block. Do not add empty sections for features the component does not use.
|
|
@@ -31,12 +31,12 @@ Here are the most important locations you need to know:
|
|
|
31
31
|
|
|
32
32
|
The `vue-lib-template` template repository, which this component library is based on, contains a small cat information component that demonstrates the recommended structure. It is useful as a starting point when creating a new component:
|
|
33
33
|
|
|
34
|
-
- [Component](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
35
|
-
- [Runnable example](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
36
|
-
- [Live
|
|
37
|
-
- [Unit tests](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
38
|
-
- [Cypress component tests](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
39
|
-
- [Cypress selectors](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/selectors/guide/
|
|
34
|
+
- [Component](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info.vue)
|
|
35
|
+
- [Runnable example](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/examples/cat-info-example.vue)
|
|
36
|
+
- [Live example](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/examples/cat-info-live-example.vue)
|
|
37
|
+
- [Unit tests](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info-logic.spec.ts)
|
|
38
|
+
- [Cypress component tests](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info.cy.ts)
|
|
39
|
+
- [Cypress selectors](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/selectors/guide/cat-info.selectors.ts)
|
|
40
40
|
- [API mock](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/mocks/guide/cat-api.mock.mts)
|
|
41
41
|
- [Mock registration](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/mocks/index.mts)
|
|
42
42
|
|
|
@@ -10,7 +10,7 @@ Use Vitest for composables, business rules, data transformations. Keep these tes
|
|
|
10
10
|
|
|
11
11
|
Run tests with `npm run unit`.
|
|
12
12
|
|
|
13
|
-
The cat information logic is tested in [`cat-info-logic.spec.ts`](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/
|
|
13
|
+
The cat information logic is tested in [`cat-info-logic.spec.ts`](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info-logic.spec.ts). It mocks the API module and verifies loading, successful data, errors, and updates:
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
16
|
import { expect, it, vi } from "vitest";
|
|
@@ -71,7 +71,7 @@ See the [apimock-express README](https://github.com/Forsakringskassan/apimock-ex
|
|
|
71
71
|
|
|
72
72
|
## Cypress component tests
|
|
73
73
|
|
|
74
|
-
Use Cypress for user-visible component behavior: rendering, loading states, form interaction, emitted actions, error states, and accessibility-related behavior. The current example is [`
|
|
74
|
+
Use Cypress for user-visible component behavior: rendering, loading states, form interaction, emitted actions, error states, and accessibility-related behavior. The current example is [`cat-info.cy.ts`](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/components/guide/cat-info/cat-info.cy.ts).
|
|
75
75
|
|
|
76
76
|
The current package does not define a dedicated Cypress npm script, so run Cypress through `npx`:
|
|
77
77
|
|
|
@@ -81,7 +81,7 @@ The current package does not define a dedicated Cypress npm script, so run Cypre
|
|
|
81
81
|
Mount the component with realistic props and wait for state changes through visible behavior:
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
|
-
cy.mount(
|
|
84
|
+
cy.mount(FcCatInfo, {
|
|
85
85
|
props: {
|
|
86
86
|
catId: testCat.id,
|
|
87
87
|
isEditable: false,
|
|
@@ -96,7 +96,7 @@ Do not use arbitrary timeouts to wait for the API. Assert on a loading element,
|
|
|
96
96
|
|
|
97
97
|
### Selectors
|
|
98
98
|
|
|
99
|
-
Keep reusable selectors in a `selectors/` file instead of scattering CSS selectors through specs. The [`
|
|
99
|
+
Keep reusable selectors in a `selectors/` file instead of scattering CSS selectors through specs. The [`FcCatInfoSelectors` helper](https://github.com/Forsakringskassan/vue-lib-template/blob/main/src/selectors/guide/cat-info.selectors.ts) uses [`data-test`](https://designsystem.forsakringskassan.se/latest/functions/plugins/testplugin.html) attributes and supports scoping a component instance.
|
|
100
100
|
|
|
101
101
|
Selectors should describe stable test targets.
|
|
102
102
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Component guide
|
|
2
2
|
|
|
3
|
-
This directory contains an example component, `
|
|
3
|
+
This directory contains an example component, `FcCatInfo`, that demonstrates the setup and conventions used by this template.
|
|
4
4
|
It includes the component, selectors, tests, mock data, related support files, and belonging documentation in `docs/guide`.
|
|
5
5
|
|
|
6
6
|
This guide will stay in sync when you update to later versions of your template,
|
|
@@ -4,7 +4,7 @@ import { catGetById } from "./cat-api";
|
|
|
4
4
|
import type { Cat } from "./cat-types";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Business logic for the
|
|
7
|
+
* Business logic for the FcCatInfo.
|
|
8
8
|
* Manages fetching and updating cat information from mock backend.
|
|
9
9
|
*/
|
|
10
10
|
export function useCatInfo(): {
|
package/files/src/components/guide/{FcCatInfo/FcCatInfoComponent.cy.ts → cat-info/cat-info.cy.ts}
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FLoaderSelectors } from "@fkui/vue/selectors";
|
|
2
|
-
import {
|
|
3
|
-
import FcCatInfoComponent from "./FcCatInfoComponent.vue";
|
|
2
|
+
import { FcCatInfoSelectors } from "../../../selectors/guide/cat-info.selectors";
|
|
4
3
|
import { cats } from "./cat-data";
|
|
4
|
+
import FcCatInfo from "./cat-info.vue";
|
|
5
5
|
|
|
6
|
-
describe("
|
|
6
|
+
describe("FcCatInfo", () => {
|
|
7
7
|
const testCat = cats[0];
|
|
8
|
-
const catInfoSelectors =
|
|
8
|
+
const catInfoSelectors = FcCatInfoSelectors();
|
|
9
9
|
const loaderSelectors = FLoaderSelectors();
|
|
10
10
|
|
|
11
11
|
it("verifies loading text", () => {
|
|
12
|
-
cy.mount(
|
|
12
|
+
cy.mount(FcCatInfo, {
|
|
13
13
|
props: {
|
|
14
14
|
catId: testCat.id,
|
|
15
15
|
},
|
|
@@ -23,7 +23,7 @@ describe("FcCatInfoComponent", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it("verifies all fields in view mode have correct data", () => {
|
|
26
|
-
cy.mount(
|
|
26
|
+
cy.mount(FcCatInfo, {
|
|
27
27
|
props: {
|
|
28
28
|
catId: testCat.id,
|
|
29
29
|
isEditable: false,
|
|
@@ -44,7 +44,7 @@ describe("FcCatInfoComponent", () => {
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
it("verifies all fields in edit mode have correct data", () => {
|
|
47
|
-
cy.mount(
|
|
47
|
+
cy.mount(FcCatInfo, {
|
|
48
48
|
props: {
|
|
49
49
|
catId: testCat.id,
|
|
50
50
|
isEditable: true,
|
package/files/src/components/guide/{FcCatInfo/FcCatInfoComponent.vue → cat-info/cat-info.vue}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, watch } from "vue";
|
|
3
3
|
import { FCard, FLoader } from "@fkui/vue";
|
|
4
|
-
import CatInfoEdit from "./
|
|
5
|
-
import CatInfoShow from "./CatInfoShow.vue";
|
|
4
|
+
import CatInfoEdit from "./cat-info-edit.vue";
|
|
6
5
|
import { useCatInfo } from "./cat-info-logic.js";
|
|
6
|
+
import CatInfoShow from "./cat-info-show.vue";
|
|
7
7
|
import { type Cat } from "./cat-types.js";
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
-
import
|
|
3
|
+
import FcCatInfo from "../cat-info.vue";
|
|
4
4
|
|
|
5
5
|
const selectedCatId = ref("whiskers-001");
|
|
6
6
|
const isEditable = ref(false);
|
|
@@ -8,7 +8,7 @@ const isEditable = ref(false);
|
|
|
8
8
|
|
|
9
9
|
<template>
|
|
10
10
|
<div class="cat-example__component">
|
|
11
|
-
<fc-cat-info
|
|
11
|
+
<fc-cat-info :cat-id="selectedCatId" :is-editable />
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { defineComponent } from "vue";
|
|
3
3
|
import { FCheckboxField, FSelectField } from "@fkui/vue";
|
|
4
4
|
import { LiveExample } from "@forsakringskassan/docs-live-example";
|
|
5
|
-
import FcCatInfoComponent from "../FcCatInfoComponent.vue";
|
|
6
5
|
import { getCatIds } from "../cat-data.js";
|
|
6
|
+
import FcCatInfo from "../cat-info.vue";
|
|
7
7
|
|
|
8
8
|
export default defineComponent({
|
|
9
|
-
name: "
|
|
9
|
+
name: "FcCatInfoLiveExample",
|
|
10
10
|
components: { LiveExample, FSelectField, FCheckboxField },
|
|
11
11
|
data() {
|
|
12
12
|
return {
|
|
@@ -17,14 +17,14 @@ export default defineComponent({
|
|
|
17
17
|
},
|
|
18
18
|
computed: {
|
|
19
19
|
components(): object {
|
|
20
|
-
return {
|
|
20
|
+
return { FcCatInfo };
|
|
21
21
|
},
|
|
22
22
|
editableAttr(): string {
|
|
23
23
|
return this.isEditable ? " is-editable" : "";
|
|
24
24
|
},
|
|
25
25
|
template(): string {
|
|
26
26
|
return /* HTML */ `
|
|
27
|
-
<fc-cat-info
|
|
27
|
+
<fc-cat-info cat-id="${this.selectedCatId}" ${this.editableAttr} />
|
|
28
28
|
`;
|
|
29
29
|
},
|
|
30
30
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FcCatInfo } from "./cat-info.vue";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { FcCatInfo } from "./cat-info";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineMock } from "@forsakringskassan/apimock-express/helpers";
|
|
2
|
-
import { cats } from "../../components/guide/
|
|
3
|
-
import type { Cat } from "../../components/guide/
|
|
2
|
+
import { cats } from "../../components/guide/cat-info/cat-data.ts";
|
|
3
|
+
import type { Cat } from "../../components/guide/cat-info/cat-types.ts";
|
|
4
4
|
|
|
5
5
|
export default defineMock<Cat | { error: string }>({
|
|
6
6
|
meta: {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TestPlugin, ValidationPlugin } from "@fkui/vue";
|
|
2
2
|
import { mount } from "@vue/test-utils";
|
|
3
3
|
import { beforeEach, expect, it, vi } from "vitest";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import { catGetById } from "../../components/guide/cat-info/cat-api";
|
|
5
|
+
import { cats } from "../../components/guide/cat-info/cat-data";
|
|
6
|
+
import FcCatInfo from "../../components/guide/cat-info/cat-info.vue";
|
|
7
|
+
import { FcCatInfoSelectors } from "./cat-info.selectors";
|
|
8
8
|
|
|
9
|
-
vi.mock(import("../../components/guide/
|
|
9
|
+
vi.mock(import("../../components/guide/cat-info/cat-api"));
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
vi.mocked(catGetById).mockResolvedValue(cats[0]);
|
|
@@ -14,10 +14,10 @@ beforeEach(() => {
|
|
|
14
14
|
|
|
15
15
|
it("should use the default selector", () => {
|
|
16
16
|
expect.assertions(2);
|
|
17
|
-
const wrapper = mount(
|
|
17
|
+
const wrapper = mount(FcCatInfo, {
|
|
18
18
|
props: { catId: cats[0].id },
|
|
19
19
|
});
|
|
20
|
-
const { selector } =
|
|
20
|
+
const { selector } = FcCatInfoSelectors();
|
|
21
21
|
|
|
22
22
|
expect(selector).toBe(":scope");
|
|
23
23
|
expect(wrapper.find(selector).exists()).toBe(true);
|
|
@@ -25,13 +25,11 @@ it("should use the default selector", () => {
|
|
|
25
25
|
|
|
26
26
|
it("should find the component with an explicit selector", () => {
|
|
27
27
|
expect.assertions(2);
|
|
28
|
-
const wrapper = mount(
|
|
28
|
+
const wrapper = mount(FcCatInfo, {
|
|
29
29
|
attrs: { "data-test": "my-cat-info" },
|
|
30
30
|
props: { catId: cats[0].id },
|
|
31
31
|
});
|
|
32
|
-
const { selector } =
|
|
33
|
-
'[data-test="my-cat-info"]',
|
|
34
|
-
);
|
|
32
|
+
const { selector } = FcCatInfoSelectors('[data-test="my-cat-info"]');
|
|
35
33
|
|
|
36
34
|
expect(selector).toBe('[data-test="my-cat-info"]');
|
|
37
35
|
expect(wrapper.find(selector).exists()).toBe(true);
|
|
@@ -39,10 +37,10 @@ it("should find the component with an explicit selector", () => {
|
|
|
39
37
|
|
|
40
38
|
it("should find the loading container", () => {
|
|
41
39
|
expect.assertions(1);
|
|
42
|
-
const wrapper = mount(
|
|
40
|
+
const wrapper = mount(FcCatInfo, {
|
|
43
41
|
props: { catId: cats[0].id },
|
|
44
42
|
});
|
|
45
|
-
const { loadingContainer } =
|
|
43
|
+
const { loadingContainer } = FcCatInfoSelectors();
|
|
46
44
|
|
|
47
45
|
expect(wrapper.get(loadingContainer()).text()).toContain(
|
|
48
46
|
"Hämtar kattinformation...",
|
|
@@ -51,10 +49,10 @@ it("should find the loading container", () => {
|
|
|
51
49
|
|
|
52
50
|
it("should find all view mode elements", async () => {
|
|
53
51
|
expect.assertions(5);
|
|
54
|
-
const wrapper = mount(
|
|
52
|
+
const wrapper = mount(FcCatInfo, {
|
|
55
53
|
props: { catId: cats[0].id, isEditable: false },
|
|
56
54
|
});
|
|
57
|
-
const selectors =
|
|
55
|
+
const selectors = FcCatInfoSelectors();
|
|
58
56
|
|
|
59
57
|
await vi.waitFor(() => {
|
|
60
58
|
if (!wrapper.find(selectors.viewContainer()).exists()) {
|
|
@@ -72,13 +70,13 @@ it("should find all view mode elements", async () => {
|
|
|
72
70
|
|
|
73
71
|
it("should find all edit mode inputs", async () => {
|
|
74
72
|
expect.assertions(6);
|
|
75
|
-
const wrapper = mount(
|
|
73
|
+
const wrapper = mount(FcCatInfo, {
|
|
76
74
|
props: { catId: cats[0].id, isEditable: true },
|
|
77
75
|
global: {
|
|
78
76
|
plugins: [TestPlugin, ValidationPlugin],
|
|
79
77
|
},
|
|
80
78
|
});
|
|
81
|
-
const selectors =
|
|
79
|
+
const selectors = FcCatInfoSelectors();
|
|
82
80
|
|
|
83
81
|
await vi.waitFor(() => {
|
|
84
82
|
if (!wrapper.find(selectors.editContainer()).exists()) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Selectors for `
|
|
2
|
+
* Selectors for `FcCatInfo`.
|
|
3
3
|
*
|
|
4
4
|
* @public
|
|
5
|
-
* @param selector - The selector for the
|
|
6
|
-
* @returns An object with selector methods for the
|
|
5
|
+
* @param selector - The selector for the FcCatInfo.
|
|
6
|
+
* @returns An object with selector methods for the FcCatInfo.
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
8
|
+
export function FcCatInfoSelectors(selector: string = ":scope") {
|
|
9
9
|
return Object.freeze({
|
|
10
10
|
/**
|
|
11
11
|
* The base selector for the component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { FcCatInfoSelectors } from "./cat-info.selectors";
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const options = {
|
|
9
9
|
...packageJson.cloneman,
|
|
10
|
-
fileHash: "
|
|
10
|
+
fileHash: "bc371200203939f7aac70cb6735d6cefd6aeaf428f0e4ff6916992a8e4919ae3",
|
|
11
11
|
filesDir: path.join(import.meta.dirname, "files"),
|
|
12
12
|
hooksDir: path.join(import.meta.dirname, "hooks"),
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/vue-lib-template",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Vue library template based on Cloneman",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"template",
|
|
@@ -72,19 +72,19 @@
|
|
|
72
72
|
"project-guide/testing.md",
|
|
73
73
|
"README.md",
|
|
74
74
|
"renovate.json",
|
|
75
|
-
"src/components/guide/
|
|
76
|
-
"src/components/guide/
|
|
77
|
-
"src/components/guide/
|
|
78
|
-
"src/components/guide/
|
|
79
|
-
"src/components/guide/
|
|
80
|
-
"src/components/guide/
|
|
81
|
-
"src/components/guide/
|
|
82
|
-
"src/components/guide/
|
|
83
|
-
"src/components/guide/
|
|
84
|
-
"src/components/guide/
|
|
85
|
-
"src/components/guide/
|
|
86
|
-
"src/components/guide/
|
|
87
|
-
"src/components/guide/
|
|
75
|
+
"src/components/guide/cat-info/cat-api.spec.ts",
|
|
76
|
+
"src/components/guide/cat-info/cat-api.ts",
|
|
77
|
+
"src/components/guide/cat-info/cat-data.ts",
|
|
78
|
+
"src/components/guide/cat-info/cat-info-edit.vue",
|
|
79
|
+
"src/components/guide/cat-info/cat-info-logic.spec.ts",
|
|
80
|
+
"src/components/guide/cat-info/cat-info-logic.ts",
|
|
81
|
+
"src/components/guide/cat-info/cat-info-show.vue",
|
|
82
|
+
"src/components/guide/cat-info/cat-info.cy.ts",
|
|
83
|
+
"src/components/guide/cat-info/cat-info.vue",
|
|
84
|
+
"src/components/guide/cat-info/cat-types.ts",
|
|
85
|
+
"src/components/guide/cat-info/examples/cat-info-example.vue",
|
|
86
|
+
"src/components/guide/cat-info/examples/cat-info-live-example.vue",
|
|
87
|
+
"src/components/guide/cat-info/index.ts",
|
|
88
88
|
"src/components/guide/index.ts",
|
|
89
89
|
"src/components/guide/README.md",
|
|
90
90
|
"src/components/index.ts",
|
|
@@ -95,8 +95,8 @@
|
|
|
95
95
|
"src/mocks/guide/cat-api.mock.mts",
|
|
96
96
|
"src/mocks/guide/index.mts",
|
|
97
97
|
"src/mocks/index.mts",
|
|
98
|
-
"src/selectors/guide/
|
|
99
|
-
"src/selectors/guide/
|
|
98
|
+
"src/selectors/guide/cat-info.selectors.spec.ts",
|
|
99
|
+
"src/selectors/guide/cat-info.selectors.ts",
|
|
100
100
|
"src/selectors/guide/index.ts",
|
|
101
101
|
"src/selectors/index.ts",
|
|
102
102
|
"src/style.scss",
|
|
@@ -127,6 +127,8 @@
|
|
|
127
127
|
"cypress/tsconfig.json",
|
|
128
128
|
"cypress/types/mocha.d.ts",
|
|
129
129
|
"docs/build.mts",
|
|
130
|
+
"docs/guide/cat-info.md",
|
|
131
|
+
"docs/guide/index.md",
|
|
130
132
|
"docs/package.json",
|
|
131
133
|
"docs/src/bundle-mocks.ts",
|
|
132
134
|
"docs/src/global.d.ts",
|
|
@@ -140,6 +142,27 @@
|
|
|
140
142
|
"LICENSE.md",
|
|
141
143
|
"README.md",
|
|
142
144
|
"renovate.json",
|
|
145
|
+
"src/components/guide/cat-info/cat-api.spec.ts",
|
|
146
|
+
"src/components/guide/cat-info/cat-api.ts",
|
|
147
|
+
"src/components/guide/cat-info/cat-data.ts",
|
|
148
|
+
"src/components/guide/cat-info/cat-info-edit.vue",
|
|
149
|
+
"src/components/guide/cat-info/cat-info-logic.spec.ts",
|
|
150
|
+
"src/components/guide/cat-info/cat-info-logic.ts",
|
|
151
|
+
"src/components/guide/cat-info/cat-info-show.vue",
|
|
152
|
+
"src/components/guide/cat-info/cat-info.cy.ts",
|
|
153
|
+
"src/components/guide/cat-info/cat-info.vue",
|
|
154
|
+
"src/components/guide/cat-info/cat-types.ts",
|
|
155
|
+
"src/components/guide/cat-info/examples/cat-info-example.vue",
|
|
156
|
+
"src/components/guide/cat-info/examples/cat-info-live-example.vue",
|
|
157
|
+
"src/components/guide/cat-info/index.ts",
|
|
158
|
+
"src/components/guide/index.ts",
|
|
159
|
+
"src/components/guide/README.md",
|
|
160
|
+
"src/mocks/guide/cat-api-mock.spec.ts",
|
|
161
|
+
"src/mocks/guide/cat-api.mock.mts",
|
|
162
|
+
"src/mocks/guide/index.mts",
|
|
163
|
+
"src/selectors/guide/cat-info.selectors.spec.ts",
|
|
164
|
+
"src/selectors/guide/cat-info.selectors.ts",
|
|
165
|
+
"src/selectors/guide/index.ts",
|
|
143
166
|
"tsconfig.cypress.json",
|
|
144
167
|
"tsconfig.json",
|
|
145
168
|
"tsconfig.lib.json",
|
|
@@ -191,7 +214,11 @@
|
|
|
191
214
|
"src/AwesomeComponent.cy.ts",
|
|
192
215
|
"src/AwesomeComponent.vue",
|
|
193
216
|
"src/AwesomeComponentLogic.spec.ts",
|
|
194
|
-
"src/awesome-component-logic.ts"
|
|
217
|
+
"src/awesome-component-logic.ts",
|
|
218
|
+
"docs/guide/**",
|
|
219
|
+
"src/components/guide/**",
|
|
220
|
+
"src/mocks/guide/**",
|
|
221
|
+
"src/selectors/guide/**"
|
|
195
222
|
],
|
|
196
223
|
"uninstallDependencies": [
|
|
197
224
|
"@forsakringskassan/cypress-axe",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as FcCatInfoComponent } from "./FcCatInfoComponent.vue";
|
|
File without changes
|
|
File without changes
|
/package/files/src/components/guide/{FcCatInfo/CatInfoEdit.vue → cat-info/cat-info-edit.vue}
RENAMED
|
File without changes
|
|
File without changes
|
/package/files/src/components/guide/{FcCatInfo/CatInfoShow.vue → cat-info/cat-info-show.vue}
RENAMED
|
File without changes
|
|
File without changes
|