-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Expand file tree
/
Copy pathhost-split-view.spec.js
More file actions
69 lines (57 loc) · 3.01 KB
/
Copy pathhost-split-view.spec.js
File metadata and controls
69 lines (57 loc) · 3.01 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
import { test, expect } from './coverage-fixtures.js'
// Host is an inventory, not a catalog, so its split view differs from the two
// galleries in exactly one place: the pane with nothing selected reports what
// is happening rather than offering something to install.
const PANE = '[data-testid="host-pane"]'
const railItems = (page) => page.locator('[data-testid="host-rail-item"]')
const railItem = (page, id) => page.locator(`[data-entity="${id}"]`)
test.describe('Host - split view', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/app/manage')
await expect(railItems(page).first()).toBeVisible({ timeout: 10_000 })
})
test('the inventory renders no table', async ({ page }) => {
await expect(page.locator('[data-testid="host"]')).toBeVisible()
await expect(page.locator('table thead th')).toHaveCount(0)
})
test('with nothing selected the pane reports the current state', async ({ page }) => {
await expect(page.locator(PANE)).toContainText('Right now')
await expect(page.locator(PANE)).toContainText('Loaded')
await expect(page.locator('[data-testid="host-back"]')).toHaveCount(0)
})
test('choosing a model turns the pane into its detail, and back returns', async ({ page }) => {
const first = railItems(page).first()
const name = await first.getAttribute('data-entity')
await first.click()
await expect(page.locator(PANE)).toContainText(name)
await expect(page.locator(PANE)).toContainText('State')
await expect(page.locator(PANE)).not.toContainText('Right now')
await page.locator('[data-testid="host-back"]').click()
await expect(page.locator(PANE)).toContainText('Right now')
})
test('the selection lives in the URL', async ({ page }) => {
const first = railItems(page).first()
const name = await first.getAttribute('data-entity')
await first.click()
await expect(page).toHaveURL(new RegExp(`[?&]sel=${encodeURIComponent(name)}`))
})
test('the rail buckets by state rather than by capability', async ({ page }) => {
// The opposite of the galleries, and deliberately so: nobody opens Host
// wondering which of their models does vision.
const groups = page.locator('[data-testid^="host-rail-group-"]')
await expect(groups.first()).toBeVisible()
const ids = await groups.evaluateAll(els => els.map(e => e.dataset.testid))
for (const id of ids) {
expect(['host-rail-group-running', 'host-rail-group-idle', 'host-rail-group-disabled']).toContain(id)
}
})
test('switching tabs drops a selection that belonged to the other tab', async ({ page }) => {
await railItems(page).first().click()
await expect(page.locator('[data-testid="host-back"]')).toBeVisible()
// The other tab may legitimately be empty on a fresh host, so the contract
// is that the stale selection is gone, not that a pane appears.
await page.locator('.tab', { hasText: 'Backends' }).click()
await expect(page.locator('[data-testid="host-back"]')).toHaveCount(0)
await expect(page).not.toHaveURL(/[?&]sel=/)
})
})