From a0ef57ca1597f7b0aeec1ed6cafacd133fd43623 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Tue, 1 Oct 2024 21:43:52 +0300 Subject: [PATCH] add Change PIN test --- menu_traversal_test.go | 31 +++++++++++++++++++++++++++++++ test_data.json | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/menu_traversal_test.go b/menu_traversal_test.go index 66f36f6..7275afa 100644 --- a/menu_traversal_test.go +++ b/menu_traversal_test.go @@ -249,3 +249,34 @@ func TestMainMenuQuit(t *testing.T) { } } } + +func TestMyAccountChangePin(t *testing.T) { + en, fn := enginetest.TestEngine("session1234112") + defer fn() + ctx := context.Background() + sessions := testData + for _, session := range sessions { + groups := driver.FilterGroupsByName(session.Groups, "my_account_change_pin") + for _, group := range groups { + for _, step := range group.Steps { + cont, err := en.Exec(ctx, []byte(step.Input)) + if err != nil { + t.Fatalf("Test case '%s' failed at input '%s': %v", group.Name, step.Input, err) + return + } + if !cont { + break + } + w := bytes.NewBuffer(nil) + if _, err := en.Flush(ctx, w); err != nil { + t.Fatalf("Test case '%s' failed during Flush: %v", group.Name, err) + } + + b := w.Bytes() + if !bytes.Equal(b, []byte(step.ExpectedContent)) { + t.Fatalf("expected:\n\t%s\ngot:\n\t%s\n", step.ExpectedContent, b) + } + } + } + } +} diff --git a/test_data.json b/test_data.json index 59e0dcb..ea6301d 100644 --- a/test_data.json +++ b/test_data.json @@ -170,6 +170,43 @@ "expectedContent": "Thank you for using Sarafu. Goodbye!" } ] + }, + { + "name": "my_account_change_pin", + "steps": [ + { + "input": "", + "expectedContent": "Balance: 0.003 CELO\n\n1:Send\n2:My Vouchers\n3:My Account\n4:Help\n9:Quit" + }, + { + "input": "3", + "expectedContent": "My Account\n1:Profile\n2:Change language\n3:Check balances\n4:Check statement\n5:PIN options\n6:My Address\n0:Back" + }, + { + "input": "5", + "expectedContent": "PIN Management\n1:Change PIN\n2:Reset other's PIN\n3:Guard my PIN\n0:Back" + }, + { + "input": "1", + "expectedContent": "Enter your old PIN\n\n0:Back" + }, + { + "input": "1234", + "expectedContent": "Enter a new four number pin\n\n0:Back" + }, + { + "input": "1234", + "expectedContent": "Confirm your new PIN:\n\n0:Back" + }, + { + "input": "1234", + "expectedContent": "Your PIN change request has been successful\n\n0:Back\n9:Quit" + }, + { + "input": "9", + "expectedContent": "Thank you for using Sarafu. Goodbye!" + } + ] } ] }