Skip to content

Commit 79e08c4

Browse files
committed
Finish removing urql and use new test render wrapper
1 parent 6921c76 commit 79e08c4

File tree

18 files changed

+559
-690
lines changed

18 files changed

+559
-690
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ updates:
8888
patterns:
8989
- "jotai"
9090
- "jotai-*"
91-
urql:
92-
patterns:
93-
- "urql"
94-
- "@urql/*"
9591
graphql-codegen:
9692
patterns:
9793
- "@graphql-codegen/*"

frontend/package-lock.json

Lines changed: 2 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"react-dom": "^18.3.1",
4242
"react-i18next": "^15.1.1",
4343
"swagger-ui-react": "^5.18.2",
44-
"urql": "^4.2.1",
4544
"vaul": "^1.1.1",
4645
"zod": "^3.23.8"
4746
},
@@ -76,7 +75,6 @@
7675
"postcss": "^8.4.49",
7776
"postcss-modules": "^6.0.1",
7877
"postcss-nesting": "^13.0.1",
79-
"react-test-renderer": "^18.3.1",
8078
"rimraf": "^6.0.1",
8179
"storybook": "^8.3.5",
8280
"storybook-react-i18next": "^3.1.7",

frontend/src/components/Block/Block.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@
66

77
// @vitest-environment happy-dom
88

9-
import { create } from "react-test-renderer";
109
import { describe, expect, it } from "vitest";
1110

11+
import render from "../../test-utils/render";
1212
import Block from "./Block";
1313

1414
describe("Block", () => {
1515
it("render <Block />", () => {
16-
const component = create(<Block />);
17-
expect(component.toJSON()).toMatchSnapshot();
16+
const { asFragment } = render(<Block />);
17+
expect(asFragment()).toMatchSnapshot();
1818
});
1919

2020
it("render <Block /> with children", () => {
21-
const component = create(
21+
const { asFragment } = render(
2222
<Block>
2323
<h1>Title</h1>
2424
<p>Body</p>
2525
</Block>,
2626
);
27-
expect(component.toJSON()).toMatchSnapshot();
27+
expect(asFragment()).toMatchSnapshot();
2828
});
2929

3030
it("passes down the className prop", () => {
31-
const component = create(<Block className="foo" />);
32-
expect(component.toJSON()).toMatchSnapshot();
31+
const { asFragment } = render(<Block className="test" />);
32+
expect(asFragment()).toMatchSnapshot();
3333
});
3434

3535
it("renders with highlight", () => {
36-
const component = create(<Block highlight />);
37-
expect(component.toJSON()).toMatchSnapshot();
36+
const { asFragment } = render(<Block highlight />);
37+
expect(asFragment()).toMatchSnapshot();
3838
});
3939
});
Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`Block > passes down the className prop 1`] = `
4-
<div
5-
className="_block_17898c foo"
6-
/>
4+
<DocumentFragment>
5+
<div
6+
class="_block_17898c test"
7+
/>
8+
</DocumentFragment>
79
`;
810

911
exports[`Block > render <Block /> 1`] = `
10-
<div
11-
className="_block_17898c"
12-
/>
12+
<DocumentFragment>
13+
<div
14+
class="_block_17898c"
15+
/>
16+
</DocumentFragment>
1317
`;
1418

1519
exports[`Block > render <Block /> with children 1`] = `
16-
<div
17-
className="_block_17898c"
18-
>
19-
<h1>
20-
Title
21-
</h1>
22-
<p>
23-
Body
24-
</p>
25-
</div>
20+
<DocumentFragment>
21+
<div
22+
class="_block_17898c"
23+
>
24+
<h1>
25+
Title
26+
</h1>
27+
<p>
28+
Body
29+
</p>
30+
</div>
31+
</DocumentFragment>
2632
`;
2733

2834
exports[`Block > renders with highlight 1`] = `
29-
<div
30-
className="_block_17898c"
31-
data-active={true}
32-
/>
35+
<DocumentFragment>
36+
<div
37+
class="_block_17898c"
38+
data-active="true"
39+
/>
40+
</DocumentFragment>
3341
`;

frontend/src/components/BlockList/BlockList.test.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,29 @@
66

77
// @vitest-environment happy-dom
88

9-
import { create } from "react-test-renderer";
109
import { describe, expect, it } from "vitest";
11-
10+
import render from "../../test-utils/render";
1211
import Block from "../Block";
13-
1412
import BlockList from "./BlockList";
1513

1614
describe("BlockList", () => {
1715
it("render an empty <BlockList />", () => {
18-
const component = create(<BlockList />);
19-
expect(component.toJSON()).toMatchSnapshot();
16+
const { asFragment } = render(<BlockList />);
17+
expect(asFragment()).toMatchSnapshot();
2018
});
2119

2220
it("render <BlockList /> with children", () => {
23-
const component = create(
21+
const { asFragment } = render(
2422
<BlockList>
2523
<Block>Block 1</Block>
2624
<Block>Block 2</Block>
2725
</BlockList>,
2826
);
29-
expect(component.toJSON()).toMatchSnapshot();
27+
expect(asFragment()).toMatchSnapshot();
3028
});
3129

3230
it("passes down the className prop", () => {
33-
const component = create(<BlockList className="foo" />);
34-
expect(component.toJSON()).toMatchSnapshot();
31+
const { asFragment } = render(<BlockList className="foo" />);
32+
expect(asFragment()).toMatchSnapshot();
3533
});
3634
});
Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`BlockList > passes down the className prop 1`] = `
4-
<div
5-
className="_blockList_f8cc7f foo"
6-
/>
4+
<DocumentFragment>
5+
<div
6+
class="_blockList_f8cc7f foo"
7+
/>
8+
</DocumentFragment>
79
`;
810

911
exports[`BlockList > render <BlockList /> with children 1`] = `
10-
<div
11-
className="_blockList_f8cc7f"
12-
>
12+
<DocumentFragment>
1313
<div
14-
className="_block_17898c"
14+
class="_blockList_f8cc7f"
1515
>
16-
Block 1
16+
<div
17+
class="_block_17898c"
18+
>
19+
Block 1
20+
</div>
21+
<div
22+
class="_block_17898c"
23+
>
24+
Block 2
25+
</div>
1726
</div>
18-
<div
19-
className="_block_17898c"
20-
>
21-
Block 2
22-
</div>
23-
</div>
27+
</DocumentFragment>
2428
`;
2529

2630
exports[`BlockList > render an empty <BlockList /> 1`] = `
27-
<div
28-
className="_blockList_f8cc7f"
29-
/>
31+
<DocumentFragment>
32+
<div
33+
class="_blockList_f8cc7f"
34+
/>
35+
</DocumentFragment>
3036
`;
Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
// Copyright 2024 New Vector Ltd.
2-
// Copyright 2023, 2024 The Matrix.org Foundation C.I.C.
2+
// Copyright 2023-2024 The Matrix.org Foundation C.I.C.
33
//
44
// SPDX-License-Identifier: AGPL-3.0-only
55
// Please see LICENSE in the repository root for full details.
66

77
// @vitest-environment happy-dom
88

9-
import { create } from "react-test-renderer";
10-
import { Provider } from "urql";
119
import { beforeAll, describe, expect, it } from "vitest";
12-
import { never } from "wonka";
13-
1410
import { makeFragmentData } from "../gql";
1511
import { mockLocale } from "../test-utils/mockLocale";
16-
import { DummyRouter } from "../test-utils/router";
17-
12+
import render from "../test-utils/render";
1813
import CompatSession, { FRAGMENT } from "./CompatSession";
1914

2015
describe("<CompatSession />", () => {
21-
const mockClient = {
22-
executeQuery: (): typeof never => never,
23-
};
24-
2516
const baseSession = {
2617
id: "session-id",
2718
deviceId: "abcd1234",
@@ -39,14 +30,8 @@ describe("<CompatSession />", () => {
3930

4031
it("renders an active session", () => {
4132
const session = makeFragmentData(baseSession, FRAGMENT);
42-
const component = create(
43-
<Provider value={mockClient}>
44-
<DummyRouter>
45-
<CompatSession session={session} />
46-
</DummyRouter>
47-
</Provider>,
48-
);
49-
expect(component.toJSON()).toMatchSnapshot();
33+
const { asFragment } = render(<CompatSession session={session} />);
34+
expect(asFragment()).toMatchSnapshot();
5035
});
5136

5237
it("renders a finished session", () => {
@@ -57,13 +42,7 @@ describe("<CompatSession />", () => {
5742
},
5843
FRAGMENT,
5944
);
60-
const component = create(
61-
<Provider value={mockClient}>
62-
<DummyRouter>
63-
<CompatSession session={session} />
64-
</DummyRouter>
65-
</Provider>,
66-
);
67-
expect(component.toJSON()).toMatchSnapshot();
45+
const { asFragment } = render(<CompatSession session={session} />);
46+
expect(asFragment()).toMatchSnapshot();
6847
});
6948
});

0 commit comments

Comments
 (0)