Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions apps/desktop/e2e-tests/test/specs/popup-smoke.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {
closePopupsAndReturn,
expectDisplayedByTestId,
openPopupWindowFromMain,
} from '../support/windows.js';

async function waitForEitherDisplayed(testIds) {
await browser.waitUntil(
async () => {
for (const testId of testIds) {
const element = await $(`[data-testid='${testId}']`);
if (await element.isDisplayed().catch(() => false)) {
return true;
}
}
return false;
},
{
timeout: 30000,
timeoutMsg: `Expected one of these test ids to be displayed: ${testIds.join(', ')}`,
}
);
}

describe('TouchAI popup smoke', () => {
it('opens the model dropdown popup through the registered popup window', async () => {
const { mainWindowHandle } = await openPopupWindowFromMain(
'model-dropdown-popup',
'openModelDropdownPopup',
'model-dropdown-popup'
);

try {
await expectDisplayedByTestId('model-dropdown-popup');
await expectDisplayedByTestId('model-dropdown-search-input');
await waitForEitherDisplayed(['model-dropdown-option', 'model-dropdown-empty']);
} finally {
await closePopupsAndReturn(mainWindowHandle);
}
});

it('opens the session history popup through the registered popup window', async () => {
const { mainWindowHandle } = await openPopupWindowFromMain(
'session-history-popup',
'openSessionHistoryPopup',
'session-history-popup'
);

try {
await expectDisplayedByTestId('session-history-popup');
await expectDisplayedByTestId('session-history-search-input');
await waitForEitherDisplayed([
'session-history-item',
'session-history-empty',
'session-history-loading',
]);
} finally {
await closePopupsAndReturn(mainWindowHandle);
}
});
});
28 changes: 24 additions & 4 deletions apps/desktop/e2e-tests/test/specs/search-smoke.e2e.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
import { waitForE2eBridge } from '../support/windows.js';

describe('TouchAI search smoke', () => {
it('opens the quick-search panel after typing into the search editor', async () => {
it('opens and closes quick-search results after typing into the search editor', async () => {
const editor = await $("[data-testid='search-editor-host'] .ProseMirror");
const quickSearchPanel = await $("[data-testid='quick-search-panel']");

await editor.waitForDisplayed();
await browser.waitUntil(async () => {
return browser.execute(() => Boolean(window.__TOUCHAI_E2E__));
});
await waitForE2eBridge();
await browser.execute((text) => {
window.__TOUCHAI_E2E__.setSearchQuery(text);
}, 'touchai');

await quickSearchPanel.waitForDisplayed();
const resultItem = await $("[data-testid='quick-search-result-item']");
await resultItem.waitForDisplayed();

const resultName = await resultItem.getAttribute('data-result-name');
if (!resultName?.toLowerCase().includes('touchai')) {
throw new Error(
`Expected quick-search result to match "touchai", received "${resultName}"`
);
}

const editorText = await editor.getText();
if (!editorText.includes('touchai')) {
throw new Error(`Expected editor text to contain "touchai", received "${editorText}"`);
}

const viewToggle = await $("[data-testid='quick-search-view-toggle']");
await viewToggle.waitForDisplayed();
await viewToggle.click();
await $("[data-testid='quick-search-result-item']").waitForDisplayed();

await browser.execute(() => {
window.__TOUCHAI_E2E__.setSearchQuery('');
});
await quickSearchPanel.waitForDisplayed({ reverse: true });
});
});
93 changes: 31 additions & 62 deletions apps/desktop/e2e-tests/test/specs/settings-smoke.e2e.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,41 @@
import { expectDisplayedByTestId, withSettingsWindow } from '../support/windows.js';

describe('TouchAI settings smoke', () => {
it('opens the settings window and persists the start-minimized toggle', async () => {
const mainWindowHandle = await browser.getWindowHandle();
let settingsHandle = null;
it('opens settings, persists launch preferences, and navigates critical sections', async () => {
await withSettingsWindow(async () => {
const settingsView = await expectDisplayedByTestId('settings-view');
const generalSection = await expectDisplayedByTestId('settings-general-section');
const startMinimizedToggle = await $("[data-testid='settings-start-minimized-toggle']");

await browser.waitUntil(async () => {
return browser.execute(() => Boolean(window.__TOUCHAI_E2E__));
});
await settingsView.waitForDisplayed();
await generalSection.waitForDisplayed();

await browser
.executeAsync((done) => {
window.__TOUCHAI_E2E__
.openSettingsWindow()
.then(() => done({ ok: true }))
.catch((error) => done({ ok: false, error: String(error) }));
})
.then((result) => {
if (!result?.ok) {
throw new Error(
`Failed to open settings window: ${result?.error ?? 'unknown error'}`
);
}
const initialPressed = await startMinimizedToggle.getAttribute('aria-pressed');

await startMinimizedToggle.click();
await browser.waitUntil(async () => {
return (await startMinimizedToggle.getAttribute('aria-pressed')) !== initialPressed;
});

await browser.waitUntil(async () => {
const handles = await browser.getWindowHandles();
for (const handle of handles) {
if (handle === mainWindowHandle) {
continue;
}
await startMinimizedToggle.click();
await browser.waitUntil(async () => {
return (await startMinimizedToggle.getAttribute('aria-pressed')) === initialPressed;
});

await browser.switchToWindow(handle);
const currentUrl = await browser.getUrl();
if (currentUrl.includes('/settings')) {
settingsHandle = handle;
return true;
}
const sectionChecks = [
['ai-services', 'settings-ai-services-panel'],
['built-in-tools', 'settings-built-in-tools-panel'],
['mcp-tools', 'settings-mcp-tools-panel'],
['data-management', 'settings-data-history-list'],
['general', 'settings-general-section'],
];

for (const [section, expectedTestId] of sectionChecks) {
const navItem = await $(`[data-testid='settings-nav-${section}']`);
await navItem.waitForDisplayed();
await navItem.click();
await expectDisplayedByTestId(expectedTestId);
}

await browser.switchToWindow(mainWindowHandle);
return false;
});

if (!settingsHandle) {
throw new Error('Unable to locate settings window handle.');
}

await browser.switchToWindow(settingsHandle);

const settingsView = await $("[data-testid='settings-view']");
const generalSection = await $("[data-testid='settings-general-section']");
const startMinimizedToggle = await $("[data-testid='settings-start-minimized-toggle']");

await settingsView.waitForDisplayed();
await generalSection.waitForDisplayed();

const initialPressed = await startMinimizedToggle.getAttribute('aria-pressed');

await startMinimizedToggle.click();
await browser.waitUntil(async () => {
return (await startMinimizedToggle.getAttribute('aria-pressed')) !== initialPressed;
});

await startMinimizedToggle.click();
await browser.waitUntil(async () => {
return (await startMinimizedToggle.getAttribute('aria-pressed')) === initialPressed;
});

await browser.closeWindow();
await browser.switchToWindow(mainWindowHandle);
});
});
Loading
Loading