Skip to content

Commit

Permalink
test(ui): update generate validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Dec 2, 2024
1 parent 7082d7d commit 6864c82
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
7 changes: 5 additions & 2 deletions ui/modals/generate/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
func Test_New(t *testing.T) {
m := New("ABC", test.GetState(nil))

m.SetAddress("ACB")
m.SetAddress("TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU")

if m.Address != "ABC" {
if m.Address != "TUIDKH2C7MUHZDD77MAMUREJRKNK25SYXB7OAFA6JFBB24PEL5UX4S4GUU" {
t.Error("Did not set address")
}

Expand Down Expand Up @@ -44,6 +44,7 @@ func Test_New(t *testing.T) {

m.SetStep(DurationStep)
m.Range = Week
m.InputTwo.SetValue("1")
m, cmd = m.HandleMessage(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("enter"),
Expand All @@ -54,6 +55,7 @@ func Test_New(t *testing.T) {

m.SetStep(DurationStep)
m.Range = Month
m.InputTwo.SetValue("1")
m, cmd = m.HandleMessage(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("enter"),
Expand All @@ -64,6 +66,7 @@ func Test_New(t *testing.T) {

m.SetStep(DurationStep)
m.Range = Year
m.InputTwo.SetValue("1")
m, cmd = m.HandleMessage(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("enter"),
Expand Down
2 changes: 1 addition & 1 deletion ui/modals/generate/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type ViewModel struct {
cursorMode cursor.Mode
}

func (m ViewModel) SetAddress(address string) {
func (m *ViewModel) SetAddress(address string) {
m.Address = address
m.Input.SetValue(address)
}
Expand Down
4 changes: 3 additions & 1 deletion ui/modals/generate/testdata/Test_Snapshot/Waiting.golden
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

Generating Participation Keys...

Please wait. This operation can take a few minutes.
Please wait. This operation can take a few minutes.

12 changes: 7 additions & 5 deletions ui/modals/transaction/testdata/Test_Snapshot/NotVisible.golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Sign this transaction to register your account keys:

QR Code too large to display. Please adjust terminal dimensions or font size.
-or-
Click here to sign via Lora.
Sign this transaction to register your account keys:

Mobile QR is available but it does not fit on screen.
Adjust terminal dimensions or font size to display.

-or-
Click here to sign via Lora.
5 changes: 4 additions & 1 deletion ui/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ func (m ViewportViewModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
case "ctrl+c":
case "q":
return m, tea.Quit
// Close the app when anything other than generate modal is visible
if !m.modal.Open || (m.modal.Open && m.modal.Type != app.GenerateModal) {
return m, tea.Quit
}
}

case tea.WindowSizeMsg:
Expand Down
2 changes: 1 addition & 1 deletion ui/viewport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Test_ViewportViewRender(t *testing.T) {
// Send quit key
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("ctrl+c"),
Runes: []rune("q"),
})

tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second))
Expand Down

0 comments on commit 6864c82

Please sign in to comment.