Skip to content

Commit eb4d0a4

Browse files
committed
improve end-to-end tests
1 parent 0ee1187 commit eb4d0a4

17 files changed

Lines changed: 358 additions & 283 deletions

tests/categories.spec.ts

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@ test('user can view category details', async ({ page }) => {
103103
})
104104
).toBeVisible()
105105

106-
await expect(page.getByText('objects: commutative rings')).toBeVisible()
107-
await expect(page.getByText('morphisms: ring homomorphisms')).toBeVisible()
106+
const body = page.locator('body')
107+
108+
await expect(body).toContainText('Objects: commutative rings')
109+
await expect(body).toContainText('Morphisms: ring homomorphisms')
108110
await expect(page.getByRole('link', { name: 'nLab link' })).toBeVisible()
109-
await expect(page.getByText('is cocomplete')).toBeVisible()
110-
await expect(page.getByText('is locally finitely presentable')).toBeVisible()
111-
await expect(page.getByText('is not additive')).toBeVisible()
112-
await expect(page.getByText('is not balanced')).toBeVisible()
113-
await expect(page.getByText('terminal object: zero ring')).toBeVisible()
114-
await expect(page.getByText('coproducts: tensor products')).toBeVisible()
115-
await expect(
116-
page.getByText('regular epimorphisms: surjective morphisms')
117-
).toBeVisible()
111+
await expect(body).toContainText('is cocomplete')
112+
await expect(body).toContainText('is locally finitely presentable')
113+
await expect(body).toContainText('is not additive')
114+
await expect(body).toContainText('is not balanced')
115+
await expect(body).toContainText('terminal object: zero ring')
116+
await expect(body).toContainText('coproducts: tensor products')
117+
await expect(body).toContainText('regular epimorphisms: surjective morphisms')
118118
})
119119

120120
test('user sees no unknown properties for the category of sets', async ({ page }) => {
@@ -137,15 +137,13 @@ test('user may see unknown properties', async ({ page }) => {
137137
})
138138
).toBeVisible()
139139

140-
const unknown_properties_section = page
141-
.locator('section', {
142-
hasText: 'Unknown properties'
143-
})
144-
.first()
140+
const unknown_properties_section = page.locator('section', {
141+
hasText: 'Unknown properties'
142+
})
145143

146-
const unknown_property_link = unknown_properties_section.locator('li').first()
144+
const link = unknown_properties_section.locator('li').first()
147145

148-
await expect(unknown_property_link).toBeVisible()
146+
await expect(link).toBeVisible()
149147
})
150148

151149
test('user may see undecidable properties', async ({ page }) => {
@@ -158,11 +156,9 @@ test('user may see undecidable properties', async ({ page }) => {
158156
})
159157
).toBeVisible()
160158

161-
const undecidable_properties_section = page
162-
.locator('section', {
163-
hasText: 'Undecidable properties'
164-
})
165-
.first()
159+
const undecidable_properties_section = page.locator('section', {
160+
hasText: 'Undecidable properties'
161+
})
166162

167163
const link = undecidable_properties_section.getByRole('link', {
168164
name: 'accessible',
@@ -184,11 +180,9 @@ test('user may see properties that cannot be determined in a family of categorie
184180
})
185181
).toBeVisible()
186182

187-
const undecidable_properties_section = page
188-
.locator('section', {
189-
hasText: 'Undecidable properties'
190-
})
191-
.first()
183+
const undecidable_properties_section = page.locator('section', {
184+
hasText: 'Undecidable properties'
185+
})
192186

193187
const link = undecidable_properties_section.getByRole('link', {
194188
name: 'finite',
@@ -202,6 +196,7 @@ test('user can navigate to a related category', async ({ page }) => {
202196
await page.goto('/category/FinSet', { waitUntil: 'networkidle' })
203197

204198
await page
199+
.locator('li', { hasText: 'Related categories:' })
205200
.getByRole('link', {
206201
name: 'category of sets',
207202
exact: true
@@ -230,11 +225,8 @@ test('user can navigate to the dual category if it exists in the database', asyn
230225
})
231226
).toBeVisible()
232227

233-
const item = page.locator('li', {
234-
hasText: 'Dual category'
235-
})
236-
237-
await item
228+
await page
229+
.locator('li', { hasText: 'Dual category' })
238230
.getByRole('link', {
239231
name: 'dual of the category of sets',
240232
exact: true
@@ -255,6 +247,7 @@ test('user can navigate to a child category', async ({ page }) => {
255247
await page.goto('/category/BG', { waitUntil: 'networkidle' })
256248

257249
await page
250+
.locator('li', { hasText: 'Children:' })
258251
.getByRole('link', {
259252
name: 'delooping of a non-trivial finite group',
260253
exact: true
@@ -275,11 +268,11 @@ test('user can navigate to a parent category', async ({ page }) => {
275268
await page.goto('/category/Ring', { waitUntil: 'networkidle' })
276269

277270
await page
271+
.locator('li', { hasText: 'Parent:' })
278272
.getByRole('link', {
279273
name: 'category of algebras',
280274
exact: true
281275
})
282-
.first()
283276
.click()
284277

285278
await expect(
@@ -295,7 +288,7 @@ test('user can navigate to a parent category', async ({ page }) => {
295288
test('user can open and close a proof for a property of a category', async ({ page }) => {
296289
await page.goto('/category/Grp', { waitUntil: 'networkidle' })
297290

298-
const claim = page.locator('li', { has: page.getByText('is mono-regular') })
291+
const claim = page.locator('li', { hasText: 'is mono-regular' })
299292

300293
await expect(claim).toBeVisible()
301294

@@ -331,69 +324,67 @@ test('user can open a proof for a deduced satisfied property of category', async
331324
}) => {
332325
await page.goto('/category/Ring', { waitUntil: 'networkidle' })
333326

334-
const claim = page.locator('li', { has: page.getByText('has an extremal generator') })
327+
const claim = page.locator('li', { hasText: 'has an extremal generator' })
335328

336329
await expect(claim).toBeVisible()
337330

338331
await claim.locator('button').click()
339332

340333
const popup = page.locator('.popup').filter({ hasText: 'Proof' })
341334

342-
await expect(
343-
popup.getByText(
344-
'Since it is one-sorted finitary algebraic, it has an extremal generator'
345-
)
346-
).toBeVisible()
335+
await expect(popup).toContainText(
336+
'Since it is one-sorted finitary algebraic, it has an extremal generator'
337+
)
347338
})
348339

349340
test('user can open a proof for a deduced unsatisfied property of a category', async ({
350341
page
351342
}) => {
352343
await page.goto('/category/Ab', { waitUntil: 'networkidle' })
353344

354-
const claim = page.locator('li', { has: page.getByText('is not cartesian closed') })
345+
const claim = page.locator('li', { hasText: 'is not cartesian closed' })
355346

356347
await expect(claim).toBeVisible()
357348

358349
await claim.locator('button').click()
359350

360351
const popup = page.locator('.popup').filter({ hasText: 'Proof' })
361352

362-
await expect(
363-
popup.getByText('Assume for contradiction that it is cartesian closed.')
364-
).toBeVisible()
353+
await expect(popup).toContainText(
354+
'Assume for contradiction that it is cartesian closed.'
355+
)
365356
})
366357

367358
test('user can open a proof for an inherited satisfied property of a category', async ({
368359
page
369360
}) => {
370361
await page.goto('/category/Ab', { waitUntil: 'networkidle' })
371362

372-
const claim = page.locator('li', { has: page.getByText('is abelian') })
363+
const claim = page.locator('li', { hasText: 'is abelian' })
373364

374365
await expect(claim).toBeVisible()
375366

376367
await claim.locator('button').click()
377368

378369
const popup = page.locator('.popup').filter({ hasText: 'Proof' })
379370

380-
await expect(popup.getByText('This follows from the parent.')).toBeVisible()
371+
await expect(popup).toContainText('This follows from the parent.')
381372
})
382373

383374
test('user can open a proof for an inherited unsatisfied property of a category', async ({
384375
page
385376
}) => {
386377
await page.goto('/category/BG_f', { waitUntil: 'networkidle' })
387378

388-
const claim = page.locator('li', { has: page.getByText('is not thin') })
379+
const claim = page.locator('li', { hasText: 'is not thin' })
389380

390381
await expect(claim).toBeVisible()
391382

392383
await claim.locator('button').click()
393384

394385
const popup = page.locator('.popup').filter({ hasText: 'Proof' })
395386

396-
await expect(popup.getByText('This follows from the parent.')).toBeVisible()
387+
await expect(popup).toContainText('This follows from the parent.')
397388
})
398389

399390
test('user sees functors associated with the given category', async ({ page }) => {
@@ -414,7 +405,7 @@ test('user sees functors associated with the given category', async ({ page }) =
414405
).toBeVisible()
415406
})
416407

417-
test('user sees morphisms stored for the given category', async ({ page }) => {
408+
test('user sees morphisms associated with the given category', async ({ page }) => {
418409
await page.goto('/category/Grp', { waitUntil: 'networkidle' })
419410

420411
await expect(
@@ -431,3 +422,16 @@ test('user sees morphisms stored for the given category', async ({ page }) => {
431422
})
432423
).toBeVisible()
433424
})
425+
426+
test('user sees symmetric monoidal categories for the given category', async ({
427+
page
428+
}) => {
429+
await page.goto('/category/Top', { waitUntil: 'networkidle' })
430+
431+
await expect(
432+
page.getByRole('link', {
433+
name: 'cartesian symmetric monoidal category of topological spaces',
434+
exact: true
435+
})
436+
).toBeVisible()
437+
})

tests/category-comparison.spec.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,26 @@ test('user can view comparison table', async ({ page }) => {
7979
})
8080
).toBeVisible()
8181

82-
await expect(page.getByText('category of rings')).toBeVisible()
83-
await expect(page.getByText('category of commutative rings')).toBeVisible()
82+
const body = page.locator('body')
83+
await expect(body).toContainText('category of rings')
84+
await expect(body).toContainText('category of commutative rings')
8485

8586
const table = page.getByRole('table')
8687
await expect(table).toBeVisible()
8788

88-
const table_except = {
89-
abelian: ['no', 'no'],
90-
generator: ['yes', 'yes'],
91-
cocomplete: ['yes', 'yes'],
92-
coextensive: ['no', 'yes']
93-
}
89+
const table_excerpt = [
90+
['abelian', 'no', 'no'],
91+
['generator', 'yes', 'yes'],
92+
['cocomplete', 'yes', 'yes'],
93+
['coextensive', 'no', 'yes']
94+
]
9495

95-
for (const [prop, values] of Object.entries(table_except)) {
96-
const row = table
97-
.locator('tbody tr', {
98-
has: page.getByRole('link', { name: prop, exact: true })
99-
})
100-
.first()
96+
for (const [prop, value_1, value_2] of table_excerpt) {
97+
const row = table.locator('tbody tr', {
98+
has: page.getByRole('link', { name: prop, exact: true })
99+
})
101100
await expect(row).toBeVisible()
102-
await expect(row.locator('td').nth(1)).toHaveAttribute('aria-label', values[0])
103-
await expect(row.locator('td').nth(2)).toHaveAttribute('aria-label', values[1])
101+
await expect(row.locator('td').nth(1)).toHaveAttribute('aria-label', value_1)
102+
await expect(row.locator('td').nth(2)).toHaveAttribute('aria-label', value_2)
104103
}
105104
})

tests/category-implications.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ test('user can see the details of an implication', async ({ page }) => {
6262
})
6363
).toBeVisible()
6464

65-
await expect(page.getByText('Proof: This holds by definition')).toBeVisible()
65+
await expect(page.locator('body')).toContainText('Proof: This holds by definition')
6666
})
6767

6868
test('user can open the list of deduced implications', async ({ page }) => {

tests/category-properties.spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,18 @@ test('user can view category property details', async ({ page }) => {
4949
})
5050
).toBeVisible()
5151

52-
await expect(page.getByText('A category is finitely accessible if')).toBeVisible()
52+
await expect(page.locator('body')).toContainText(
53+
'A category is finitely accessible if'
54+
)
5355

54-
await expect(
55-
page.getByRole('link', {
56+
const related_link = page
57+
.locator('li', { hasText: 'Related properties:' })
58+
.getByRole('link', {
5659
name: 'accessible',
5760
exact: true
5861
})
59-
).toBeVisible()
62+
63+
await expect(related_link).toBeVisible()
6064

6165
const examples = page
6266
.getByRole('heading', {
@@ -111,11 +115,8 @@ test('user can navigate to the dual property', async ({ page }) => {
111115
})
112116
).toBeVisible()
113117

114-
const item = page.locator('li', {
115-
hasText: 'Dual property'
116-
})
117-
118-
await item
118+
await page
119+
.locator('li', { hasText: 'Dual property:' })
119120
.getByRole('link', {
120121
name: 'coequalizers',
121122
exact: true
@@ -136,11 +137,10 @@ test('user sees no unknown categories for the property of being additive', async
136137
page
137138
}) => {
138139
await page.goto('/category-property/additive')
139-
await expect(
140-
page.getByText(
141-
'There are 0 categories for which the database has no information on whether they satisfy this property'
142-
)
143-
).toBeVisible()
140+
141+
await expect(page.locator('body')).toContainText(
142+
'There are 0 categories for which the database has no information on whether they satisfy this property'
143+
)
144144
})
145145

146146
test("user can navigate to properties tagged with 'colimits' from the property list page", async ({

0 commit comments

Comments
 (0)