diff --git a/tests/bdd_test.go b/tests/bdd_test.go index a4a7900c..07061478 100644 --- a/tests/bdd_test.go +++ b/tests/bdd_test.go @@ -171,6 +171,7 @@ func TestFeatures(testingT *testing.T) { ctx.Step(`^IMAP client "([^"]*)" sees that message (\d+) has the flag "([^"]*)"$`, s.imapClientSeesThatMessageHasTheFlag) ctx.Step(`^IMAP client "([^"]*)" expunges$`, s.imapClientExpunges) ctx.Step(`^IMAP client "([^"]*)" appends the following message to "([^"]*)":$`, s.imapClientAppendsTheFollowingMessageToMailbox) + ctx.Step(`^IMAP client "([^"]*)" appends the following messages to "([^"]*)":$`, s.imapClientAppendsTheFollowingMessagesToMailbox) ctx.Step(`^IMAP client "([^"]*)" appends "([^"]*)" to "([^"]*)"$`, s.imapClientAppendsToMailbox) // ==== SMTP ==== diff --git a/tests/features/imap/message/create.feature b/tests/features/imap/message/create.feature new file mode 100644 index 00000000..3e1a90b2 --- /dev/null +++ b/tests/features/imap/message/create.feature @@ -0,0 +1,62 @@ +Feature: IMAP create messages + Background: + Given there exists an account with username "user@pm.me" and password "password" + And the account "user@pm.me" has additional address "alias@pm.me" + And bridge starts + And the user logs in with username "user@pm.me" and password "password" + And user "user@pm.me" finishes syncing + And user "user@pm.me" connects and authenticates IMAP client "1" + + Scenario: Creates message to user's primary address + When IMAP client "1" appends the following messages to "INBOX": + | from | to | subject | body | + | john.doe@email.com | user@pm.me | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "INBOX": + | from | to | subject | body | + | john.doe@email.com | user@pm.me | foo | bar | + + Scenario: Creates draft + When IMAP client "1" appends the following messages to "Drafts": + | from | to | subject | body | + | user@pm.me | john.doe@email.com | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "Drafts": + | from | to | subject | body | + | user@pm.me | john.doe@email.com | foo | bar | + + Scenario: Creates message sent from user's primary address + When IMAP client "1" appends the following messages to "Sent": + | from | to | subject | body | + | user@pm.me | john.doe@email.com | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "Sent": + | from | to | subject | body | + | user@pm.me | john.doe@email.com | foo | bar | + + Scenario: Creates message sent from user's secondary address + When IMAP client "1" appends the following messages to "Sent": + | from | to | subject | body | + | alias@pm.me | john.doe@email.com | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "Sent": + | from | to | subject | body | + | alias@pm.me | john.doe@email.com | foo | bar | + + Scenario: Imports an unrelated message to inbox + When IMAP client "1" appends the following messages to "INBOX": + | from | to | subject | body | + | john.doe@email.com | john.doe2@pm.me | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "INBOX": + | from | to | subject | body | + | john.doe@email.com | john.doe2@pm.me | foo | bar | + + Scenario: Imports an unrelated message to sent + When IMAP client "1" appends the following messages to "Sent": + | from | to | subject | body | + | john.doe@email.com | john.doe2@pm.me | foo | bar | + Then it succeeds + And IMAP client "1" sees the following messages in "Sent": + | from | to | subject | body | + | john.doe@email.com | john.doe2@pm.me | foo | bar | \ No newline at end of file diff --git a/tests/imap_test.go b/tests/imap_test.go index 685ac421..c5ba6912 100644 --- a/tests/imap_test.go +++ b/tests/imap_test.go @@ -389,6 +389,23 @@ func (s *scenario) imapClientAppendsTheFollowingMessageToMailbox(clientID string return clientAppend(client, mailbox, docString.Content) } +func (s *scenario) imapClientAppendsTheFollowingMessagesToMailbox(clientID string, mailbox string, table *godog.Table) error { + _, client := s.t.getIMAPClient(clientID) + + messages, err := unmarshalTable[Message](table) + if err != nil { + return err + } + + for _, message := range messages { + if err := clientAppend(client, mailbox, string(message.Build())); err != nil { + return err + } + } + + return nil +} + func (s *scenario) imapClientAppendsToMailbox(clientID string, file, mailbox string) error { _, client := s.t.getIMAPClient(clientID)