Skip to content

Commit 341532b

Browse files
authored
ui tests (#93)
1 parent 6dc4ca4 commit 341532b

5 files changed

Lines changed: 29 additions & 17 deletions

File tree

‎ui/tests/pages/Applications.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ it('allows deleting only a project with no applications', async () => {
7676
await flushPromises()
7777
const [shop, empty] = wrapper.findAllComponents(ProjectCard)
7878

79-
expect(deleteButton(shop).attributes('disabled')).toBeDefined()
80-
expect(deleteButton(empty).attributes('disabled')).toBeUndefined()
79+
expect(deleteButton(shop!).attributes('disabled')).toBeDefined()
80+
expect(deleteButton(empty!).attributes('disabled')).toBeUndefined()
8181
})
8282

8383
it("shows a project's New Application, Edit and Delete as icons, in that order", async () => {

‎ui/tests/pages/Domains.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,13 @@ describe('the Domains page', () => {
241241
await flushPromises()
242242

243243
const [pooled, plain] = wrapper.findAll('[data-domain]')
244-
expect(pooled!.getComponent('[data-application]').props('to')).toBe('/applications/demo/web')
244+
expect(pooled!.getComponent<typeof RouterLinkStub>('[data-application]').props('to')).toBe(
245+
'/applications/demo/web'
246+
)
245247
expect(pooled!.get('[data-application]').text()).toBe('Demo / Web')
246-
expect(pooled!.getComponent('[data-worker]').props('to')).toBe('/workers/w1')
248+
expect(pooled!.getComponent<typeof RouterLinkStub>('[data-worker]').props('to')).toBe(
249+
'/workers/w1'
250+
)
247251
expect(pooled!.get('[data-pool]').text()).toBe('eu')
248252
expect(plain!.find('[data-pool]').exists()).toBe(false)
249253
})
@@ -256,7 +260,9 @@ describe('the Domains page', () => {
256260
await flushPromises()
257261

258262
expect(wrapper.find('[data-application]').exists()).toBe(false)
259-
expect(wrapper.getComponent('[data-worker]').props('to')).toBe('/workers/w2')
263+
expect(wrapper.getComponent<typeof RouterLinkStub>('[data-worker]').props('to')).toBe(
264+
'/workers/w2'
265+
)
260266
})
261267

262268
it('opens an HTTP address and shows a TCP one as text', async () => {

‎ui/tests/pages/Home.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const summary: HomeSummary = {
3333
stopping: 0,
3434
backup: 0,
3535
restoring: 0,
36+
recovering: 0,
3637
},
3738
domains: { total: 4, synced: 1, pending: 1, syncing: 1, error: 1 },
3839
deploys: { succeeded: 4, failed: 2 },

‎ui/tests/pages/TaskTable.test.ts‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ describe('the task table', () => {
6262
})
6363

6464
it("shows a finished task's status as an icon left of its id", () => {
65-
const task = table(finished, 'finished').findAll('td')[0].get('div')
65+
const task = table(finished, 'finished').get('td').get('div')
6666
const [icon, id] = task.element.children
67-
expect(icon.getAttribute('role')).toBe('img')
68-
expect(icon.getAttribute('aria-label')).toBe('completed')
69-
expect(id.tagName.toLowerCase()).toBe('task-logs-button-stub')
67+
expect(icon!.getAttribute('role')).toBe('img')
68+
expect(icon!.getAttribute('aria-label')).toBe('completed')
69+
expect(id!.tagName.toLowerCase()).toBe('task-logs-button-stub')
7070
expect(task.text()).toBe('')
7171
})
7272

@@ -90,17 +90,15 @@ describe('the task table', () => {
9090
...finished,
9191
finished_at: new Date(Date.parse(`${at(1)}Z`) + seconds * 1000).toISOString(),
9292
}
93-
expect(taskTimes(ran, 'finished').at(-1)).toEqual({
94-
label: 'Ran',
95-
value: shown,
96-
duration: true,
97-
})
93+
expect(taskTimes(ran, 'finished').slice(-1)).toEqual([
94+
{ label: 'Ran', value: shown, duration: true },
95+
])
9896
})
9997

10098
it('gives a running task how long it waited, and no run time', () => {
10199
const times = taskTimes({ ...queued, started_at: at(3) }, 'running')
102100
expect(times.map(time => time.label)).toEqual(['Queued', 'Started', 'Waited'])
103-
expect(times.at(-1)!.value).toBe('3:00 mins')
101+
expect(times[2]!.value).toBe('3:00 mins')
104102
})
105103

106104
it("shows a running task's two dates in its row, without its wait", () => {
@@ -119,7 +117,7 @@ describe('the task table', () => {
119117
const wrapper = table(queued, 'queued')
120118
expect(pairs(queued, 'queued', 'times')).toEqual([['Queued', formatDate(at(0))]])
121119
expect(wrapper.find('[data-durations]').exists()).toBe(false)
122-
expect(wrapper.findAll('td')[0].text()).toBe('')
120+
expect(wrapper.get('td').text()).toBe('')
123121
})
124122

125123
it('shows each label with its value beside it', () => {

‎ui/tests/stores/app.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ function onWorkers() {
4545
}
4646

4747
function settings(state: SettingState = 'ok'): SettingsStatus {
48-
const section = { state, message: null, task_id: null, checked_at: null, details: null }
48+
const section = {
49+
state,
50+
message: null,
51+
task_id: null,
52+
checked_at: null,
53+
details: null,
54+
testing: false,
55+
}
4956
return {
5057
tailscale: { ...section, channels: null },
5158
cloudflare: { ...section, channels: null },

0 commit comments

Comments
 (0)