Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): add data-slot helper and file-drop test for chat thread

Steven Enamakel5edcd46e30c2
diff --git a/app/test/e2e/helpers/element-helpers.ts b/app/test/e2e/helpers/element-helpers.ts
index 916f7a6095..2e27bb2803 100644
--- a/app/test/e2e/helpers/element-helpers.ts
+++ b/app/test/e2e/helpers/element-helpers.ts
@@ -356,6 +356,10 @@ function testIdSelector(testId: string): string {
return `[data-testid="${testId}"]`;
}
+function dataSlotSelector(slot: string): string {
+ return `[data-slot="${slot}"]`;
+}
+
/**
* Wait for an element by stable `data-testid`.
*
@@ -381,6 +385,28 @@ export async function waitForTestId(
return el;
}
+/**
+ * Wait for an element by its stable assistant-ui data slot.
+ *
+ * Like test IDs, data slots are exposed by the DOM-backed tauri driver only.
+ */
+export async function waitForDataSlot(
+ slot: string,
+ timeout: number = 15_000
+): Promise<ChainablePromiseElement> {
+ if (!isTauriDriver()) {
+ throw new Error(`waitForDataSlot is only supported on tauri-driver: ${slot}`);
+ }
+
+ const selector = dataSlotSelector(slot);
+ const el = await browser.$(selector);
+ await el.waitForExist({
+ timeout,
+ timeoutMsg: `data-slot="${slot}" not found within ${timeout}ms`,
+ });
+ return el;
+}
+
/**
* Dispatch a browser file drag sequence against an element.
*
diff --git a/app/test/e2e/specs/file-drop-guard.spec.ts b/app/test/e2e/specs/file-drop-guard.spec.ts
index be9fdaa908..2f501a148c 100644
--- a/app/test/e2e/specs/file-drop-guard.spec.ts
+++ b/app/test/e2e/specs/file-drop-guard.spec.ts
@@ -1,8 +1,10 @@
import { expect } from '@wdio/globals';
import { waitForApp } from '../helpers/app-helpers';
-import { dispatchFileDrop, waitForTestId } from '../helpers/element-helpers';
+import { clickByTitle } from '../helpers/chat-harness';
+import { dispatchFileDrop, waitForDataSlot, waitForTestId } from '../helpers/element-helpers';
import { resetApp } from '../helpers/reset-app';
+import { navigateViaHash } from '../helpers/shared-flows';
import { startMockServer, stopMockServer } from '../mock-server';
const USER_ID = 'e2e-file-drop-guard';
@@ -28,4 +30,18 @@ describe('File drop guard', () => {
expect(result).toEqual({ dragOverPrevented: true, dropPrevented: true, fileCount: 1 });
});
+
+ it('claims a real file drop over the open chat thread', async () => {
+ await navigateViaHash('/chat');
+ expect(await clickByTitle('New thread', 8_000)).toBe(true);
+
+ const thread = await waitForDataSlot('aui_thread-viewport');
+ const result = await dispatchFileDrop(thread, {
+ name: 'thread-drop.txt',
+ type: 'text/plain',
+ contents: 'dropped onto the transcript',
+ });
+
+ expect(result).toEqual({ dragOverPrevented: true, dropPrevented: true, fileCount: 1 });
+ });
});