e2e/util.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 18
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 13
mnd 1
bc 1
fnc 1
dl 0
loc 18
bpm 1
cpm 2
noi 0
c 0
b 0
f 0
rs 10
1
// @ts-check
2
3
/**
4
 * @typedef {import('@playwright/test').Locator} Locator
5
 * @typedef {import('@playwright/test').Expect} Expect
6
 */
7
8
/**
9
 * @param {Expect} expect
10
 * @param {Locator}  locator
11
 * @param {string[]} header
12
 * @param {any[]} rows
13
 */
14
export async function expectTableContent(expect, locator, header, rows) {
15
  await expect(locator).toBeVisible();
16
17
  expect(await locator.locator('> thead > tr > th').allInnerTexts()).toEqual(
18
    header
19
  );
20
  expect(await locator.locator('> tbody > tr').count()).toBe(rows.length);
21
22
  for (let i = 0; i < rows.length; i++) {
23
    expect(
24
      await locator
25
        .locator('> tbody > tr')
26
        .nth(i)
27
        .locator('> td')
28
        .allInnerTexts()
29
    ).toEqual(rows[i]);
30
  }
31
}
32