mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-09 16:59:43 +02:00
fix: COD-153 preserve matched case selection
This commit is contained in:
committed by
Aamer Akhter
parent
03192d9980
commit
e8f5ac94f3
@@ -475,6 +475,16 @@ Object.assign(CodemanApp.prototype, {
|
|||||||
if (item.type === 'new-session') {
|
if (item.type === 'new-session') {
|
||||||
const caseSelect = document.getElementById('quickStartCase');
|
const caseSelect = document.getElementById('quickStartCase');
|
||||||
if (caseSelect && item.caseName) {
|
if (caseSelect && item.caseName) {
|
||||||
|
if (
|
||||||
|
caseSelect.tagName === 'SELECT' &&
|
||||||
|
typeof caseSelect.appendChild === 'function' &&
|
||||||
|
!Array.from(caseSelect.options || []).some((option) => option.value === item.caseName)
|
||||||
|
) {
|
||||||
|
const option = document.createElement('option');
|
||||||
|
option.value = item.caseName;
|
||||||
|
option.textContent = item.caseName;
|
||||||
|
caseSelect.appendChild(option);
|
||||||
|
}
|
||||||
caseSelect.value = item.caseName;
|
caseSelect.value = item.caseName;
|
||||||
}
|
}
|
||||||
await this.run();
|
await this.run();
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ function loadPaletteHarness(overrides: Record<string, any> = {}) {
|
|||||||
CodemanApp,
|
CodemanApp,
|
||||||
document: {
|
document: {
|
||||||
getElementById: (id: string) => elements[id] ?? null,
|
getElementById: (id: string) => elements[id] ?? null,
|
||||||
|
createElement: (tagName: string) => ({
|
||||||
|
tagName: tagName.toUpperCase(),
|
||||||
|
value: '',
|
||||||
|
textContent: '',
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
console,
|
console,
|
||||||
escapeHtml: (value: string) =>
|
escapeHtml: (value: string) =>
|
||||||
@@ -200,6 +205,33 @@ describe('Command-K session palette', () => {
|
|||||||
expect(app.run).toHaveBeenCalledTimes(1);
|
expect(app.run).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('adds the matched case option before selecting it for a new session', async () => {
|
||||||
|
const { app, elements } = loadPaletteHarness();
|
||||||
|
const options = [{ value: 'plex-previews' }];
|
||||||
|
elements.quickStartCase = {
|
||||||
|
tagName: 'SELECT',
|
||||||
|
options,
|
||||||
|
appendChild: vi.fn((option: any) => options.push(option)),
|
||||||
|
get value() {
|
||||||
|
return this._value || '';
|
||||||
|
},
|
||||||
|
set value(next: string) {
|
||||||
|
this._value = options.some((option) => option.value === next) ? next : '';
|
||||||
|
},
|
||||||
|
};
|
||||||
|
elements.quickStartCase.value = 'plex-previews';
|
||||||
|
|
||||||
|
const newSession = app.buildCommandPaletteItems('flux').find((item: any) => item.type === 'new-session');
|
||||||
|
app.commandPaletteItems = [newSession];
|
||||||
|
app.commandPaletteActiveIndex = 0;
|
||||||
|
|
||||||
|
await app.activateCommandPaletteItem();
|
||||||
|
|
||||||
|
expect(elements.quickStartCase.appendChild).toHaveBeenCalledTimes(1);
|
||||||
|
expect(elements.quickStartCase.value).toBe('flux-player');
|
||||||
|
expect(app.run).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
it('activates the highlighted session result', async () => {
|
it('activates the highlighted session result', async () => {
|
||||||
const { app } = loadPaletteHarness();
|
const { app } = loadPaletteHarness();
|
||||||
app.openCommandPalette();
|
app.openCommandPalette();
|
||||||
|
|||||||
Reference in New Issue
Block a user