Skip to content

Commit ad2970f

Browse files
committed
Colorize state and fix playwright
1 parent 8512227 commit ad2970f

File tree

7 files changed

+167
-79
lines changed

7 files changed

+167
-79
lines changed

openc3-cosmos-init/plugins/packages/openc3-vue-common/src/tools/scriptrunner/ScriptRunner.vue

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# GNU Affero General Public License for more details.
1414
1515
# Modified by OpenC3, Inc.
16-
# All changes Copyright 2024, OpenC3, Inc.
16+
# All changes Copyright 2025, OpenC3, Inc.
1717
# All Rights Reserved
1818
#
1919
# This file may also be used under the terms of a commercial license
@@ -185,7 +185,7 @@
185185
v-model="stateTimer"
186186
label="Script State"
187187
data-test="state"
188-
class="shrink ml-2 script-state"
188+
:class="['shrink', 'ml-2', 'script-state', stateColorClass]"
189189
style="max-width: 120px"
190190
density="compact"
191191
variant="outlined"
@@ -842,8 +842,30 @@ export default {
842842
if (this.state === 'waiting' || this.state === 'paused') {
843843
return `${this.state} ${this.waitingTime}s`
844844
}
845+
// Map completed_errors to completed for display
846+
// it will be colored via the stateColorClass
847+
if (this.state === 'completed_errors') {
848+
return 'completed'
849+
}
845850
return this.state
846851
},
852+
stateColorClass: function () {
853+
// All possible states: spawning, init, running, paused, waiting, breakpoint,
854+
// error, crashed, stopped, completed, completed_errors, killed
855+
if (
856+
this.state === 'error' ||
857+
this.state === 'crashed' ||
858+
this.state === 'killed'
859+
) {
860+
return 'script-state-red'
861+
} else if (this.state === 'completed_errors') {
862+
return 'script-state-orange'
863+
} else if (this.state === 'completed') {
864+
return 'script-state-green'
865+
} else {
866+
return ''
867+
}
868+
},
847869
// This is the list of files shown in the select dropdown
848870
fileList: function () {
849871
// this.files is the list of all files seen while running
@@ -1755,10 +1777,6 @@ export default {
17551777
this.subscription = null
17561778
}
17571779
this.receivedEvents.length = 0 // Clear any unprocessed events
1758-
if (this.state === 'completed_errors') {
1759-
// Displaying 'Completed_errors' is not very user friendly
1760-
this.state = 'completed'
1761-
}
17621780
17631781
await this.reloadFile() // Make sure the right file is shown
17641782
// We may have changed the contents (if there were sub-scripts)
@@ -2950,6 +2968,20 @@ hr {
29502968
.script-state :deep(input) {
29512969
text-transform: capitalize;
29522970
}
2971+
2972+
/* Taken from the various status-symbol-color-fill classes
2973+
on https://www.astrouxds.com/design-tokens/component/ */
2974+
.script-state-red :deep(input) {
2975+
color: #ff3838 !important;
2976+
}
2977+
2978+
.script-state-orange :deep(input) {
2979+
color: #ffb302 !important;
2980+
}
2981+
2982+
.script-state-green :deep(input) {
2983+
color: #56f000 !important;
2984+
}
29532985
</style>
29542986
<style>
29552987
.splitpanes--horizontal > .splitpanes__splitter {

playwright/tests/admin/settings.p.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,12 @@ test('changes scripting settings', async ({ page, utils }) => {
200200
await expect(editorContent).toContain('# Test vim mode')
201201

202202
await page.locator('[data-test=start-button]').click()
203-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
204-
timeout: 20000,
205-
})
203+
await expect(page.locator('[data-test=state] input')).toHaveValue(
204+
'completed',
205+
{
206+
timeout: 20000,
207+
},
208+
)
206209
let filename = await page.locator('[data-test=filename] input').inputValue()
207210
await expect(filename).toContain('.rb') // Should be Ruby
208211

@@ -245,9 +248,8 @@ test('changes scripting settings', async ({ page, utils }) => {
245248
await expect(editorContent).toContain('# Test normal mode')
246249

247250
await page.locator('[data-test=start-button]').click()
248-
// TODO: This is weird that it could be either stopped or completed
249251
await expect(page.locator('[data-test=state] input')).toHaveValue(
250-
/stopped|completed/,
252+
'completed',
251253
{
252254
timeout: 20000,
253255
},

playwright/tests/command-sender.p.spec.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,12 @@ test('disable parameter conversions', async ({ page, utils }) => {
625625
timeout: 5000,
626626
},
627627
)
628-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
629-
timeout: 20000,
630-
})
628+
await expect(page.locator('[data-test=state] input')).toHaveValue(
629+
'completed',
630+
{
631+
timeout: 20000,
632+
},
633+
)
631634
await expect(page.locator('[data-test=output-messages]')).toContainText(
632635
'00000010: 02 00',
633636
)
@@ -668,9 +671,12 @@ test('disable parameter conversions', async ({ page, utils }) => {
668671
timeout: 5000,
669672
},
670673
)
671-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
672-
timeout: 20000,
673-
})
674+
await expect(page.locator('[data-test=state] input')).toHaveValue(
675+
'completed',
676+
{
677+
timeout: 20000,
678+
},
679+
)
674680
await expect(page.locator('[data-test=output-messages]')).toContainText(
675681
'00000010: 01 00',
676682
)
@@ -679,10 +685,10 @@ test('disable parameter conversions', async ({ page, utils }) => {
679685
test('disables command validation', async ({ page, utils }) => {
680686
await page.locator('[data-test="clear-history"]').click()
681687
await utils.selectTargetPacketItem('INST', 'TIME_OFFSET')
682-
688+
683689
await page.locator('[data-test=command-sender-mode]').click()
684690
await page.getByText('Disable Command Validation').click()
685-
691+
686692
await page.locator('[data-test="select-send"]').click()
687693
await expect(page.locator('main')).toContainText(
688694
'cmd("INST TIME_OFFSET with SECONDS 0, IP_ADDRESS \'127.0.0.1\'") sent',

playwright/tests/script-runner/api.s.spec.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ async function runScript(page, utils, filename, callback = async () => {}) {
5959
await openFile(page, utils, filename)
6060
await page.locator('[data-test=start-button]').click()
6161
await callback()
62-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
63-
timeout: 60000,
64-
})
62+
await expect(page.locator('[data-test=state] input')).toHaveValue(
63+
'completed',
64+
{
65+
timeout: 60000,
66+
},
67+
)
6568
}
6669

6770
test('opens a target file', async ({ page, utils }) => {
@@ -116,7 +119,7 @@ delete_target_file("INST/screens/web.txt") # Cleanup modified`)
116119
await expect(page.locator('[data-test=output-messages]')).toContainText(
117120
'Original web',
118121
)
119-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped')
122+
await expect(page.locator('[data-test=state] input')).toHaveValue('completed')
120123
})
121124

122125
test('runs a script', async ({ page, utils }) => {
@@ -130,9 +133,12 @@ test('runs a script', async ({ page, utils }) => {
130133
timeout: 5000,
131134
},
132135
)
133-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
134-
timeout: 20000,
135-
})
136+
await expect(page.locator('[data-test=state] input')).toHaveValue(
137+
'completed',
138+
{
139+
timeout: 20000,
140+
},
141+
)
136142

137143
await page.locator('[data-test="script-runner-script"]').click()
138144
await page.getByText('Execution Status').click()
@@ -226,9 +232,12 @@ async function testMetadataApis(page, utils, filename) {
226232
await page.getByRole('button', { name: 'Ok' }).click()
227233
await page.locator('[data-test="close-event-list"]').click()
228234

229-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
230-
timeout: 20000,
231-
})
235+
await expect(page.locator('[data-test=state] input')).toHaveValue(
236+
'completed',
237+
{
238+
timeout: 20000,
239+
},
240+
)
232241
}
233242

234243
test('test ruby metadata apis', async ({ page, utils }) => {
@@ -353,7 +362,10 @@ test('test python numpy import', async ({ page, utils }) => {
353362
timeout: 5000,
354363
},
355364
)
356-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
357-
timeout: 20000,
358-
})
365+
await expect(page.locator('[data-test=state] input')).toHaveValue(
366+
'completed',
367+
{
368+
timeout: 20000,
369+
},
370+
)
359371
})

playwright/tests/script-runner/debug.s.spec.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ puts "two"`)
105105
)
106106
// Go
107107
await page.locator('[data-test=go-button]').click()
108-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped')
108+
await expect(page.locator('[data-test=state] input')).toHaveValue('completed')
109109
// Verify we were able to change the 'x' variable
110110
await expect(page.locator('[data-test=output-messages]')).toContainText(
111111
'x:67890',
@@ -133,7 +133,7 @@ test('retries failed checks', async ({ page, utils }) => {
133133
).toHaveCount(2)
134134
await expect(page.locator('[data-test=state] input')).toHaveValue('error')
135135
await page.locator('[data-test=go-button]').click()
136-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped')
136+
await expect(page.locator('[data-test=state] input')).toHaveValue('completed')
137137
})
138138

139139
test('displays the call stack', async ({ page, utils }) => {
@@ -190,9 +190,12 @@ test('displays disconnect icon', async ({ page, utils }) => {
190190
'cmd("INST SETPARAMS with VALUE1 0, VALUE2 1, VALUE3 2, VALUE4 1, VALUE5 0")',
191191
)
192192
await page.locator('[data-test=start-button]').click()
193-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
194-
timeout: 20000,
195-
})
193+
await expect(page.locator('[data-test=state] input')).toHaveValue(
194+
'completed',
195+
{
196+
timeout: 20000,
197+
},
198+
)
196199

197200
await page.locator('[data-test=script-runner-script]').click()
198201
await page.locator('text=Toggle Disconnect').click()
@@ -219,9 +222,12 @@ puts "disconnect:#{val}"`)
219222
timeout: 5000,
220223
},
221224
)
222-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
223-
timeout: 20000,
224-
})
225+
await expect(page.locator('[data-test=state] input')).toHaveValue(
226+
'completed',
227+
{
228+
timeout: 20000,
229+
},
230+
)
225231
await expect(page.locator('[data-test=output-messages]')).toContainText(
226232
"CHECK: INST PARAMS VALUE1 == 'BAD' failed",
227233
)
@@ -252,9 +258,12 @@ puts "e"`)
252258
},
253259
)
254260
await page.locator('[data-test=go-button]').click()
255-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
256-
timeout: 20000,
257-
})
261+
await expect(page.locator('[data-test=state] input')).toHaveValue(
262+
'completed',
263+
{
264+
timeout: 20000,
265+
},
266+
)
258267
await expect(page.locator('[data-test=start-button]')).toBeVisible()
259268

260269
// Disable the breakpoint
@@ -266,9 +275,12 @@ puts "e"`)
266275
timeout: 5000,
267276
},
268277
)
269-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
270-
timeout: 20000,
271-
})
278+
await expect(page.locator('[data-test=state] input')).toHaveValue(
279+
'completed',
280+
{
281+
timeout: 20000,
282+
},
283+
)
272284
})
273285

274286
test('remembers breakpoints and clears all', async ({ page, utils }) => {
@@ -327,9 +339,12 @@ test('can delete all temp files', async ({ page, utils }) => {
327339
timeout: 5000,
328340
},
329341
)
330-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
331-
timeout: 20000,
332-
})
342+
await expect(page.locator('[data-test=state] input')).toHaveValue(
343+
'completed',
344+
{
345+
timeout: 20000,
346+
},
347+
)
333348
await expect(page.locator('#sr-controls')).toContainText(
334349
/__TEMP__\/\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}_\d{3}_temp.rb/,
335350
)
@@ -348,9 +363,12 @@ test('can delete all temp files', async ({ page, utils }) => {
348363
timeout: 5000,
349364
},
350365
)
351-
await expect(page.locator('[data-test=state] input')).toHaveValue('stopped', {
352-
timeout: 20000,
353-
})
366+
await expect(page.locator('[data-test=state] input')).toHaveValue(
367+
'completed',
368+
{
369+
timeout: 20000,
370+
},
371+
)
354372
await expect(page.locator('#sr-controls')).toContainText(
355373
/__TEMP__\/\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}_\d{3}_temp.rb/,
356374
)

0 commit comments

Comments
 (0)