feat(KB-132): auto-open Settings to Authentication tab when unauthenticated
- Add initialSection prop to SettingsModal to allow opening to a specific tab - Export SectionId type from SettingsModal for use by parent components - Check auth status on App mount and auto-open Settings to Authentication tab when all providers are unauthenticated - Reset initialSection on modal close so subsequent manual opens default to General - Add comprehensive tests for auto-open behavior and initialSection prop
This commit is contained in:
@@ -502,4 +502,25 @@ describe("SettingsModal", () => {
|
||||
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("opens to Authentication section when initialSection='authentication' is passed", async () => {
|
||||
render(<SettingsModal onClose={onClose} addToast={addToast} initialSection="authentication" />);
|
||||
await waitFor(() => expect(fetchSettings).toHaveBeenCalled());
|
||||
await waitFor(() => expect(fetchAuthStatus).toHaveBeenCalled());
|
||||
|
||||
// Authentication content should be visible immediately
|
||||
expect(screen.getByText("Anthropic")).toBeTruthy();
|
||||
// General content should NOT be visible
|
||||
expect(screen.queryByLabelText("Task Prefix")).toBeNull();
|
||||
});
|
||||
|
||||
it("defaults to General section when no initialSection is passed", async () => {
|
||||
render(<SettingsModal onClose={onClose} addToast={addToast} />);
|
||||
await waitFor(() => expect(fetchSettings).toHaveBeenCalled());
|
||||
|
||||
// General content should be visible
|
||||
expect(screen.getByLabelText("Task Prefix")).toBeTruthy();
|
||||
// Authentication content should NOT be visible
|
||||
expect(screen.queryByText("✗ Not authenticated")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user