Skip to content

Commit b4bb8d6

Browse files
dazy-dsmhordynski
authored andcommitted
chore: remove config test (#795)
1 parent f526fc6 commit b4bb8d6

File tree

4 files changed

+21
-83
lines changed

4 files changed

+21
-83
lines changed

packages/ragbits-chat/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CHANGELOG
22

33
## Unreleased
4+
- Remove redundant test for `/api/config` endpoint (#795)
45
- Fix bug causing infinite initialization screen (#793)
56
- Fix bug that caused messages to be sent when changing chat settings; simplify and harden history logic (#791)
67
- Add `clear_message` event type allowing to reset whole message (#789)

typescript/ui/__tests__/integration/intergation.test.tsx

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import {
1313
act,
1414
render,
15-
renderHook,
1615
waitFor,
1716
screen,
1817
fireEvent,
@@ -26,7 +25,6 @@ import {
2625
MessageRole,
2726
FeedbackType,
2827
} from "@ragbits/api-client-react";
29-
import { useConfigContext } from "../../src/core/contexts/ConfigContext/useConfigContext";
3028
import { ConfigContextProvider } from "../../src/core/contexts/ConfigContext/ConfigContextProvider";
3129
import userEvent from "@testing-library/user-event";
3230
import PromptInput from "../../src/core/components/inputs/PromptInput/PromptInput";
@@ -61,69 +59,6 @@ historyStore.getState()._internal._setHasHydrated(true);
6159

6260
describe("Integration tests", () => {
6361
const BASE_URL = "http://127.0.0.1:8000";
64-
const renderWithHook = <R,>(hook: () => R) => {
65-
return renderHook(() => hook(), {
66-
wrapper: ({ children }: { children: React.ReactNode }) => {
67-
return (
68-
<RagbitsContextProvider baseUrl={BASE_URL}>
69-
<ConfigContextProvider>{children}</ConfigContextProvider>
70-
</RagbitsContextProvider>
71-
);
72-
},
73-
});
74-
};
75-
/**
76-
* This should test all default endpoints from the API
77-
* using UIs mechanims
78-
*/
79-
describe("/api/config", () => {
80-
it("should return config", async () => {
81-
// TODO: Automate generation of this test
82-
const { result } = renderWithHook(() => useConfigContext());
83-
84-
await waitFor(() => {
85-
expect(result.current).not.toBeNull();
86-
});
87-
88-
const config = result.current.config;
89-
// Customization
90-
expect(config).toHaveProperty("customization");
91-
// Debug mode
92-
expect(config).toHaveProperty("debug_mode");
93-
expect(typeof config.debug_mode).toBe("boolean");
94-
// History mode
95-
expect(config).toHaveProperty("conversation_history");
96-
expect(typeof config.conversation_history).toBe("boolean");
97-
// Authentication
98-
expect(typeof config.authentication).toBe("object");
99-
expect(typeof config.authentication.enabled).toBe("boolean");
100-
expect(Array.isArray(config.authentication.auth_types)).toBe(true);
101-
// Usage
102-
expect(config).toHaveProperty("show_usage");
103-
expect(typeof config.show_usage).toBe("boolean");
104-
105-
// Feedback
106-
expect(config).toHaveProperty("feedback");
107-
expect(config.feedback).toHaveProperty(FeedbackType.Like);
108-
expect(config.feedback).toHaveProperty("like");
109-
expect(config.feedback.like).toHaveProperty("enabled");
110-
expect(typeof config.feedback.like.enabled === "boolean").toBe(true);
111-
expect(config.feedback.like).toHaveProperty("form");
112-
expect(
113-
config.feedback.like.form === null ||
114-
config.feedback.like.form instanceof Object,
115-
).toBe(true);
116-
117-
expect(config.feedback).toHaveProperty(FeedbackType.Dislike);
118-
expect(config.feedback.dislike).toHaveProperty("enabled");
119-
expect(typeof config.feedback.dislike.enabled === "boolean").toBe(true);
120-
expect(config.feedback.dislike).toHaveProperty("form");
121-
expect(
122-
config.feedback.dislike.form === null ||
123-
config.feedback.dislike.form instanceof Object,
124-
).toBe(true);
125-
});
126-
});
12762

12863
describe("/api/chat", { timeout: 30000 }, () => {
12964
describe("should call chat endpoint with correct data", () => {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { cn } from "@heroui/react";
2+
3+
export default function InitializationErrorScreen() {
4+
return (
5+
<div
6+
className={cn(
7+
"bg-background flex h-screen w-screen items-start justify-center",
8+
)}
9+
>
10+
<div className="text-default-900 m-auto flex flex-col items-center gap-4">
11+
<p className="text-large">
12+
Something went wrong during chat initialization.
13+
</p>
14+
<p className="text-small text-default-500">Try refreshing the page.</p>
15+
</div>
16+
</div>
17+
);
18+
}

typescript/ui/src/core/contexts/ConfigContext/ConfigContextProvider.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PropsWithChildren, useEffect, useLayoutEffect, useMemo } from "react";
22
import { ConfigContext } from "./ConfigContext";
33
import { useRagbitsCall } from "@ragbits/api-client-react";
4-
import { cn } from "@heroui/react";
54
import { FeedbackFormPluginName } from "../../../plugins/FeedbackPlugin";
65
import { ChatOptionsPluginName } from "../../../plugins/ChatOptionsPlugin";
76
import { pluginManager } from "../../utils/plugins/PluginManager";
@@ -12,6 +11,7 @@ import { CONFIG_LOADING_PAGE_TITLE } from "../../../config";
1211
import { AuthPluginName } from "../../../plugins/AuthPlugin";
1312
import { UsagePluginName } from "../../../plugins/UsagePlugin";
1413
import InitializationScreen from "../../components/InitializationScreen";
14+
import InitializationErrorScreen from "../../components/InitializationErrorScreen";
1515

1616
export function ConfigContextProvider({ children }: PropsWithChildren) {
1717
const { call: fetchConfig, ...config } = useRagbitsCall("/api/config");
@@ -66,28 +66,12 @@ export function ConfigContextProvider({ children }: PropsWithChildren) {
6666
document.title = CONFIG_LOADING_PAGE_TITLE;
6767
}, []);
6868

69-
// TODO: Consider adding minimal timeout for config to not flash users with this screen
7069
if (config.isLoading) {
7170
return <InitializationScreen />;
7271
}
7372

7473
if (config.error || !value) {
75-
return (
76-
<div
77-
className={cn(
78-
"bg-background flex h-screen w-screen items-start justify-center",
79-
)}
80-
>
81-
<div className="text-default-900 m-auto flex flex-col items-center gap-4">
82-
<p className="text-large">
83-
Something went wrong during chat initialization.
84-
</p>
85-
<p className="text-small text-default-500">
86-
Try refreshing the page.
87-
</p>
88-
</div>
89-
</div>
90-
);
74+
return <InitializationErrorScreen />;
9175
}
9276

9377
return (

0 commit comments

Comments
 (0)