Skip to content
Merged
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
59 changes: 38 additions & 21 deletions scripts/verify/e2e/cases/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,33 +1965,50 @@ export const workspaceCases: E2ECase[] = [
}

// File selection: single-click a file row marks it selected
// (root exposes data-directory-browser-selected-file).
// (root exposes data-directory-browser-selected-file). After
// go-up the listing reloads asynchronously — the path field can
// settle before entries arrive, so wait for a file row before
// clicking, and retry once if the selection does not register
// (the listing may have been mid-refresh at click time).
if (entries.files && entries.files > 0) {
await ctx.evalJs(
panel,
`(() => {
const scope = document.querySelector(${scopeJson});
const row = scope?.querySelector('[data-directory-browser-entry][data-entry-kind="file"]');
if (row) row.click();
return Boolean(row);
})()`,
);
const selectedPath = await waitForDom(
ctx,
panel,
`(() => {
const fileRowSelector =
'[data-directory-browser-entry][data-entry-kind="file"]';
const selectedPathExpr = `(() => {
const scope = document.querySelector(${scopeJson});
const host = scope?.querySelector('[data-directory-browser-selected-file]');
const v = host?.getAttribute('data-directory-browser-selected-file');
const v = scope?.querySelector('[data-directory-browser-selected-file]')
?.getAttribute('data-directory-browser-selected-file');
return v ? v : null;
})()`,
20_000,
);
})()`;
let selectedPath: unknown = null;
let fileRowSeen = false;
for (let attempt = 0; attempt < 2 && !selectedPath; attempt++) {
fileRowSeen = await waitForDom(
ctx,
panel,
`Boolean(document.querySelector(${scopeJson})?.querySelector(${JSON.stringify(fileRowSelector)}))`,
30_000,
);
if (!fileRowSeen) break;
await ctx.evalJs(
panel,
`(() => {
const scope = document.querySelector(${scopeJson});
scope?.querySelector(${JSON.stringify(fileRowSelector)})?.click();
return true;
})()`,
);
selectedPath = await waitForDom(
ctx,
panel,
selectedPathExpr,
15_000,
);
}
checks.push(
check(
"file row selection registers selected path",
Boolean(selectedPath),
`selected=${JSON.stringify(selectedPath)}`,
Boolean(fileRowSeen && selectedPath),
`rowSeen=${String(fileRowSeen)} selected=${JSON.stringify(selectedPath)}`,
),
);
} else {
Expand Down
28 changes: 27 additions & 1 deletion scripts/verify/e2e/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,33 @@ export class E2EContext {
async snapshotManagedRoot(snapshotDir: string): Promise<void> {
await rm(snapshotDir, { recursive: true, force: true });
await mkdir(snapshotDir, { recursive: true });
await cp(this.managedRoot(), snapshotDir, { recursive: true });
// The product writes files via tmp+rename, so a `*.tmp-*` file can
// vanish between readdir and lstat mid-copy (ENOENT), and live
// writers can hold transient locks (EPERM/EACCES/EBUSY). The
// snapshot is a point-in-time copy, so retry the whole copy.
const transient = new Set([
"ENOENT",
"EPERM",
"EACCES",
"EBUSY",
"ENOTEMPTY",
]);
const maxAttempts = 4;
let lastError: unknown;
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
try {
await cp(this.managedRoot(), snapshotDir, { recursive: true });
return;
} catch (error) {
lastError = error;
const code = (error as NodeJS.ErrnoException)?.code;
if (!code || !transient.has(code) || attempt === maxAttempts) {
throw error;
}
await sleep(500 * attempt);
}
}
throw lastError;
}

/**
Expand Down
Loading