Skip to content

refactor: extract createSessionFromReportPage helper to pages/sessions#893

Open
empiricalrun[bot] wants to merge 4 commits intomainfrom
chat-session_IMJWmRX8Kwvw
Open

refactor: extract createSessionFromReportPage helper to pages/sessions#893
empiricalrun[bot] wants to merge 4 commits intomainfrom
chat-session_IMJWmRX8Kwvw

Conversation

@empiricalrun
Copy link
Copy Markdown
Contributor

@empiricalrun empiricalrun Bot commented May 3, 2026

Summary

Extracted a repeated 6-line block into a reusable helper method createSessionFromReportPage in tests/pages/sessions.ts.

What was duplicated

The exact same sequence appeared twice in tests/tool-execution/session.spec.ts:

  1. Click "New Session" button from a test run / report page
  2. Fill in the prompt placeholder
  3. Click "Create"
  4. Wait for and capture the new browser tab opened via the toast's "Open" button
  5. Assert the new tab is at a session URL

Change

tests/pages/sessions.ts — Added createSessionFromReportPage(page, prompt):

export async function createSessionFromReportPage(page: Page, prompt: string) {
  await page.getByRole('button', { name: 'New Session' }).click();
  await page.getByPlaceholder('Enter an initial prompt or drag and drop a file here').fill(prompt);
  await page.getByRole('button', { name: 'Create' }).click();
  const sessionPagePromise = page.context().waitForEvent('page');
  await page.getByRole('button', { name: 'Open', exact: true }).click();
  const sessionPage = await sessionPagePromise;
  await expect(sessionPage).toHaveURL(/\/sessions\/[^/?]+/);
  return sessionPage;
}

tests/tool-execution/session.spec.ts — Both duplicated blocks replaced with a single call to createSessionFromReportPage, imported from pages/sessions.

TypeScript compilation passes with no errors.

PR created from session #127726

Updated at 2026-05-03 04:54:07.710 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants