-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(console): refactor, retries, sleep to address flaky tests (#698)
- Loading branch information
1 parent
1ab0eef
commit 02101a5
Showing
13 changed files
with
475 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/internal/tui/assessment_results/assessment-results_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package assessmentresults_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
"github.com/charmbracelet/lipgloss" | ||
"github.com/defenseunicorns/lula/src/internal/testhelpers" | ||
assessmentresults "github.com/defenseunicorns/lula/src/internal/tui/assessment_results" | ||
"github.com/defenseunicorns/lula/src/internal/tui/common" | ||
"github.com/muesli/termenv" | ||
) | ||
|
||
const ( | ||
timeout = time.Second * 20 | ||
maxRetries = 3 | ||
height = common.DefaultHeight | ||
width = common.DefaultWidth | ||
|
||
validAssessmentResults = "../../../test/unit/common/oscal/valid-assessment-results.yaml" | ||
) | ||
|
||
func init() { | ||
lipgloss.SetColorProfile(termenv.Ascii) | ||
} | ||
|
||
// TestAssessmentResultsBasicView tests that the model is created correctly from an assessment results model | ||
func TestAssessmentResultsBasicView(t *testing.T) { | ||
oscalModel := testhelpers.OscalFromPath(t, validAssessmentResults) | ||
model := assessmentresults.NewAssessmentResultsModel(oscalModel.AssessmentResults) | ||
model.Open(height, width) | ||
|
||
msgs := []tea.Msg{} | ||
|
||
err := testhelpers.RunTestModelView(t, model, msgs, timeout, maxRetries, height, width) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
src/internal/tui/assessment_results/testdata/TestAssessmentResultsBasicView.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
? toggle help | ||
╭────────────────────────────────────────╮ ╭────────────────────────────────────────╮ | ||
Selected Result │Lula Validation Result - 41787700-2a4c-…│ Compare Result │No Result Selected │ | ||
╰────────────────────────────────────────╯ ╰────────────────────────────────────────╯ | ||
╭───────────────╮ ╭─────────╮ | ||
│ Findings List ├─────────────────────────────╮ │ Summary ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
╰───────────────╯ ╰─────────╯ | ||
│ │ │ ⚠️ Summary Under Construction ⚠️ │ | ||
│ 1 item │ │ │ | ||
│ │ │ │ | ||
│ ID-1 │ │ │ | ||
│ not-satisfied │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ | ||
│ │ ╭──────────────╮ | ||
│ │ │ Observations ├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ | ||
│ │ ╰──────────────╯ | ||
│ │ │ ⚠️ Observations Under Construction ⚠️ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ │ │ │ | ||
│ ↑/k up • ↓/j down • ↳ confirm • ? toggle │ │ │ | ||
╰────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ |
Oops, something went wrong.