test/e2e/commits.spec.ts TYPESCRIPT 63 lines View on github.com → Search inside
1// @vitest-environment node2import { setupPuppeteer, getExampleUrl, E2E_TIMEOUT } from './e2eUtils'3import mocks from './commits.mock'45describe('e2e: commits', () => {6  const { page, click, count, text, isChecked } = setupPuppeteer()78  async function testCommits(apiType: 'classic' | 'composition') {9    // intercept and mock the response to avoid hitting the actual API10    await page().setRequestInterception(true)11    page().on('request', req => {12      const match = req.url().match(/&sha=(.*)$/)13      if (!match) {14        req.continue()15      } else {16        const ret = JSON.stringify(mocks[match[1] as 'main' | 'dev'])17        req.respond({18          status: 200,19          contentType: 'application/json',20          headers: { 'Access-Control-Allow-Origin': '*' },21          body: ret22        })23      }24    })2526    await page().goto(getExampleUrl('commits', apiType))27    await page().waitForSelector('li')2829    expect(await count('input')).toBe(2)30    expect(await count('label')).toBe(2)31    expect(await text('label[for="main"]')).toBe('main')32    expect(await text('label[for="dev"]')).toBe('dev')33    expect(await isChecked('#main')).toBe(true)34    expect(await isChecked('#dev')).toBe(false)35    expect(await text('p')).toBe('vuejs/vue@main')36    expect(await count('li')).toBe(3)37    expect(await count('li .commit')).toBe(3)38    expect(await count('li .message')).toBe(3)3940    await click('#dev')41    expect(await text('p')).toBe('vuejs/vue@dev')42    expect(await count('li')).toBe(3)43    expect(await count('li .commit')).toBe(3)44    expect(await count('li .message')).toBe(3)45  }4647  test(48    'classic',49    async () => {50      await testCommits('classic')51    },52    E2E_TIMEOUT53  )5455  test(56    'composition',57    async () => {58      await testCommits('composition')59    },60    E2E_TIMEOUT61  )62})

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.