Fix flaky test for SettingsDialog. (#6294)
This commit is contained in:
parent
d46b91e09d
commit
2690123af0
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { render } from 'ink-testing-library';
|
import { render } from 'ink-testing-library';
|
||||||
|
import { waitFor } from '@testing-library/react';
|
||||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||||
import { SettingsDialog } from './SettingsDialog.js';
|
import { SettingsDialog } from './SettingsDialog.js';
|
||||||
import { LoadedSettings, SettingScope } from '../../config/settings.js';
|
import { LoadedSettings, SettingScope } from '../../config/settings.js';
|
||||||
|
@ -285,12 +286,15 @@ describe('SettingsDialog', () => {
|
||||||
|
|
||||||
// Switch to scope focus
|
// Switch to scope focus
|
||||||
stdin.write('\t'); // Tab key
|
stdin.write('\t'); // Tab key
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
expect(lastFrame()).toContain('> Apply To');
|
expect(lastFrame()).toContain('> Apply To');
|
||||||
|
});
|
||||||
|
|
||||||
// Select a scope
|
// Select a scope
|
||||||
stdin.write('1'); // Select first scope option
|
stdin.write('1'); // Select first scope option
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
|
expect(lastFrame()).toContain(' Apply To');
|
||||||
|
});
|
||||||
|
|
||||||
// Should be back to settings focus
|
// Should be back to settings focus
|
||||||
expect(lastFrame()).toContain(' Apply To');
|
expect(lastFrame()).toContain(' Apply To');
|
||||||
|
@ -351,9 +355,9 @@ describe('SettingsDialog', () => {
|
||||||
|
|
||||||
// Press Escape key
|
// Press Escape key
|
||||||
stdin.write('\u001B'); // ESC key
|
stdin.write('\u001B'); // ESC key
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
|
expect(onSelect).toHaveBeenCalledWith(undefined, SettingScope.User);
|
||||||
expect(onSelect).toHaveBeenCalledWith(undefined, SettingScope.User);
|
});
|
||||||
|
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
|
@ -549,9 +553,9 @@ describe('SettingsDialog', () => {
|
||||||
describe('Settings Display Values', () => {
|
describe('Settings Display Values', () => {
|
||||||
it('should show correct values for inherited settings', () => {
|
it('should show correct values for inherited settings', () => {
|
||||||
const settings = createMockSettings(
|
const settings = createMockSettings(
|
||||||
{}, // No user settings
|
{},
|
||||||
{ vimMode: true, hideWindowTitle: false }, // System settings
|
{ vimMode: true, hideWindowTitle: false }, // System settings
|
||||||
{}, // No workspace settings
|
{},
|
||||||
);
|
);
|
||||||
const onSelect = vi.fn();
|
const onSelect = vi.fn();
|
||||||
|
|
||||||
|
@ -568,7 +572,7 @@ describe('SettingsDialog', () => {
|
||||||
const settings = createMockSettings(
|
const settings = createMockSettings(
|
||||||
{ vimMode: false }, // User overrides
|
{ vimMode: false }, // User overrides
|
||||||
{ vimMode: true }, // System default
|
{ vimMode: true }, // System default
|
||||||
{}, // No workspace settings
|
{},
|
||||||
);
|
);
|
||||||
const onSelect = vi.fn();
|
const onSelect = vi.fn();
|
||||||
|
|
||||||
|
@ -664,13 +668,15 @@ describe('SettingsDialog', () => {
|
||||||
|
|
||||||
// Tab to scope section
|
// Tab to scope section
|
||||||
stdin.write('\t');
|
stdin.write('\t');
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
expect(lastFrame()).toContain('> Apply To');
|
expect(lastFrame()).toContain('> Apply To');
|
||||||
|
});
|
||||||
|
|
||||||
// Tab back to settings section
|
// Tab back to settings section
|
||||||
stdin.write('\t');
|
stdin.write('\t');
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
expect(lastFrame()).toContain(' Apply To');
|
expect(lastFrame()).toContain(' Apply To');
|
||||||
|
});
|
||||||
|
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
|
@ -746,9 +752,9 @@ describe('SettingsDialog', () => {
|
||||||
|
|
||||||
// Exit
|
// Exit
|
||||||
stdin.write('\u001B'); // Escape
|
stdin.write('\u001B'); // Escape
|
||||||
await wait();
|
await waitFor(() => {
|
||||||
|
expect(onSelect).toHaveBeenCalledWith(undefined, expect.any(String));
|
||||||
expect(onSelect).toHaveBeenCalledWith(undefined, expect.any(String));
|
});
|
||||||
|
|
||||||
unmount();
|
unmount();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue