Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

test: find turn-level source footer

Louis Beaumont3fb7a45aa217
diff --git a/apps/screenpipe-app-tauri/e2e/specs/chat-source-file-preview.spec.ts b/apps/screenpipe-app-tauri/e2e/specs/chat-source-file-preview.spec.ts
index d06936630..eeb4b462d 100644
--- a/apps/screenpipe-app-tauri/e2e/specs/chat-source-file-preview.spec.ts
+++ b/apps/screenpipe-app-tauri/e2e/specs/chat-source-file-preview.spec.ts
@@ -141,14 +141,19 @@ async function expandSeededSourcesFooter(): Promise<void> {
).find((el) =>
(el.textContent ?? "").includes("Here is what I found in the skill file"),
);
- const searchRoot: ParentNode = assistantMessage ?? document;
- const button = Array.from(searchRoot.querySelectorAll("button")).find((el) => {
+ const sourceButtons = Array.from(document.querySelectorAll("button")).filter((el) => {
const text = el.textContent ?? "";
- return (
- el.getAttribute("aria-expanded") !== null &&
- /\bsources?\b/i.test(text)
- );
+ return el.getAttribute("aria-expanded") !== null && /\bsources?\b/i.test(text);
});
+ const button = assistantMessage
+ ? sourceButtons.find((el) => assistantMessage.contains(el)) ??
+ sourceButtons.find((el) =>
+ Boolean(
+ assistantMessage.compareDocumentPosition(el) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ),
+ )
+ : sourceButtons[0];
if (!button) return false;
if (button.getAttribute("aria-expanded") === "false") {
(button as HTMLButtonElement).click();