()
| 96 | } |
| 97 | |
| 98 | func (m rootModel) View() string { |
| 99 | if m.clear { |
| 100 | return "" |
| 101 | } |
| 102 | s := m.spinner.View() |
| 103 | var str strings.Builder |
| 104 | for _, step := range m.steps { |
| 105 | str.WriteString(renderTestHeader(step.step, m.spinner, step.finished, m.isSubmit, step.passed, step.noPenaltyOnFail)) |
| 106 | str.WriteString(renderTests(step.tests, s)) |
| 107 | |
| 108 | if step.sleepAfter != "" && step.finished { |
| 109 | sleepBox := borderBox.Render(fmt.Sprintf(" %s ", step.sleepAfter)) |
| 110 | str.WriteString(sleepBox) |
| 111 | str.WriteByte('\n') |
| 112 | } |
| 113 | |
| 114 | if step.result == nil || !m.finalized { |
| 115 | continue |
| 116 | } |
| 117 | |
| 118 | if step.result.CLICommandResult != nil { |
| 119 | for _, test := range step.tests { |
| 120 | if strings.Contains(test.text, "exit code") { |
| 121 | fmt.Fprintf(&str, "\n > Command exit code: %d\n", step.result.CLICommandResult.ExitCode) |
| 122 | break |
| 123 | } |
| 124 | } |
| 125 | str.WriteString(" > Command stdout:\n\n") |
| 126 | sliced := strings.SplitSeq(step.result.CLICommandResult.Stdout, "\n") |
| 127 | i := 0 |
| 128 | runeCount := 0 |
| 129 | const maxLines, maxRunes = 32, 5120 |
| 130 | for s := range sliced { |
| 131 | if i >= maxLines || runeCount >= maxRunes { |
| 132 | str.WriteString(gray.Render("... output visually truncated, full output captured")) |
| 133 | str.WriteByte('\n') |
| 134 | break |
| 135 | } |
| 136 | runeCount += utf8.RuneCountInString(s) |
| 137 | str.WriteString(gray.Render(s)) |
| 138 | str.WriteByte('\n') |
| 139 | i++ |
| 140 | } |
| 141 | str.WriteString(renderJqOutputs(step.result.CLICommandResult.JqOutputs)) |
| 142 | availableVariables, expectsVariables := availableVariablesForCLIResult(*step.result.CLICommandResult) |
| 143 | if expectsVariables { |
| 144 | str.WriteString(renderVariableSection("Variables Available", availableVariables)) |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if step.result.HTTPRequestResult != nil { |
| 149 | str.WriteString(printHTTPRequestResult(*step.result.HTTPRequestResult)) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if m.result == api.VerificationResultSlugSuccess && m.isSubmit { |
| 154 | str.WriteString("\n\n" + green.Render("All tests passed! 🎉") + "\n") |
| 155 | if m.xpReward >= 0 { |
no test coverage detected