Home / File/ grid.spec.ts — vue Source File

grid.spec.ts — vue Source File

Architecture documentation for grid.spec.ts, a typescript file in the vue codebase. 3 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  c430f7de_c708_06ad_19ba_93d55b0f2f72["grid.spec.ts"]
  74c9703b_0a18_7462_9820_16ae2926fb68["e2eUtils.ts"]
  c430f7de_c708_06ad_19ba_93d55b0f2f72 --> 74c9703b_0a18_7462_9820_16ae2926fb68
  a0544ceb_04fe_69ff_50e4_5f4b5588b908["setupPuppeteer"]
  c430f7de_c708_06ad_19ba_93d55b0f2f72 --> a0544ceb_04fe_69ff_50e4_5f4b5588b908
  86d0ef47_5ef3_4c63_5a71_03f519f9407a["getExampleUrl"]
  c430f7de_c708_06ad_19ba_93d55b0f2f72 --> 86d0ef47_5ef3_4c63_5a71_03f519f9407a
  style c430f7de_c708_06ad_19ba_93d55b0f2f72 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { setupPuppeteer, getExampleUrl, E2E_TIMEOUT } from './e2eUtils'

interface TableData {
  name: string
  power: number
}

describe('e2e: grid', () => {
  const { page, click, text, count, typeValue, clearValue } = setupPuppeteer()
  const columns = ['name', 'power'] as const

  async function assertTable(data: TableData[]) {
    expect(await count('td')).toBe(data.length * columns.length)
    for (let i = 0; i < data.length; i++) {
      for (let j = 0; j < columns.length; j++) {
        expect(
          await text(`tr:nth-child(${i + 1}) td:nth-child(${j + 1})`)
        ).toContain(`${data[i][columns[j]]}`)
      }
    }
  }

  async function testGrid(apiType: 'classic' | 'composition') {
    await page().goto(getExampleUrl('grid', apiType))
    await page().waitForSelector('table')
    expect(await count('th')).toBe(2)
    expect(await count('th.active')).toBe(0)
    expect(await text('th:nth-child(1)')).toContain('Name')
    expect(await text('th:nth-child(2)')).toContain('Power')
    await assertTable([
      { name: 'Chuck Norris', power: Infinity },
      { name: 'Bruce Lee', power: 9000 },
      { name: 'Jackie Chan', power: 7000 },
      { name: 'Jet Li', power: 8000 }
    ])

    await click('th:nth-child(1)')
    expect(await count('th.active:nth-child(1)')).toBe(1)
    expect(await count('th.active:nth-child(2)')).toBe(0)
    expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1)
    expect(await count('th:nth-child(2) .arrow.dsc')).toBe(0)
    await assertTable([
      { name: 'Jet Li', power: 8000 },
      { name: 'Jackie Chan', power: 7000 },
      { name: 'Chuck Norris', power: Infinity },
      { name: 'Bruce Lee', power: 9000 }
    ])

    await click('th:nth-child(2)')
    expect(await count('th.active:nth-child(1)')).toBe(0)
    expect(await count('th.active:nth-child(2)')).toBe(1)
    expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1)
    expect(await count('th:nth-child(2) .arrow.dsc')).toBe(1)
    await assertTable([
      { name: 'Chuck Norris', power: Infinity },
      { name: 'Bruce Lee', power: 9000 },
      { name: 'Jet Li', power: 8000 },
      { name: 'Jackie Chan', power: 7000 }
    ])

    await click('th:nth-child(2)')
    expect(await count('th.active:nth-child(1)')).toBe(0)
    expect(await count('th.active:nth-child(2)')).toBe(1)
    expect(await count('th:nth-child(1) .arrow.dsc')).toBe(1)
    expect(await count('th:nth-child(2) .arrow.asc')).toBe(1)
    await assertTable([
      { name: 'Jackie Chan', power: 7000 },
      { name: 'Jet Li', power: 8000 },
      { name: 'Bruce Lee', power: 9000 },
      { name: 'Chuck Norris', power: Infinity }
    ])

    await click('th:nth-child(1)')
    expect(await count('th.active:nth-child(1)')).toBe(1)
    expect(await count('th.active:nth-child(2)')).toBe(0)
    expect(await count('th:nth-child(1) .arrow.asc')).toBe(1)
    expect(await count('th:nth-child(2) .arrow.asc')).toBe(1)
    await assertTable([
      { name: 'Bruce Lee', power: 9000 },
      { name: 'Chuck Norris', power: Infinity },
      { name: 'Jackie Chan', power: 7000 },
      { name: 'Jet Li', power: 8000 }
    ])

    await typeValue('input[name="query"]', 'j')
    await assertTable([
      { name: 'Jackie Chan', power: 7000 },
      { name: 'Jet Li', power: 8000 }
    ])

    await typeValue('input[name="query"]', 'infinity')
    await assertTable([{ name: 'Chuck Norris', power: Infinity }])

    await clearValue('input[name="query"]')
    expect(await count('p')).toBe(0)
    await typeValue('input[name="query"]', 'stringthatdoesnotexistanywhere')
    expect(await count('p')).toBe(1)
  }

  test(
    'classic',
    async () => {
      await testGrid('classic')
    },
    E2E_TIMEOUT
  )

  test(
    'composition',
    async () => {
      await testGrid('composition')
    },
    E2E_TIMEOUT
  )
})

Domain

Types

Frequently Asked Questions

What does grid.spec.ts do?
grid.spec.ts is a source file in the vue codebase, written in typescript. It belongs to the CompilerSFC domain.
What does grid.spec.ts depend on?
grid.spec.ts imports 3 module(s): e2eUtils.ts, getExampleUrl, setupPuppeteer.
Where is grid.spec.ts in the architecture?
grid.spec.ts is located at test/e2e/grid.spec.ts (domain: CompilerSFC, directory: test/e2e).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free