@scm-manager/ui-components 4.0.0-REACT19-20250917-125211 → 4.0.0-REACT19-20250920-130317

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-manager/ui-components",
3
- "version": "4.0.0-REACT19-20250917-125211",
3
+ "version": "4.0.0-REACT19-20250920-130317",
4
4
  "description": "UI Components for SCM-Manager and its plugins",
5
5
  "main": "src/index.ts",
6
6
  "files": [
@@ -11,7 +11,7 @@
11
11
  "author": "Sebastian Sdorra <sebastian.sdorra@cloudogu.com>",
12
12
  "license": "AGPL-3.0-only",
13
13
  "scripts": {
14
- "test": "jest",
14
+ "test": "vitest",
15
15
  "typecheck": "tsc",
16
16
  "storybook": "storybook dev -p 6006",
17
17
  "build-storybook": "storybook build",
@@ -34,13 +34,12 @@
34
34
  "devDependencies": {
35
35
  "@scm-manager/babel-preset": "^2.13.1",
36
36
  "@scm-manager/eslint-config": "^2.18.2",
37
- "@scm-manager/jest-preset": "^2.15.0-alpha1",
38
37
  "@scm-manager/prettier-config": "^2.12.0",
39
38
  "@scm-manager/tsconfig": "^2.13.0",
40
- "@scm-manager/ui-shortcuts": "4.0.0-REACT19-20250917-125211",
41
- "@scm-manager/ui-syntaxhighlighting": "4.0.0-REACT19-20250917-125211",
42
- "@scm-manager/ui-text": "4.0.0-REACT19-20250917-125211",
43
- "@scm-manager/ui-types": "4.0.0-REACT19-20250917-125211",
39
+ "@scm-manager/ui-shortcuts": "4.0.0-REACT19-20250920-130317",
40
+ "@scm-manager/ui-syntaxhighlighting": "4.0.0-REACT19-20250920-130317",
41
+ "@scm-manager/ui-text": "4.0.0-REACT19-20250920-130317",
42
+ "@scm-manager/ui-types": "4.0.0-REACT19-20250920-130317",
44
43
  "@storybook/addon-actions": "^9.0.8",
45
44
  "@storybook/addon-docs": "^9.1.5",
46
45
  "@storybook/addon-essentials": "^9.0.0-alpha.12",
@@ -56,23 +55,27 @@
56
55
  "@types/react": "^19.1.1",
57
56
  "@types/react-select": "^2.0.19",
58
57
  "@types/unist": "^2.0.3",
58
+ "@vitest/coverage-v8": "^3.2.4",
59
+ "@vitest/web-worker": "^3.2.4",
60
+ "ci-info": "^4.3.1",
59
61
  "decode-named-character-reference": "^1.0.1",
60
62
  "fetch-mock": "^7.5.1",
61
63
  "gitdiff-parser": "^0.2.2",
62
64
  "minimatch": "^10.0.3",
63
- "react-test-renderer": "^19.1.1",
64
65
  "react-router-dom": "^7.9.1",
66
+ "react-test-renderer": "^19.1.1",
65
67
  "sass-loader": "^12.3.0",
66
68
  "storybook-addon-i18next": "^1.3.0",
67
- "storybook-addon-themes": "^6.1.0"
69
+ "storybook-addon-themes": "^6.1.0",
70
+ "vitest": "^3.2.4"
68
71
  },
69
72
  "dependencies": {
70
- "@scm-manager/ui-api": "4.0.0-REACT19-20250917-125211",
71
- "@scm-manager/ui-buttons": "4.0.0-REACT19-20250917-125211",
72
- "@scm-manager/ui-core": "4.0.0-REACT19-20250917-125211",
73
- "@scm-manager/ui-extensions": "4.0.0-REACT19-20250917-125211",
74
- "@scm-manager/ui-layout": "4.0.0-REACT19-20250917-125211",
75
- "@scm-manager/ui-overlays": "4.0.0-REACT19-20250917-125211",
73
+ "@scm-manager/ui-api": "4.0.0-REACT19-20250920-130317",
74
+ "@scm-manager/ui-buttons": "4.0.0-REACT19-20250920-130317",
75
+ "@scm-manager/ui-core": "4.0.0-REACT19-20250920-130317",
76
+ "@scm-manager/ui-extensions": "4.0.0-REACT19-20250920-130317",
77
+ "@scm-manager/ui-layout": "4.0.0-REACT19-20250920-130317",
78
+ "@scm-manager/ui-overlays": "4.0.0-REACT19-20250920-130317",
76
79
  "deepmerge": "^4.2.2",
77
80
  "hast-util-sanitize": "^3.0.2",
78
81
  "react-diff-view": "2.6.0",
@@ -94,9 +97,6 @@
94
97
  "@scm-manager/babel-preset"
95
98
  ]
96
99
  },
97
- "jest": {
98
- "preset": "@scm-manager/jest-preset"
99
- },
100
100
  "prettier": "@scm-manager/prettier-config",
101
101
  "eslintConfig": {
102
102
  "extends": "@scm-manager/eslint-config"
@@ -18,14 +18,6 @@ import React from "react";
18
18
  import { render, screen } from "@testing-library/react";
19
19
  import Paginator from "./Paginator";
20
20
 
21
- describe("Temporary test to be removed", () => {
22
- it("true", () => {
23
- expect(true).toBe(true);
24
- });
25
- });
26
-
27
- //TODO Fix jest preset to include TextEncoder in its environment
28
- /*
29
21
  describe("paginator rendering tests", () => {
30
22
  const dummyLink = {
31
23
  href: "https://dummy",
@@ -41,12 +33,11 @@ describe("paginator rendering tests", () => {
41
33
 
42
34
  render(<Paginator collection={collection} />);
43
35
 
44
- const buttons = await screen.findAllByRole("button");
36
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
45
37
 
46
- expect(buttons.length).toBe(7);
38
+ assert.lengthOf(buttons, 7);
47
39
  buttons.forEach((button) => {
48
- // @ts-ignore
49
- expect(button).toBeDisabled();
40
+ assert.strictEqual(button.disabled, true, "all buttons should be disabled");
50
41
  });
51
42
  });
52
43
 
@@ -64,28 +55,24 @@ describe("paginator rendering tests", () => {
64
55
 
65
56
  render(<Paginator collection={collection} />);
66
57
 
67
- const buttons = await screen.findAllByRole("button");
58
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
68
59
 
69
- expect(buttons.length).toBe(5);
60
+ assert.lengthOf(buttons, 5);
61
+
62
+ assert.strictEqual(buttons[0].disabled, true, "previous button should be disabled");
63
+ assert.strictEqual(buttons[1].disabled, false, "next button should be enabled");
70
64
 
71
- // previous button
72
- expect(buttons[0]).toBeDisabled();
73
- // last button
74
- expect(buttons[1]).toBeEnabled();
75
- // first button
76
65
  const firstButton = buttons[2];
77
- expect(firstButton).toBeDisabled();
78
- expect(firstButton).toHaveTextContent("1");
66
+ assert.strictEqual(firstButton.disabled, true, "first button should be disabled");
67
+ assert.strictEqual(firstButton.textContent?.trim(), "1", "first button be 1");
79
68
 
80
- // next button
81
69
  const nextButton = buttons[3];
82
- expect(nextButton).toBeEnabled();
83
- expect(nextButton).toHaveTextContent("2");
70
+ assert.strictEqual(nextButton.disabled, false, "next button should be enabled");
71
+ assert.strictEqual(nextButton.textContent?.trim(), "2", "next button be 2");
84
72
 
85
- // last button
86
73
  const lastButton = buttons[4];
87
- expect(lastButton).toBeEnabled();
88
- expect(lastButton).toHaveTextContent("148");
74
+ assert.strictEqual(lastButton.disabled, false, "last button should be enabled");
75
+ assert.strictEqual(lastButton.textContent?.trim(), "148", "last button be 148");
89
76
  });
90
77
 
91
78
  it("should render buttons for second page", async () => {
@@ -103,33 +90,28 @@ describe("paginator rendering tests", () => {
103
90
 
104
91
  render(<Paginator collection={collection} />);
105
92
 
106
- const buttons = await screen.findAllByRole("button");
93
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
94
+
95
+ assert.lengthOf(buttons, 6);
107
96
 
108
- expect(buttons.length).toBe(6);
97
+ assert.strictEqual(buttons[0].disabled, false, "previous button should be enabled");
98
+ assert.strictEqual(buttons[1].disabled, false, "next button should be enabled");
109
99
 
110
- // previous button
111
- expect(buttons[0]).toBeEnabled();
112
- // last button
113
- expect(buttons[1]).toBeEnabled();
114
- // first button
115
100
  const firstButton = buttons[2];
116
- expect(firstButton).toBeEnabled();
117
- expect(firstButton).toHaveTextContent("1");
101
+ assert.strictEqual(firstButton.disabled, false, "first button should be enabled");
102
+ assert.strictEqual(firstButton.textContent?.trim(), "1", "first button be 1");
118
103
 
119
- // current button
120
104
  const currentButton = buttons[3];
121
- expect(currentButton).toBeDisabled();
122
- expect(currentButton).toHaveTextContent("2");
105
+ assert.strictEqual(currentButton.disabled, true, "current button should be disabled");
106
+ assert.strictEqual(currentButton.textContent?.trim(), "2", "current button be 2");
123
107
 
124
- // next button
125
108
  const nextButton = buttons[4];
126
- expect(nextButton).toBeEnabled();
127
- expect(nextButton).toHaveTextContent("3");
109
+ assert.strictEqual(nextButton.disabled, false, "next button should be enabled");
110
+ assert.strictEqual(nextButton.textContent?.trim(), "3", "next button be 3");
128
111
 
129
- // last button
130
112
  const lastButton = buttons[5];
131
- expect(lastButton).toBeEnabled();
132
- expect(lastButton).toHaveTextContent("148");
113
+ assert.strictEqual(lastButton.disabled, false, "last button should be enabled");
114
+ assert.strictEqual(lastButton.textContent?.trim(), "148", "last button be 148");
133
115
  });
134
116
 
135
117
  it("should render buttons for last page", async () => {
@@ -145,28 +127,24 @@ describe("paginator rendering tests", () => {
145
127
 
146
128
  render(<Paginator collection={collection} />);
147
129
 
148
- const buttons = await screen.findAllByRole("button");
130
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
131
+
132
+ assert.lengthOf(buttons, 5);
149
133
 
150
- expect(buttons.length).toBe(5);
134
+ assert.strictEqual(buttons[0].disabled, false, "previous button should be enabled");
135
+ assert.strictEqual(buttons[1].disabled, true, "next button should be disabled");
151
136
 
152
- // previous button
153
- expect(buttons[0]).toBeEnabled();
154
- // last button
155
- expect(buttons[1]).toBeDisabled();
156
- // first button
157
137
  const firstButton = buttons[2];
158
- expect(firstButton).toBeEnabled();
159
- expect(firstButton).toHaveTextContent("1");
138
+ assert.strictEqual(firstButton.disabled, false, "first button should be enabled");
139
+ assert.strictEqual(firstButton.textContent?.trim(), "1", "first button be 1");
160
140
 
161
- // next button
162
141
  const nextButton = buttons[3];
163
- expect(nextButton).toBeEnabled();
164
- expect(nextButton).toHaveTextContent("147");
142
+ assert.strictEqual(nextButton.disabled, false, "next button should be enabled");
143
+ assert.strictEqual(nextButton.textContent?.trim(), "147", "next button be 147");
165
144
 
166
- // last button
167
145
  const lastButton = buttons[4];
168
- expect(lastButton).toBeDisabled();
169
- expect(lastButton).toHaveTextContent("148");
146
+ assert.strictEqual(lastButton.disabled, true, "last button should be disabled");
147
+ assert.strictEqual(lastButton.textContent?.trim(), "148", "last button be 148");
170
148
  });
171
149
 
172
150
  it("should render buttons for penultimate page", async () => {
@@ -184,33 +162,28 @@ describe("paginator rendering tests", () => {
184
162
 
185
163
  render(<Paginator collection={collection} />);
186
164
 
187
- const buttons = await screen.findAllByRole("button");
165
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
188
166
 
189
- expect(buttons.length).toBe(6);
167
+ assert.lengthOf(buttons, 6);
190
168
 
191
- // previous button
192
- expect(buttons[0]).toBeEnabled();
193
- // last button
194
- expect(buttons[1]).toBeEnabled();
169
+ assert.strictEqual(buttons[0].disabled, false, "previous button should be enabled");
170
+ assert.strictEqual(buttons[1].disabled, false, "next button should be enabled");
195
171
 
196
- // first button
197
172
  const firstButton = buttons[2];
198
- expect(firstButton).toBeEnabled();
199
- expect(firstButton).toHaveTextContent("1");
173
+ assert.strictEqual(firstButton.disabled, false, "first button should be enabled");
174
+ assert.strictEqual(firstButton.textContent?.trim(), "1", "first button be 1");
200
175
 
201
- const currentButton = buttons[3];
202
- expect(currentButton).toBeEnabled();
203
- expect(currentButton).toHaveTextContent("146");
176
+ const previousButton = buttons[3];
177
+ assert.strictEqual(previousButton.disabled, false, "previous button should be enabled");
178
+ assert.strictEqual(previousButton.textContent?.trim(), "146", "previous button be 146");
204
179
 
205
- // current button
206
- const nextButton = buttons[4];
207
- expect(nextButton).toBeDisabled();
208
- expect(nextButton).toHaveTextContent("147");
180
+ const currentButton = buttons[4];
181
+ assert.strictEqual(currentButton.disabled, true, "current button should be disabled");
182
+ assert.strictEqual(currentButton.textContent?.trim(), "147", "current button be 147");
209
183
 
210
- // last button
211
184
  const lastButton = buttons[5];
212
- expect(lastButton).toBeEnabled();
213
- expect(lastButton).toHaveTextContent("148");
185
+ assert.strictEqual(lastButton.disabled, false, "last button should be enabled");
186
+ assert.strictEqual(lastButton.textContent?.trim(), "148", "last button be 148");
214
187
  });
215
188
 
216
189
  it("should render buttons for a page in the middle", async () => {
@@ -228,39 +201,32 @@ describe("paginator rendering tests", () => {
228
201
 
229
202
  render(<Paginator collection={collection} />);
230
203
 
231
- const buttons = await screen.findAllByRole("button");
204
+ const buttons: HTMLButtonElement[] = await screen.findAllByRole("button");
232
205
 
233
- expect(buttons.length).toBe(7);
206
+ assert.lengthOf(buttons, 7);
234
207
 
235
- // previous button
236
- expect(buttons[0]).toBeEnabled();
237
- // next button
238
- expect(buttons[1]).toBeEnabled();
208
+ assert.strictEqual(buttons[0].disabled, false, "previous button should be enabled");
209
+ assert.strictEqual(buttons[1].disabled, false, "next button should be enabled");
239
210
 
240
- // first button
241
- const firstButton = buttons[2];
242
- expect(firstButton).toBeEnabled();
243
- expect(firstButton).toHaveTextContent("1");
211
+ const firstButton = buttons[2] as HTMLButtonElement;
212
+ assert.strictEqual(firstButton.disabled, false, "first button should be enabled");
213
+ assert.strictEqual(firstButton.textContent?.trim(), "1", "first button be 1");
244
214
 
245
- // previous Button
246
215
  const previousButton = buttons[3];
247
- expect(previousButton).toBeEnabled();
248
- expect(previousButton).toHaveTextContent("41");
216
+ assert.strictEqual(previousButton.disabled, false, "previous button should be enabled");
217
+ assert.strictEqual(previousButton.textContent?.trim(), "41", "previous button be 41");
249
218
 
250
- // current button
251
219
  const currentButton = buttons[4];
252
- expect(currentButton).toBeDisabled();
253
- expect(currentButton).toHaveTextContent("42");
220
+ assert.strictEqual(currentButton.disabled, true, "current button should be disabled");
221
+ assert.strictEqual(currentButton.textContent?.trim(), "42", "current button be 42");
254
222
 
255
- // next button
256
223
  const nextButton = buttons[5];
257
- expect(nextButton).toBeEnabled();
258
- expect(nextButton).toHaveTextContent("43");
224
+ assert.strictEqual(nextButton.disabled, false, "next button should be enabled");
225
+ assert.strictEqual(nextButton.textContent?.trim(), "43", "next button be 43");
259
226
 
260
- // last button
261
227
  const lastButton = buttons[6];
262
- expect(lastButton).toBeEnabled();
263
- expect(lastButton).toHaveTextContent("148");
228
+ assert.strictEqual(lastButton.disabled, false, "last button should be enabled");
229
+ assert.strictEqual(lastButton.textContent?.trim(), "148", "last button be 148");
264
230
  });
265
231
 
266
232
  it("should call the function with the last previous url", async () => {
@@ -285,9 +251,9 @@ describe("paginator rendering tests", () => {
285
251
 
286
252
  render(<Paginator collection={collection} onPageChange={callMe} />);
287
253
 
288
- const previousButton = await screen.getByRole("button", { name: /paginator.previous/i });
254
+ const previousButton = screen.getByRole("button", { name: /paginator.previous/i });
289
255
  previousButton.click();
290
256
 
291
- expect(urlToOpen).toBe("https://www.scm-manager.org");
257
+ assert.strictEqual(urlToOpen, "https://www.scm-manager.org", "the url passed to the function is not correct");
292
258
  });
293
- });*/
259
+ });
@@ -1,4 +1,4 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
3
  exports[`Storyshots BranchSelector Default 1`] = `
4
4
  <div
@@ -48,7 +48,7 @@ describe("key comparator tests", () => {
48
48
  });
49
49
 
50
50
  it("should not fail if item is undefined", () => {
51
- const array: any[] = createObjects("key", ["a"]);
51
+ const array: Array<Record<string, unknown> | undefined> = createObjects("key", ["a"]);
52
52
  array.push(undefined);
53
53
  array.push(createObject("key", "z"));
54
54
  array.sort(byKey("key"));
@@ -78,7 +78,7 @@ describe("length comparator tests", () => {
78
78
  });
79
79
 
80
80
  it("should not fail if item is undefined", () => {
81
- const array: any[] = createObjects("key", ["."]);
81
+ const array: Array<Record<string, unknown> | undefined> = createObjects("key", ["."]);
82
82
  array.push(undefined);
83
83
  array.push(createObject("key", ".."));
84
84
  array.sort(byValueLength("key"));
@@ -133,7 +133,7 @@ describe("nested key comparator tests", () => {
133
133
  });
134
134
 
135
135
  it("should not fail if item is undefined", () => {
136
- const array: any[] = createObjects("key", "nested", ["a"]);
136
+ const array: Array<Record<string, unknown> | undefined> = createObjects("key", "nested", ["a"]);
137
137
  array.push(undefined);
138
138
  array.push(createObject("key", "nested", "z"));
139
139
  array.sort(byNestedKeys("key", "nested"));
@@ -36,5 +36,4 @@ describe("syntax highlighter", () => {
36
36
  const lang = determineLanguage("");
37
37
  expect(lang).toBe("text");
38
38
  });
39
-
40
39
  });
@@ -14,17 +14,8 @@
14
14
  * along with this program. If not, see https://www.gnu.org/licenses/.
15
15
  */
16
16
 
17
- import React from "react";
18
17
  import { headingToAnchorId } from "./MarkdownHeadingRenderer";
19
18
 
20
- describe("Temporary test to be removed", () => {
21
- it("true", () => {
22
- expect(true).toBe(true);
23
- });
24
- });
25
-
26
- //TODO Fix jest preset to include TextEncoder in its environment
27
- /*
28
19
  describe("headingToAnchorId tests", () => {
29
20
  it("should lower case the text", () => {
30
21
  expect(headingToAnchorId("Hello")).toBe("hello");
@@ -36,4 +27,4 @@ describe("headingToAnchorId tests", () => {
36
27
  expect(headingToAnchorId("awesome stuff")).toBe("awesome-stuff");
37
28
  expect(headingToAnchorId("a b c d e f")).toBe("a-b-c-d-e-f");
38
29
  });
39
- });*/
30
+ });
@@ -14,16 +14,8 @@
14
14
  * along with this program. If not, see https://www.gnu.org/licenses/.
15
15
  */
16
16
 
17
- import React from "react";
18
17
  import { createLocalLink } from "./MarkdownImageRenderer";
19
18
 
20
- describe("Temporary test to be removed", () => {
21
- it("true", () => {
22
- expect(true).toBe(true);
23
- });
24
- });
25
-
26
- /*
27
19
  describe("createLocalLink tests", () => {
28
20
  const revision = "revision";
29
21
  const basePath = `/repo/namespace/name/code/sources/${revision}/`;
@@ -38,7 +30,7 @@ describe("createLocalLink tests", () => {
38
30
 
39
31
  it("should return modified contentLink for absolute link", () => {
40
32
  expect(createLocalLink(basePath, contentLink, revision, currentPath, "/path/anotherImg.jpg")).toBe(
41
- "http://localhost:8081/scm/api/v2/repositories/namespace/name/content/revision/path/anotherImg.jpg"
33
+ "http://localhost:8081/scm/api/v2/repositories/namespace/name/content/revision/path/anotherImg.jpg",
42
34
  );
43
35
  });
44
36
 
@@ -49,8 +41,8 @@ describe("createLocalLink tests", () => {
49
41
  contentLink,
50
42
  "feature/awesome",
51
43
  currentPath,
52
- link
53
- )
44
+ link,
45
+ ),
54
46
  ).toContain("feature%2Fawesome");
55
47
  });
56
- });*/
48
+ });
@@ -17,14 +17,6 @@
17
17
  import { isAnchorLink, isExternalLink, isLinkWithProtocol, isInternalScmRepoLink } from "./paths";
18
18
  import { createLocalLink } from "./MarkdownLinkRenderer";
19
19
 
20
- describe("Temporary test to be removed", () => {
21
- it("true", () => {
22
- expect(true).toBe(true);
23
- });
24
- });
25
-
26
- //TODO Fix jest preset to include TextEncoder in its environment
27
- /*
28
20
  describe("test isAnchorLink", () => {
29
21
  it("should return true", () => {
30
22
  expect(isAnchorLink("#some-thing")).toBe(true);
@@ -135,4 +127,3 @@ describe("test createLocalLink", () => {
135
127
  expect(localLink).toBe(expected);
136
128
  };
137
129
  });
138
- */
@@ -19,16 +19,18 @@ import React, { FC, ReactNode } from "react";
19
19
  import ActiveModalCountContext, { ModalStateContextType } from "./activeModalCountContext";
20
20
  import useRegisterModal from "./useRegisterModal";
21
21
 
22
- const createWrapper =
23
- (context: ModalStateContextType): FC<{ children: ReactNode }> =>
24
- ({ children }: { children: React.ReactNode }) => {
25
- return <ActiveModalCountContext.Provider value={context}>{children}</ActiveModalCountContext.Provider>;
26
- };
22
+ const createWrapper = (context: ModalStateContextType): FC<{ children: ReactNode }> => {
23
+ const Wrapper: FC<{ children: ReactNode }> = ({ children }) => (
24
+ <ActiveModalCountContext.Provider value={context}>{children}</ActiveModalCountContext.Provider>
25
+ );
26
+ Wrapper.displayName = "ActiveModalCountContextWrapper";
27
+ return Wrapper;
28
+ };
27
29
 
28
30
  describe("useRegisterModal", () => {
29
31
  it("should increment and not decrement on active registration", () => {
30
- const increment = jest.fn();
31
- const decrement = jest.fn();
32
+ const increment = vi.fn();
33
+ const decrement = vi.fn();
32
34
 
33
35
  renderHook(() => useRegisterModal(true), {
34
36
  wrapper: createWrapper({ value: 0, increment, decrement }),
@@ -39,8 +41,8 @@ describe("useRegisterModal", () => {
39
41
  });
40
42
 
41
43
  it("should not decrement on inactive registration", () => {
42
- const increment = jest.fn();
43
- const decrement = jest.fn();
44
+ const increment = vi.fn();
45
+ const decrement = vi.fn();
44
46
 
45
47
  renderHook(() => useRegisterModal(false), {
46
48
  wrapper: createWrapper({ value: 0, increment, decrement }),
@@ -51,8 +53,8 @@ describe("useRegisterModal", () => {
51
53
  });
52
54
 
53
55
  it("should not decrement on inactive de-registration", () => {
54
- const increment = jest.fn();
55
- const decrement = jest.fn();
56
+ const increment = vi.fn();
57
+ const decrement = vi.fn();
56
58
 
57
59
  const result = renderHook(() => useRegisterModal(false), {
58
60
  wrapper: createWrapper({ value: 0, increment, decrement }),
@@ -65,8 +67,8 @@ describe("useRegisterModal", () => {
65
67
  });
66
68
 
67
69
  it("should decrement once on active de-registration", () => {
68
- const increment = jest.fn();
69
- const decrement = jest.fn();
70
+ const increment = vi.fn();
71
+ const decrement = vi.fn();
70
72
 
71
73
  const result = renderHook(() => useRegisterModal(false, true), {
72
74
  wrapper: createWrapper({ value: 0, increment, decrement }),
@@ -79,11 +81,10 @@ describe("useRegisterModal", () => {
79
81
  });
80
82
 
81
83
  it("should decrement once when switching from active to inactive", () => {
82
- const increment = jest.fn();
83
- const decrement = jest.fn();
84
+ const increment = vi.fn();
85
+ const decrement = vi.fn();
84
86
 
85
87
  const result = renderHook(({ active }: { active: boolean }) => useRegisterModal(active), {
86
- // @ts-ignore
87
88
  wrapper: createWrapper({ value: 0, increment, decrement }),
88
89
  initialProps: { active: true },
89
90
  });
@@ -295,7 +295,7 @@ describe("with hunks the diff expander", () => {
295
295
  const preceedingHunk = diffExpander.getHunk(0).hunk;
296
296
  fetchMock.get(
297
297
  "http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=8&end=13",
298
- "new line 9\nnew line 10\nnew line 11\nnew line 12\nnew line 13"
298
+ "new line 9\nnew line 10\nnew line 11\nnew line 12\nnew line 13",
299
299
  );
300
300
  let newFile: FileDiff;
301
301
  await diffExpander
@@ -324,7 +324,7 @@ describe("with hunks the diff expander", () => {
324
324
  const oldHunkCount = diffExpander.hunkCount();
325
325
  fetchMock.get(
326
326
  "http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=40&end=50",
327
- "new line 40\nnew line 41\nnew line 42"
327
+ "new line 40\nnew line 41\nnew line 42",
328
328
  );
329
329
  let newFile: FileDiff;
330
330
  await diffExpander
@@ -337,7 +337,7 @@ describe("with hunks the diff expander", () => {
337
337
  it("should set end to -1 if requested to expand to the end", async () => {
338
338
  fetchMock.get(
339
339
  "http://localhost:8081/scm/api/v2/content/abc/CommitMessage.js?start=40&end=-1",
340
- "new line 40\nnew line 41\nnew line 42"
340
+ "new line 40\nnew line 41\nnew line 42",
341
341
  );
342
342
  let newFile: FileDiff;
343
343
  await diffExpander
@@ -14,52 +14,57 @@
14
14
  * along with this program. If not, see https://www.gnu.org/licenses/.
15
15
  */
16
16
 
17
- import * as changesets from "./changesets";
17
+ import React from "react";
18
+ import { BrowserRouter } from "react-router-dom";
18
19
  import { render } from "@testing-library/react";
19
20
  import { Branch, Changeset, Repository } from "@scm-manager/ui-types";
21
+ import * as changesets from "./changesets";
20
22
  import ChangesetButtonGroup from "./ChangesetButtonGroup";
21
- import React from "react";
22
- import { BrowserRouter } from "react-router-dom";
23
23
 
24
- const createChangesetLink = jest.spyOn(changesets, "createChangesetLink");
25
- const createChangesetLinkByBranch = jest.spyOn(changesets, "createChangesetLinkByBranch");
26
-
27
- afterEach(() => {
28
- jest.resetAllMocks();
24
+ vi.mock("react-router", async (importOriginal) => {
25
+ const actual = await importOriginal();
26
+ return {
27
+ ...(actual as Record<string, unknown>),
28
+ // Mock the 'Link' component to render an <a> tag directly, bypassing the broken router context (Fixes basename error)
29
+ Link: vi.fn(({ to, children, ...props }) => (
30
+ <a href={to} {...props}>
31
+ {children}
32
+ </a>
33
+ )),
34
+ };
29
35
  });
30
36
 
31
- describe("Temporary test to be removed", () => {
32
- it("true", () => {
33
- expect(true).toBe(true);
34
- });
37
+ const createChangesetLink = vi.spyOn(changesets, "createChangesetLink").mockReturnValue("/changeset");
38
+ const createChangesetLinkByBranch = vi.spyOn(changesets, "createChangesetLinkByBranch").mockReturnValue("/branch");
39
+
40
+ afterEach(() => {
41
+ vi.resetAllMocks();
35
42
  });
36
43
 
37
- //TODO Fix jest preset to include TextEncoder in its environment
38
- /*describe("ChangesetButtonGroup", () => {
39
- test("shouldCallCreateChangesetLinkWithoutBranch", async () => {
44
+ describe("ChangesetButtonGroup", () => {
45
+ it("should call createChangesetLink without branch", () => {
40
46
  const { repository, changeset } = createTestData();
41
47
  render(
42
48
  <BrowserRouter>
43
49
  <ChangesetButtonGroup repository={repository} changeset={changeset}></ChangesetButtonGroup>
44
- </BrowserRouter>
50
+ </BrowserRouter>,
45
51
  );
46
52
  expect(createChangesetLink).toHaveBeenCalled();
47
53
  expect(createChangesetLinkByBranch).toHaveBeenCalledTimes(0);
48
54
  });
49
55
 
50
- test("shouldCallCreateChangesetLinkByBranchWithBranch", async () => {
56
+ it("should call createChangesetLink by branch with branch", () => {
51
57
  const { repository, changeset, branch } = createTestData();
52
58
  render(
53
59
  <BrowserRouter>
54
60
  <ChangesetButtonGroup repository={repository} changeset={changeset} branch={branch}></ChangesetButtonGroup>
55
- </BrowserRouter>
61
+ </BrowserRouter>,
56
62
  );
57
63
  expect(createChangesetLinkByBranch).toHaveBeenCalled();
58
64
  expect(createChangesetLink).toHaveBeenCalledTimes(0);
59
65
  });
60
66
  });
61
67
 
62
- // TODO centralized test data
63
68
  function createTestData() {
64
69
  const repository: Repository = { _links: {}, name: "", namespace: "", type: "" };
65
70
  const changeset: Changeset = {
@@ -73,4 +78,4 @@ function createTestData() {
73
78
  };
74
79
  const branch: Branch = { _links: {}, name: "", revision: "" };
75
80
  return { repository, changeset, branch };
76
- }*/
81
+ }
@@ -16,14 +16,6 @@
16
16
 
17
17
  import { createUrl, isDiffSupported } from "./ChangesetDiff";
18
18
 
19
- describe("Temporary test to be removed", () => {
20
- it("true", () => {
21
- expect(true).toBe(true);
22
- });
23
- });
24
-
25
- //TODO Fix jest preset to include TextEncoder in its environment
26
- /*
27
19
  describe("isDiffSupported tests", () => {
28
20
  it("should return true if diff link is defined", () => {
29
21
  const supported = isDiffSupported({
@@ -105,4 +97,4 @@ describe("createUrl tests", () => {
105
97
  }),
106
98
  ).toThrow();
107
99
  });
108
- });*/
100
+ });
@@ -27,10 +27,10 @@ describe("getProtocolLinkByType tests", () => {
27
27
  protocol: [
28
28
  {
29
29
  name: "http",
30
- href: "http://scm.scm-manager.org/repo/scm/core"
31
- }
32
- ]
33
- }
30
+ href: "http://scm.scm-manager.org/repo/scm/core",
31
+ },
32
+ ],
33
+ },
34
34
  };
35
35
 
36
36
  const link = getProtocolLinkByType(repository, "http");
@@ -46,14 +46,14 @@ describe("getProtocolLinkByType tests", () => {
46
46
  protocol: [
47
47
  {
48
48
  name: "http",
49
- href: "http://scm.scm-manager.org/repo/scm/core"
49
+ href: "http://scm.scm-manager.org/repo/scm/core",
50
50
  },
51
51
  {
52
52
  name: "ssh",
53
- href: "git@scm.scm-manager.org:scm/core"
54
- }
55
- ]
56
- }
53
+ href: "git@scm.scm-manager.org:scm/core",
54
+ },
55
+ ],
56
+ },
57
57
  };
58
58
 
59
59
  const link = getProtocolLinkByType(repository, "http");
@@ -68,9 +68,9 @@ describe("getProtocolLinkByType tests", () => {
68
68
  _links: {
69
69
  protocol: {
70
70
  name: "http",
71
- href: "http://scm.scm-manager.org/repo/scm/core"
72
- }
73
- }
71
+ href: "http://scm.scm-manager.org/repo/scm/core",
72
+ },
73
+ },
74
74
  };
75
75
 
76
76
  const link = getProtocolLinkByType(repository, "http");
@@ -86,14 +86,14 @@ describe("getProtocolLinkByType tests", () => {
86
86
  protocol: [
87
87
  {
88
88
  name: "http",
89
- href: "http://scm.scm-manager.org/repo/scm/core"
89
+ href: "http://scm.scm-manager.org/repo/scm/core",
90
90
  },
91
91
  {
92
92
  name: "ssh",
93
- href: "git@scm.scm-manager.org:scm/core"
94
- }
95
- ]
96
- }
93
+ href: "git@scm.scm-manager.org:scm/core",
94
+ },
95
+ ],
96
+ },
97
97
  };
98
98
 
99
99
  const link = getProtocolLinkByType(repository, "awesome");
@@ -105,7 +105,7 @@ describe("getProtocolLinkByType tests", () => {
105
105
  namespace: "scm",
106
106
  name: "core",
107
107
  type: "git",
108
- _links: {}
108
+ _links: {},
109
109
  };
110
110
 
111
111
  const link = getProtocolLinkByType(repository, "http");
@@ -88,7 +88,7 @@ describe("test mail validation", () => {
88
88
  "s.sdorra @ostfalia.de",
89
89
  "s.sdorra@[ostfalia.de",
90
90
  "abc.example.com",
91
- "a@b@c@example.com"
91
+ "a@b@c@example.com",
92
92
  ];
93
93
  for (const mail of invalid) {
94
94
  it(`should return false for '${mail}'`, () => {
@@ -113,7 +113,7 @@ describe("test mail validation", () => {
113
113
  "example@s.example",
114
114
  "user.name+tag+sorting@example.com",
115
115
  "name/surname@example.com",
116
- "user%example.com@example.org"
116
+ "user%example.com@example.org",
117
117
  ];
118
118
  for (const mail of valid) {
119
119
  it(`should return true for '${mail}'`, () => {