Skip to content

Commit 27102c3

Browse files
youssefbenlemlihRichardSiegel
authored andcommitted
fix frontend tests
1 parent 2de2f24 commit 27102c3

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

frontend/src/components/InAppDocsProvider.ui-unit.spec.tsx

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { MantineProvider } from '@mantine/core';
22
import { fireEvent, render, screen } from '@testing-library/react';
3+
import { PropsWithChildren } from 'react';
34
import { describe, expect, it, vi } from 'vitest';
5+
import { ProfileContext } from 'src/hooks';
46
import { InAppDocsProvider, useDocsContext } from './InAppDocsProvider';
57

68
vi.mock('react-router-dom', () => ({
@@ -17,6 +19,11 @@ vi.mock('@tanstack/react-query', () => ({
1719
})),
1820
}));
1921

22+
const ProfileProvider = ({ children }: PropsWithChildren) => (
23+
<ProfileContext.Provider value={{ id: '', name: 'Admin', email: '[email protected]', isAdmin: true }}>
24+
{children}
25+
</ProfileContext.Provider>
26+
);
2027
const TestComponent = () => {
2128
const { isDocsButtonVisible, toggleDocs } = useDocsContext();
2229
return (
@@ -34,9 +41,11 @@ describe('InAppDocsProvider', () => {
3441
it('initially shows docs button and hide docs panel', () => {
3542
render(
3643
<MantineProvider>
37-
<InAppDocsProvider>
38-
<TestComponent />
39-
</InAppDocsProvider>
44+
<ProfileProvider>
45+
<InAppDocsProvider>
46+
<TestComponent />
47+
</InAppDocsProvider>
48+
</ProfileProvider>
4049
</MantineProvider>,
4150
);
4251

@@ -47,9 +56,11 @@ describe('InAppDocsProvider', () => {
4756
it('after toggle: hides docs button and shows docs panel', () => {
4857
render(
4958
<MantineProvider>
50-
<InAppDocsProvider>
51-
<TestComponent />
52-
</InAppDocsProvider>
59+
<ProfileProvider>
60+
<InAppDocsProvider>
61+
<TestComponent />
62+
</InAppDocsProvider>
63+
</ProfileProvider>
5364
</MantineProvider>,
5465
);
5566

@@ -61,9 +72,11 @@ describe('InAppDocsProvider', () => {
6172
it('close button: shows docs button and hides docs panel', () => {
6273
render(
6374
<MantineProvider>
64-
<InAppDocsProvider>
65-
<TestComponent />
66-
</InAppDocsProvider>
75+
<ProfileProvider>
76+
<InAppDocsProvider>
77+
<TestComponent />
78+
</InAppDocsProvider>
79+
</ProfileProvider>
6780
</MantineProvider>,
6881
);
6982

0 commit comments

Comments
 (0)