Skip to content

Commit 92b16df

Browse files
authored
Tweaks to the UI for ie test (#239)
This PR updates `ie test` to include the Scenario title, the step titles, and styling for command standard output/error messages shown after the command is executed.
1 parent ac65e32 commit 92b16df

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

internal/engine/test/model.go

+25-3
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,34 @@ func (model TestModeModel) Update(message tea.Msg) (tea.Model, tea.Cmd) {
132132
model.resourceGroupName = tmpResourceGroup
133133
}
134134
}
135-
model.CommandLines = append(model.CommandLines, codeBlockState.StdOut)
135+
model.CommandLines = append(
136+
model.CommandLines,
137+
ui.VerboseStyle.Render(codeBlockState.StdOut),
138+
)
136139
viewportContentUpdated = true
137140

138141
// Increment the codeblock and update the viewport content.
139142
model.currentCodeBlock++
140143

141144
if model.currentCodeBlock < len(model.codeBlockState) {
145+
nextTitle := model.codeBlockState[model.currentCodeBlock].StepName
142146
nextCommand := model.codeBlockState[model.currentCodeBlock].CodeBlock.Content
143147
nextLanguage := model.codeBlockState[model.currentCodeBlock].CodeBlock.Language
144148

145-
model.CommandLines = append(model.CommandLines, ui.CommandPrompt(nextLanguage)+nextCommand)
149+
// Only add the title if the next step title is different from the current step.
150+
if codeBlockState.StepName != nextTitle {
151+
model.CommandLines = append(
152+
model.CommandLines,
153+
ui.StepTitleStyle.Render(
154+
fmt.Sprintf("Step %d: %s", model.currentCodeBlock+1, nextTitle),
155+
)+"\n",
156+
)
157+
}
158+
159+
model.CommandLines = append(
160+
model.CommandLines,
161+
ui.CommandPrompt(nextLanguage)+nextCommand,
162+
)
146163
}
147164

148165
// Only increment the step for azure if the step name has changed.
@@ -178,7 +195,10 @@ func (model TestModeModel) Update(message tea.Msg) (tea.Model, tea.Cmd) {
178195
codeBlockState.SimilarityScore = message.SimilarityScore
179196

180197
model.codeBlockState[step] = codeBlockState
181-
model.CommandLines = append(model.CommandLines, codeBlockState.StdErr+message.Error.Error())
198+
model.CommandLines = append(
199+
model.CommandLines,
200+
ui.ErrorStyle.Render(codeBlockState.StdErr+message.Error.Error()),
201+
)
182202
viewportContentUpdated = true
183203

184204
commands = append(commands, common.Exit(true))
@@ -287,6 +307,8 @@ func NewTestModeModel(
287307

288308
language := codeBlockState[0].CodeBlock.Language
289309
commandLines := []string{
310+
ui.ScenarioTitleStyle.Render(title) + "\n",
311+
ui.StepTitleStyle.Render("Step 1: "+codeBlockState[0].StepName) + "\n",
290312
ui.CommandPrompt(language) + codeBlockState[0].CodeBlock.Content,
291313
}
292314

0 commit comments

Comments
 (0)