GODT-1433 Adding first integration test for drafts.

This commit is contained in:
Jakub
2021-11-30 13:53:49 +01:00
parent 6ed97a0347
commit 55beb9227f
8 changed files with 89 additions and 15 deletions

View File

@ -27,6 +27,7 @@ func APIActionsFeatureContext(s *godog.ScenarioContext) {
s.Step(`^the internet connection is lost$`, theInternetConnectionIsLost)
s.Step(`^the internet connection is restored$`, theInternetConnectionIsRestored)
s.Step(`^(\d+) second[s]? pass$`, secondsPass)
s.Step(`^the body of draft "([^"]*)" for "([^"]*)" has changed to "([^"]*)"$`, draftBodyChanged)
}
func theInternetConnectionIsLost() error {
@ -43,3 +44,22 @@ func secondsPass(seconds int) error {
time.Sleep(time.Duration(seconds) * time.Second)
return nil
}
func draftBodyChanged(bddMessageID, bddUserID, body string) error {
account := ctx.GetTestAccount(bddUserID)
if account == nil {
return godog.ErrPending
}
messageID, err := ctx.GetAPIMessageID(account.Username(), bddMessageID)
if err != nil {
return internalError(err, "getting apiID for %s", bddMessageID)
}
err = ctx.GetPMAPIController().SetDraftBody(account.Username(), messageID, body)
if err != nil {
return internalError(err, "cannot set body of %s", messageID)
}
return nil
}