-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathcmd-pkts.p.spec.ts
More file actions
143 lines (135 loc) · 4.72 KB
/
cmd-pkts.p.spec.ts
File metadata and controls
143 lines (135 loc) · 4.72 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
# Copyright 2022 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# Modified by OpenC3, Inc.
# All changes Copyright 2025, OpenC3, Inc.
# All Rights Reserved
*/
// @ts-check
import { test, expect } from './../fixture'
test.use({
toolPath: '/tools/cmdtlmserver/cmd-packets',
toolName: 'CmdTlmServer',
})
test('displays the list of command', async ({ page, utils }) => {
// When we ask for just text there are no spaces
await expect(
page.locator('[data-test=cmd-packets-table]').locator('text=INSTABORT'),
).toBeVisible()
await expect(
page.locator('[data-test=cmd-packets-table]').locator('text=INSTCLEAR'),
).toBeVisible()
await expect(
page.locator('[data-test=cmd-packets-table]').locator('text=INSTCOLLECT'),
).toBeVisible()
await expect(
page.locator('[data-test=cmd-packets-table]').locator('text=EXAMPLESTART'),
).toBeVisible()
})
test('displays the command count', async ({ page, utils }) => {
await expect
.poll(() =>
page.locator('[data-test=cmd-packets-table] >> tbody > tr').count(),
)
.toBeGreaterThan(3)
await utils.sleep(1500) // Allow API to fetch counts
await page
.locator(
'div.v-card-title:has-text("Command Packets") >> input[type="text"]',
)
.fill('abort')
await expect
.poll(() =>
page.locator('[data-test=cmd-packets-table] >> tbody > tr').count(),
)
.toEqual(2)
const countStr = await page
.locator('[data-test=cmd-packets-table] >> tr td >> nth=2')
.textContent()
if (countStr === null) {
throw new Error('Unable to get packet count')
}
const count = parseInt(countStr)
// Send an ABORT command
await page.goto('/tools/cmdsender/INST/ABORT', {
waitUntil: 'domcontentloaded',
})
await expect(page.locator('.v-app-bar')).toContainText('Command Sender')
await page.locator('[data-test=select-send]').click()
await expect(page.locator('main')).toContainText('cmd("INST ABORT") sent')
await page.goto('/tools/cmdtlmserver/cmd-packets', {
waitUntil: 'domcontentloaded',
})
await expect(page.locator('.v-app-bar')).toContainText('CmdTlmServer')
await expect
.poll(() =>
page.locator('[data-test=cmd-packets-table] >> tbody > tr').count(),
)
.toBeGreaterThan(3)
await utils.sleep(1500) // Allow API to fetch counts
await page
.locator(
'div.v-card-title:has-text("Command Packets") >> input[type="text"]',
)
.fill('abort')
await expect
.poll(() =>
page.locator('[data-test=cmd-packets-table] >> tbody > tr').count(),
)
.toEqual(2)
await expect
.poll(
async () =>
await page
.locator('[data-test=cmd-packets-table] >> tr td >> nth=2')
.textContent(),
)
.toEqual(`${count + 1}`)
})
test('displays a raw command', async ({ page, utils }) => {
await expect(page.locator('text=INSTABORT')).toBeVisible()
await page
.getByRole('row', { name: 'INST ABORT' })
.getByRole('button', { name: 'View Raw' })
.click()
await expect(page.locator('.raw-dialog')).toContainText(
'Raw Command Packet: INST ABORT',
)
await expect(page.locator('.raw-dialog')).toContainText('Received Time:')
await expect(page.locator('.raw-dialog')).toContainText('Count:')
expect(await page.inputValue('.raw-dialog textarea')).toMatch('Address')
expect(await page.inputValue('.raw-dialog textarea')).toMatch('00000000:')
await utils.download(page, '[data-test=download]', function (contents) {
expect(contents).toMatch('Raw Command Packet: INST ABORT')
expect(contents).toMatch('Received Time:')
expect(contents).toMatch('Count:')
expect(contents).toMatch('Address')
expect(contents).toMatch('00000000:')
})
await page.locator('[data-test=close]').click()
await expect(page.locator('.raw-dialog')).not.toBeVisible()
})
test('links to command sender', async ({ page, utils }) => {
await expect(page.locator('text=INSTCOLLECT')).toBeVisible()
const [newPage] = await Promise.all([
page.context().waitForEvent('page'),
await page.locator('text=INSTCOLLECT >> td >> nth=4').click(),
])
await expect(newPage.locator('.v-app-bar')).toContainText('Command Sender', {
timeout: 30000,
})
await expect(newPage.locator('id=openc3-tool')).toContainText(
'Starts a collect on the INST target',
)
})