@forsakringskassan/vue-lib-template 1.2.10 → 1.3.0
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/cypress/support/component.ts +1 -19
- package/files/cypress/tsconfig.json +1 -0
- package/files/docs/build.mts +19 -6
- package/files/docs/package.json +2 -2
- package/files/docs/src/bundle-mocks.mjs +1 -1
- package/files/package.json +33 -26
- package/files/src/selectors/guide/FcCatInfoComponent.selectors.spec.ts +111 -0
- package/files/tsconfig.cypress.json +2 -0
- package/files/tsconfig.lib.json +2 -0
- package/hooks/install.mjs +1 -9
- package/index.js +1 -1
- package/package.json +2 -1
|
@@ -6,25 +6,7 @@ import "@fkui/theme-default";
|
|
|
6
6
|
import "./main.scss";
|
|
7
7
|
import "./common";
|
|
8
8
|
|
|
9
|
-
Cypress.Commands.add("mount",
|
|
10
|
-
options.global ??= {};
|
|
11
|
-
options.global.plugins ??= [];
|
|
12
|
-
|
|
13
|
-
/* handle warnings as errors */
|
|
14
|
-
options.global.plugins.push({
|
|
15
|
-
install(app) {
|
|
16
|
-
app.config.warnHandler = (msg) => {
|
|
17
|
-
const mochaRunner = Cypress.mocha.getRunner();
|
|
18
|
-
const body = mochaRunner.test?.body ?? "";
|
|
19
|
-
if (!body.includes("<expectedException")) {
|
|
20
|
-
cy.wrap(`Vue warning: ${msg}`).should("be.empty");
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
return mount(component, options);
|
|
27
|
-
});
|
|
9
|
+
Cypress.Commands.add("mount", mount);
|
|
28
10
|
|
|
29
11
|
const uncaughtErrors: string[] = [];
|
|
30
12
|
|
package/files/docs/build.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
|
|
2
2
|
|
|
3
|
-
import { copyFileSync } from "node:fs";
|
|
4
3
|
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
5
|
import {
|
|
6
6
|
Generator,
|
|
7
|
+
extractMarkdownProcessor,
|
|
7
8
|
frontMatterFileReader,
|
|
9
|
+
manifestProcessor,
|
|
8
10
|
vueFileReader,
|
|
9
11
|
} from "@forsakringskassan/docs-generator";
|
|
10
12
|
import pkg from "../package.json" with { type: "json" };
|
|
@@ -24,6 +26,12 @@ const docs = new Generator(import.meta.url, {
|
|
|
24
26
|
"@fkui/logic",
|
|
25
27
|
"@fkui/vue",
|
|
26
28
|
],
|
|
29
|
+
processors: [
|
|
30
|
+
extractMarkdownProcessor({
|
|
31
|
+
outputFolder: path.join(import.meta.dirname, "../dist/docs"),
|
|
32
|
+
}),
|
|
33
|
+
manifestProcessor(),
|
|
34
|
+
],
|
|
27
35
|
});
|
|
28
36
|
|
|
29
37
|
docs.compileScript("main", "./src/main.js", {
|
|
@@ -34,10 +42,20 @@ docs.compileStyle("main", "./src/main.scss", {
|
|
|
34
42
|
appendTo: "head",
|
|
35
43
|
});
|
|
36
44
|
|
|
45
|
+
const styleUrl = import.meta.resolve(`../dist/esm/style.css`);
|
|
46
|
+
const stylePath = fileURLToPath(styleUrl); // workaround for https://github.com/Forsakringskassan/docs-generator/issues/499
|
|
47
|
+
docs.compileStyle("lib", stylePath, {
|
|
48
|
+
appendTo: "head",
|
|
49
|
+
});
|
|
50
|
+
|
|
37
51
|
docs.compileScript("mocks", "./src/bundle-mocks.mjs", {
|
|
38
52
|
appendTo: "head",
|
|
39
53
|
});
|
|
40
54
|
|
|
55
|
+
const mswUrl = import.meta.resolve("msw/mockServiceWorker.js");
|
|
56
|
+
const mswPath = fileURLToPath(mswUrl); // workaround for https://github.com/Forsakringskassan/docs-generator/issues/499
|
|
57
|
+
docs.compileWorker("msw", mswPath);
|
|
58
|
+
|
|
41
59
|
await docs.build([
|
|
42
60
|
{
|
|
43
61
|
include: ["**/*.md"],
|
|
@@ -49,8 +67,3 @@ await docs.build([
|
|
|
49
67
|
fileReader: vueFileReader,
|
|
50
68
|
},
|
|
51
69
|
]);
|
|
52
|
-
|
|
53
|
-
copyFileSync(
|
|
54
|
-
"../node_modules/msw/lib/mockServiceWorker.js",
|
|
55
|
-
"./public/mock-service-worker.js",
|
|
56
|
-
);
|
package/files/docs/package.json
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"@fkui/icon-lib-default": "6.58.0",
|
|
11
11
|
"@fkui/vue": "6.58.0",
|
|
12
12
|
"@forsakringskassan/apimock-express": "4.1.0",
|
|
13
|
-
"@forsakringskassan/docs-generator": "3.
|
|
13
|
+
"@forsakringskassan/docs-generator": "3.11.1",
|
|
14
14
|
"@tsconfig/node24": "24.0.5",
|
|
15
15
|
"@tsconfig/recommended": "1.0.13",
|
|
16
16
|
"http-server": "14.1.1",
|
|
17
17
|
"msw": "2.15.0",
|
|
18
|
-
"vue": "3.5.
|
|
18
|
+
"vue": "3.5.43"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -11,7 +11,7 @@ const handlers = [
|
|
|
11
11
|
const worker = setupWorker(...handlers);
|
|
12
12
|
// eslint-disable-next-line no-undef -- technical debt
|
|
13
13
|
const rootUrl = document.documentElement.dataset["rootUrl"];
|
|
14
|
-
const url = `${rootUrl}/
|
|
14
|
+
const url = `${rootUrl}/msw.js`;
|
|
15
15
|
|
|
16
16
|
// Used in setup.ts
|
|
17
17
|
// eslint-disable-next-line unicorn/no-global-object-property-assignment, no-undef -- technical debt
|
package/files/package.json
CHANGED
|
@@ -20,11 +20,18 @@
|
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"import": "./dist/esm/index.esm.js"
|
|
22
22
|
},
|
|
23
|
+
"./docs": {
|
|
24
|
+
"types": "./dist/docs/index.d.mts",
|
|
25
|
+
"import": "./dist/docs/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./docs/links.json": {
|
|
28
|
+
"default": "./dist/docs/links.json"
|
|
29
|
+
},
|
|
23
30
|
"./selectors": {
|
|
24
31
|
"types": "./dist/types/selectors.d.ts",
|
|
25
32
|
"import": "./dist/esm/selectors.esm.js"
|
|
26
33
|
},
|
|
27
|
-
"./style.css": "./dist/esm/
|
|
34
|
+
"./style.css": "./dist/esm/style.css",
|
|
28
35
|
"./package.json": "./package.json"
|
|
29
36
|
},
|
|
30
37
|
"main": "dist/esm/index.esm.js",
|
|
@@ -57,7 +64,7 @@
|
|
|
57
64
|
"postpublish": "release-postpublish",
|
|
58
65
|
"start": "vite --",
|
|
59
66
|
"start:docs": "npm start -w docs",
|
|
60
|
-
"stylelint": "stylelint \"src/**/*.{css,scss}\"",
|
|
67
|
+
"stylelint": "stylelint \"src/**/*.{css,scss,vue}\"",
|
|
61
68
|
"stylelint:fix": "npm run stylelint -- --fix",
|
|
62
69
|
"pretest": "npm run lint",
|
|
63
70
|
"test": "vitest run",
|
|
@@ -89,42 +96,42 @@
|
|
|
89
96
|
"@fkui/vue": "6.58.0",
|
|
90
97
|
"@forsakringskassan/apimock-express": "4.1.0",
|
|
91
98
|
"@forsakringskassan/commitlint-config": "4.2.8",
|
|
92
|
-
"@forsakringskassan/cypress-config": "1.
|
|
99
|
+
"@forsakringskassan/cypress-config": "1.10.0",
|
|
93
100
|
"@forsakringskassan/cypress-visual-regression": "5.2.0",
|
|
94
|
-
"@forsakringskassan/docs-generator": "3.
|
|
101
|
+
"@forsakringskassan/docs-generator": "3.11.1",
|
|
95
102
|
"@forsakringskassan/docs-live-example": "3.0.2",
|
|
96
|
-
"@forsakringskassan/eslint-config": "15.
|
|
97
|
-
"@forsakringskassan/eslint-config-cli": "15.
|
|
98
|
-
"@forsakringskassan/eslint-config-cypress": "15.
|
|
99
|
-
"@forsakringskassan/eslint-config-jest": "15.
|
|
100
|
-
"@forsakringskassan/eslint-config-typescript": "15.
|
|
101
|
-
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.
|
|
102
|
-
"@forsakringskassan/eslint-config-vitest": "15.
|
|
103
|
-
"@forsakringskassan/eslint-config-vue": "15.
|
|
104
|
-
"@forsakringskassan/prettier-config": "3.7.
|
|
105
|
-
"@forsakringskassan/stylelint-config": "3.
|
|
106
|
-
"@forsakringskassan/vite-lib-config": "5.12.
|
|
103
|
+
"@forsakringskassan/eslint-config": "15.10.0",
|
|
104
|
+
"@forsakringskassan/eslint-config-cli": "15.10.0",
|
|
105
|
+
"@forsakringskassan/eslint-config-cypress": "15.10.0",
|
|
106
|
+
"@forsakringskassan/eslint-config-jest": "15.10.0",
|
|
107
|
+
"@forsakringskassan/eslint-config-typescript": "15.10.0",
|
|
108
|
+
"@forsakringskassan/eslint-config-typescript-typeinfo": "15.10.0",
|
|
109
|
+
"@forsakringskassan/eslint-config-vitest": "15.10.0",
|
|
110
|
+
"@forsakringskassan/eslint-config-vue": "15.10.0",
|
|
111
|
+
"@forsakringskassan/prettier-config": "3.7.10",
|
|
112
|
+
"@forsakringskassan/stylelint-config": "3.5.0",
|
|
113
|
+
"@forsakringskassan/vite-lib-config": "5.12.4",
|
|
107
114
|
"@forsakringskassan/vitest-config-jsdom": "5.0.0",
|
|
108
|
-
"@forsakringskassan/vue-lib-template": "1.
|
|
109
|
-
"@html-validate/release-scripts": "7.6.
|
|
110
|
-
"@types/node": "24.13.
|
|
115
|
+
"@forsakringskassan/vue-lib-template": "1.3.0",
|
|
116
|
+
"@html-validate/release-scripts": "7.6.12",
|
|
117
|
+
"@types/node": "24.13.5",
|
|
111
118
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
112
|
-
"@vue/server-renderer": "3.5.
|
|
113
|
-
"@vue/test-utils": "2.5.
|
|
114
|
-
"cloneman": "1.24.
|
|
119
|
+
"@vue/server-renderer": "3.5.43",
|
|
120
|
+
"@vue/test-utils": "2.5.1",
|
|
121
|
+
"cloneman": "1.24.1",
|
|
115
122
|
"core-js": "3.50.0",
|
|
116
|
-
"cypress": "16.
|
|
117
|
-
"html-validate": "11.
|
|
123
|
+
"cypress": "16.1.0",
|
|
124
|
+
"html-validate": "11.16.0",
|
|
118
125
|
"html-validate-markdown": "6.0.0",
|
|
119
126
|
"html-validate-vue": "9.3.1",
|
|
120
127
|
"mocha-junit-reporter": "2.2.1",
|
|
121
|
-
"npm-pkg-lint": "5.
|
|
128
|
+
"npm-pkg-lint": "5.3.1",
|
|
122
129
|
"npm-run-all2": "9.0.3",
|
|
123
130
|
"rimraf": "6.1.3",
|
|
124
131
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
125
132
|
"vite": "8.3.0",
|
|
126
|
-
"vitest": "5.0.
|
|
127
|
-
"vue": "3.5.
|
|
133
|
+
"vitest": "5.0.1",
|
|
134
|
+
"vue": "3.5.43",
|
|
128
135
|
"vue-tsc": "3.3.11"
|
|
129
136
|
},
|
|
130
137
|
"peerDependencies": {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { TestPlugin, ValidationPlugin } from "@fkui/vue";
|
|
2
|
+
import { mount } from "@vue/test-utils";
|
|
3
|
+
import { beforeEach, expect, it, vi } from "vitest";
|
|
4
|
+
import FcCatInfoComponent from "../../components/guide/FcCatInfo/FcCatInfoComponent.vue";
|
|
5
|
+
import { catGetById } from "../../components/guide/FcCatInfo/cat-api";
|
|
6
|
+
import { cats } from "../../components/guide/FcCatInfo/cat-data";
|
|
7
|
+
import { FcCatInfoComponentSelectors } from "./FcCatInfoComponent.selectors";
|
|
8
|
+
|
|
9
|
+
vi.mock(import("../../components/guide/FcCatInfo/cat-api"));
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
vi.mocked(catGetById).mockResolvedValue(cats[0]);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should use the default selector", () => {
|
|
16
|
+
expect.assertions(2);
|
|
17
|
+
const wrapper = mount(FcCatInfoComponent, {
|
|
18
|
+
props: { catId: cats[0].id },
|
|
19
|
+
});
|
|
20
|
+
const { selector } = FcCatInfoComponentSelectors();
|
|
21
|
+
|
|
22
|
+
expect(selector).toBe(":scope");
|
|
23
|
+
expect(wrapper.find(selector).exists()).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should find the component with an explicit selector", () => {
|
|
27
|
+
expect.assertions(2);
|
|
28
|
+
const wrapper = mount(FcCatInfoComponent, {
|
|
29
|
+
attrs: { "data-test": "my-cat-info" },
|
|
30
|
+
props: { catId: cats[0].id },
|
|
31
|
+
});
|
|
32
|
+
const { selector } = FcCatInfoComponentSelectors(
|
|
33
|
+
'[data-test="my-cat-info"]',
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(selector).toBe('[data-test="my-cat-info"]');
|
|
37
|
+
expect(wrapper.find(selector).exists()).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should find the loading container", () => {
|
|
41
|
+
expect.assertions(1);
|
|
42
|
+
const wrapper = mount(FcCatInfoComponent, {
|
|
43
|
+
props: { catId: cats[0].id },
|
|
44
|
+
});
|
|
45
|
+
const { loadingContainer } = FcCatInfoComponentSelectors();
|
|
46
|
+
|
|
47
|
+
expect(wrapper.get(loadingContainer()).text()).toContain(
|
|
48
|
+
"Hämtar kattinformation...",
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("should find all view mode elements", async () => {
|
|
53
|
+
expect.assertions(5);
|
|
54
|
+
const wrapper = mount(FcCatInfoComponent, {
|
|
55
|
+
props: { catId: cats[0].id, isEditable: false },
|
|
56
|
+
});
|
|
57
|
+
const selectors = FcCatInfoComponentSelectors();
|
|
58
|
+
|
|
59
|
+
await vi.waitFor(() => {
|
|
60
|
+
if (!wrapper.find(selectors.viewContainer()).exists()) {
|
|
61
|
+
throw new Error("View container has not been rendered yet");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const view = wrapper.get(selectors.viewContainer());
|
|
66
|
+
expect(view.text()).toContain(cats[0].name);
|
|
67
|
+
expect(view.text()).toContain(`${cats[0].age} år`);
|
|
68
|
+
expect(view.text()).toContain(cats[0].breed);
|
|
69
|
+
expect(view.text()).toContain(cats[0].color);
|
|
70
|
+
expect(view.text()).toContain(cats[0].favoriteFood);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("should find all edit mode inputs", async () => {
|
|
74
|
+
expect.assertions(6);
|
|
75
|
+
const wrapper = mount(FcCatInfoComponent, {
|
|
76
|
+
props: { catId: cats[0].id, isEditable: true },
|
|
77
|
+
global: {
|
|
78
|
+
plugins: [TestPlugin, ValidationPlugin],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
const selectors = FcCatInfoComponentSelectors();
|
|
82
|
+
|
|
83
|
+
await vi.waitFor(() => {
|
|
84
|
+
if (!wrapper.find(selectors.editContainer()).exists()) {
|
|
85
|
+
throw new Error("Edit container has not been rendered yet");
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
expect(wrapper.find(selectors.editContainer()).exists()).toBe(true);
|
|
90
|
+
|
|
91
|
+
expect(
|
|
92
|
+
wrapper.get<HTMLInputElement>(selectors.nameInput()).element.value,
|
|
93
|
+
).toBe(cats[0].name);
|
|
94
|
+
|
|
95
|
+
expect(
|
|
96
|
+
wrapper.get<HTMLInputElement>(selectors.ageInput()).element.value,
|
|
97
|
+
).toBe(cats[0].age.toString());
|
|
98
|
+
|
|
99
|
+
expect(
|
|
100
|
+
wrapper.get<HTMLInputElement>(selectors.breedInput()).element.value,
|
|
101
|
+
).toBe(cats[0].breed);
|
|
102
|
+
|
|
103
|
+
expect(
|
|
104
|
+
wrapper.get<HTMLInputElement>(selectors.colorInput()).element.value,
|
|
105
|
+
).toBe(cats[0].color);
|
|
106
|
+
|
|
107
|
+
expect(
|
|
108
|
+
wrapper.get<HTMLInputElement>(selectors.favoriteFoodInput()).element
|
|
109
|
+
.value,
|
|
110
|
+
).toBe(cats[0].favoriteFood);
|
|
111
|
+
});
|
package/files/tsconfig.lib.json
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
"extends": "@forsakringskassan/vite-lib-config/tsconfig.lib.json",
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
"paths": {
|
|
7
|
+
// prettier-ignore
|
|
7
8
|
"@forsakringskassan/vue-lib-template/selectors": [
|
|
8
9
|
"./src/selectors/index.ts"
|
|
9
10
|
],
|
|
11
|
+
// prettier-ignore
|
|
10
12
|
"@forsakringskassan/vue-lib-template": ["./src/index.ts"]
|
|
11
13
|
}
|
|
12
14
|
}
|
package/hooks/install.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
3
|
export async function install(context ) {
|
|
4
|
-
const {
|
|
4
|
+
const { getApplicationName, replaceInFile } = context;
|
|
5
5
|
const scopedName = getApplicationName();
|
|
6
|
-
const unscopedName = getApplicationName({ unscoped: true });
|
|
7
6
|
|
|
8
7
|
/* update placeholder names with the real application name (from package.json) */
|
|
9
8
|
const placeholder = /"@forsakringskassan\/vue-lib-template(\/[^"]+)?"/g;
|
|
@@ -14,11 +13,4 @@ export async function install(context ) {
|
|
|
14
13
|
await replaceInFile("tsconfig.lib.json", placeholder, quotedName);
|
|
15
14
|
await replaceInFile("tsconfig.cypress.json", placeholder, quotedName);
|
|
16
15
|
await replaceInFile("tsconfig.selectors.json", placeholder, quotedName);
|
|
17
|
-
|
|
18
|
-
/* correct exported subpath "style.css" */
|
|
19
|
-
await updateJsonFile("package.json", {
|
|
20
|
-
exports: {
|
|
21
|
-
"./style.css": `./dist/esm/${unscopedName}.css`,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
16
|
}
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const options = {
|
|
9
9
|
...packageJson.cloneman,
|
|
10
|
-
fileHash: "
|
|
10
|
+
fileHash: "3ed96f7ccd01c366c430cf3081cbf47d160888c6d793dc177709a483b78000f9",
|
|
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.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Vue library template based on Cloneman",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"template",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"src/mocks/guide/cat-api.mock.mts",
|
|
92
92
|
"src/mocks/guide/index.mts",
|
|
93
93
|
"src/mocks/index.mts",
|
|
94
|
+
"src/selectors/guide/FcCatInfoComponent.selectors.spec.ts",
|
|
94
95
|
"src/selectors/guide/FcCatInfoComponent.selectors.ts",
|
|
95
96
|
"src/selectors/guide/index.ts",
|
|
96
97
|
"src/selectors/index.ts",
|