diff --git a/tests/bridge_test.go b/tests/bridge_test.go index 87e9a877..11430a4d 100644 --- a/tests/bridge_test.go +++ b/tests/bridge_test.go @@ -31,6 +31,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/ProtonMail/proton-bridge/v3/internal/bridge" "github.com/ProtonMail/proton-bridge/v3/internal/events" + "github.com/ProtonMail/proton-bridge/v3/internal/kb" "github.com/ProtonMail/proton-bridge/v3/internal/vault" "github.com/cucumber/godog" "github.com/golang/mock/gomock" @@ -236,6 +237,30 @@ func (s *scenario) theUserReportsABugWithDetails(value *godog.DocString) error { return bugReport.report() } +func (s *scenario) theDescriptionInputProvidesKnowledgeBaseArticles(description string, value *godog.DocString) error { + var wantSuggestions kb.ArticleList + if err := json.Unmarshal([]byte(value.Content), &wantSuggestions); err != nil { + return fmt.Errorf("Cannot parse wanted suggestions: %w", err) + } + + haveSuggestions, err := s.t.bridge.GetKnowledgeBaseSuggestions(description) + if err != nil { + return err + } + + for i := 0; i < len(wantSuggestions); i++ { + if haveSuggestions[i].URL != wantSuggestions[i].URL { + return fmt.Errorf("Description \"%v\" has URL: \"%v\", want: \"%v\"", description, haveSuggestions[i].URL, wantSuggestions[i].URL) + } + + if haveSuggestions[i].Title != wantSuggestions[i].Title { + return fmt.Errorf("Description \"%v\" has Title: \"%v\", want: \"%v\"", description, haveSuggestions[i].Title, wantSuggestions[i].Title) + } + } + + return nil +} + func (s *scenario) bridgeSendsAConnectionUpEvent() error { if event := s.t.events.await(events.ConnStatusUp{}, 30*time.Second); event == nil { return errors.New("expected connection up event, got none") diff --git a/tests/features/user/kb_article_suggestions.feature b/tests/features/user/kb_article_suggestions.feature new file mode 100644 index 00000000..9b98e404 --- /dev/null +++ b/tests/features/user/kb_article_suggestions.feature @@ -0,0 +1,23 @@ +Feature: The user reports a problem + Background: + Given bridge starts + And it succeeds + + Scenario: The user wants to report a problem + Then the description "Setup Outlook Windows" provides the following KB suggestions: + """ + [ + { + "url": "https://proton.me/support/protonmail-bridge-configure-client", + "title": "How to configure your email client for Proton Mail Bridge" + }, + { + "url": "https://proton.me/support/protonmail-bridge-install", + "title": "How to install Proton Mail Bridge" + }, + { + "url": "https://proton.me/support/protonmail-bridge-clients-windows-outlook-2019", + "title": "Proton Mail Bridge Microsoft Outlook for Windows 2019 setup guide" + } + ] + """ diff --git a/tests/steps_test.go b/tests/steps_test.go index 1ccc1b01..a02e6825 100644 --- a/tests/steps_test.go +++ b/tests/steps_test.go @@ -76,6 +76,7 @@ func (s *scenario) steps(ctx *godog.ScenarioContext) { ctx.Step(`^the user reports a bug$`, s.theUserReportsABug) ctx.Step(`^the user reports a bug with field "([^"]*)" set to "([^"]*)"$`, s.theUserReportsABugWithSingleHeaderChange) ctx.Step(`^the user reports a bug with details:$`, s.theUserReportsABugWithDetails) + ctx.Step(`^the description "([^"]*)" provides the following KB suggestions:$`, s.theDescriptionInputProvidesKnowledgeBaseArticles) ctx.Step(`^the user hides All Mail$`, s.theUserHidesAllMail) ctx.Step(`^the user shows All Mail$`, s.theUserShowsAllMail) ctx.Step(`^the user disables telemetry in bridge settings$`, s.theUserDisablesTelemetryInBridgeSettings)