-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcategory-comparison.spec.ts
More file actions
104 lines (84 loc) · 2.36 KB
/
Copy pathcategory-comparison.spec.ts
File metadata and controls
104 lines (84 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import { test, expect } from '@playwright/test'
test('user can navigate to compare page', async ({ page }) => {
await page.goto('/')
const nav = page.getByRole('navigation')
await expect(nav).toBeVisible()
await nav
.getByRole('link', {
name: 'Compare',
exact: true
})
.click()
await expect(
page.getByRole('heading', {
name: 'Compare categories',
exact: true
})
).toBeVisible()
await expect(page).toHaveURL('/category-comparison')
})
test('user can select categories for comparison', async ({ page }) => {
await page.goto('/category-comparison')
await expect(
page.getByRole('heading', {
name: 'Compare categories',
exact: true
})
).toBeVisible()
const textbox = page.getByRole('textbox', { name: 'Category' })
for (const category of ['category of rings', 'category of commutative rings']) {
await expect(textbox).toHaveValue('')
await textbox.fill(category)
await textbox.focus()
await page.waitForTimeout(500)
await textbox.press('Enter')
await expect(textbox).toHaveValue('')
await expect(
page.getByRole('button', {
name: category,
exact: true
})
).toBeVisible()
}
await page
.getByRole('button', {
name: 'Compare',
exact: true
})
.click()
await expect(page).toHaveURL('/category-comparison/Ring/CRing')
await expect(
page.getByRole('heading', {
name: 'Comparison of categories',
exact: true
})
).toBeVisible()
})
test('user can view comparison table', async ({ page }) => {
await page.goto('/category-comparison/Ring/CRing')
await expect(
page.getByRole('heading', {
name: 'Comparison of categories',
exact: true
})
).toBeVisible()
const body = page.locator('body')
await expect(body).toContainText('category of rings')
await expect(body).toContainText('category of commutative rings')
const table = page.getByRole('table')
await expect(table).toBeVisible()
const table_excerpt = [
['abelian', 'no', 'no'],
['generator', 'yes', 'yes'],
['cocomplete', 'yes', 'yes'],
['coextensive', 'no', 'yes']
]
for (const [prop, value_1, value_2] of table_excerpt) {
const row = table.locator('tbody tr', {
has: page.getByRole('link', { name: prop, exact: true })
})
await expect(row).toBeVisible()
await expect(row.locator('td').nth(1)).toHaveAttribute('aria-label', value_1)
await expect(row.locator('td').nth(2)).toHaveAttribute('aria-label', value_2)
}
})