Skip to content

Commit b25fee6

Browse files
authored
feat: Add support for help text config in UI (#2448)
* Add support for help text config in UI * f
1 parent 7ba1d0c commit b25fee6

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

web/src/components/wizard/config/ConfigurationStep.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ const ConfigurationStep: React.FC<ConfigurationStepProps> = ({ onNext }) => {
170170
value={getDisplayValue(item)}
171171
onChange={handleInputChange}
172172
dataTestId={`text-input-${item.name}`}
173+
helpText={item.help_text}
173174
/>
174175
);
175176

web/src/components/wizard/tests/ConfigurationStep.test.tsx

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const MOCK_APP_CONFIG: AppConfig = {
1818
title: "Application Name",
1919
type: "text",
2020
value: "My App",
21-
default: "Default App"
21+
default: "Default App",
22+
help_text: "Enter the name of your application"
2223
},
2324
{
2425
name: "description",
@@ -266,8 +267,12 @@ describe.each([
266267
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
267268
});
268269

270+
// Wait for the content to be rendered
271+
await waitFor(() => {
272+
expect(screen.getByTestId("config-item-app_name")).toBeInTheDocument();
273+
});
274+
269275
// Initially, Settings tab should be active
270-
expect(screen.getByTestId("config-item-app_name")).toBeInTheDocument();
271276
expect(screen.getByTestId("config-item-description")).toBeInTheDocument();
272277
expect(screen.getByTestId("config-item-enable_feature")).toBeInTheDocument();
273278
expect(screen.getByTestId("config-item-auth_type")).toBeInTheDocument();
@@ -303,6 +308,11 @@ describe.each([
303308
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
304309
});
305310

311+
// Wait for the content to be rendered
312+
await waitFor(() => {
313+
expect(screen.getByTestId("text-input-app_name")).toBeInTheDocument();
314+
});
315+
306316
// Find and update text input
307317
const appNameInput = screen.getByTestId("text-input-app_name");
308318
fireEvent.change(appNameInput, { target: { value: "New App Name" } });
@@ -370,6 +380,11 @@ describe.each([
370380
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
371381
});
372382

383+
// Wait for the content to be rendered
384+
await waitFor(() => {
385+
expect(screen.getByTestId("bool-input-enable_feature")).toBeInTheDocument();
386+
});
387+
373388
// Find and toggle checkbox
374389
const enableFeatureCheckbox = screen.getByTestId("bool-input-enable_feature");
375390
expect(enableFeatureCheckbox).not.toBeChecked();
@@ -440,6 +455,11 @@ describe.each([
440455
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
441456
});
442457

458+
// Wait for the content to be rendered
459+
await waitFor(() => {
460+
expect(screen.getByTestId("text-input-app_name")).toBeInTheDocument();
461+
});
462+
443463
// Make changes to form fields
444464
const appNameInput = screen.getByTestId("text-input-app_name");
445465
fireEvent.change(appNameInput, { target: { value: "Updated App Name" } });
@@ -491,6 +511,28 @@ describe.each([
491511
});
492512
});
493513

514+
it("displays help text for text inputs", async () => {
515+
renderWithProviders(<ConfigurationStep onNext={mockOnNext} />, {
516+
wrapperProps: {
517+
authenticated: true,
518+
target: target,
519+
},
520+
});
521+
522+
// Wait for loading to complete
523+
await waitFor(() => {
524+
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
525+
});
526+
527+
// Wait for the content to be rendered
528+
await waitFor(() => {
529+
expect(screen.getByTestId("text-input-app_name")).toBeInTheDocument();
530+
});
531+
532+
// Verify help text is displayed for the app_name field
533+
expect(screen.getByText("Enter the name of your application")).toBeInTheDocument();
534+
});
535+
494536
it("handles unauthorized error correctly", async () => {
495537
server.use(
496538
http.get(`*/api/${target}/install/app/config`, () => {
@@ -537,6 +579,11 @@ describe.each([
537579
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
538580
});
539581

582+
// Wait for the content to be rendered
583+
await waitFor(() => {
584+
expect(screen.getByTestId("text-input-app_name")).toBeInTheDocument();
585+
});
586+
540587
// Change the app name
541588
const appNameInput = screen.getByTestId("text-input-app_name");
542589
fireEvent.change(appNameInput, { target: { value: "Only Changed Field" } });
@@ -735,8 +782,13 @@ describe.each([
735782
expect(screen.queryByTestId("configuration-step-loading")).not.toBeInTheDocument();
736783
});
737784

785+
// Wait for the content to be rendered
786+
await waitFor(() => {
787+
// Check that all radio groups are rendered
788+
expect(screen.getByTestId("config-item-authentication_method")).toBeInTheDocument();
789+
});
790+
738791
// Check that all radio groups are rendered
739-
expect(screen.getByTestId("config-item-authentication_method")).toBeInTheDocument();
740792
expect(screen.getByTestId("config-item-database_type")).toBeInTheDocument();
741793
expect(screen.getByTestId("config-item-logging_level")).toBeInTheDocument();
742794
expect(screen.getByTestId("config-item-ssl_mode")).toBeInTheDocument();

web/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface AppConfigItem {
3535
type: string;
3636
value?: string;
3737
default?: string;
38+
help_text?: string;
3839
items?: AppConfigChildItem[];
3940
}
4041

0 commit comments

Comments
 (0)