test(GODT-3162): Add step definition for checking KB article suggestions

* Add a step definition that takes input from a possible problem report description, and gets the suggested knowledge base articles
* Also, has input of what those knowledge base articles should be, just their title and url, and compares these two values.
* A sample integration test is added
This commit is contained in:
Gjorgji Slamkov 2023-12-15 09:53:49 +00:00
parent 8f5bd37aee
commit 3ac59d6943
3 changed files with 49 additions and 0 deletions

View File

@ -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")

View File

@ -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"
}
]
"""

View File

@ -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)