diff --git a/tests/_features/imap/message/copy.feature b/tests/_features/imap/message/copy.feature deleted file mode 100644 index a4c50ed4..00000000 --- a/tests/_features/imap/message/copy.feature +++ /dev/null @@ -1,89 +0,0 @@ -Feature: IMAP copy messages - Background: - Given there is connected user "user" - And there is "user" with mailbox "Folders/mbox" - And there is "user" with mailbox "Labels/label" - And there are messages in mailbox "INBOX" for "user" - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - And there are messages in mailbox "Sent" for "user" - | from | to | subject | body | - | john.doe@mail.com | user@pm.me | response | hello | - And there is IMAP client logged in as "user" - - Scenario: Copy message to label - Given there is IMAP client selected in "INBOX" - When IMAP client copies message seq "1" to "Labels/label" - Then IMAP response is "OK" - And mailbox "INBOX" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - And mailbox "Labels/label" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - - Scenario: Copy all messages to label - Given there is IMAP client selected in "INBOX" - When IMAP client copies message seq "1:*" to "Labels/label" - Then IMAP response is "OK" - And mailbox "INBOX" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - And mailbox "Labels/label" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - - Scenario: Copy message to folder does move - Given there is IMAP client selected in "INBOX" - When IMAP client copies message seq "1" to "Folders/mbox" - Then IMAP response is "OK" - And mailbox "INBOX" for "user" has messages - | from | to | subject | body | read | deleted | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - And mailbox "Folders/mbox" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - - Scenario: Copy message from All mail moves from the original location - Given there is IMAP client selected in "All Mail" - When IMAP client copies message seq "1" to "Folders/mbox" - Then IMAP response is "OK" - And mailbox "INBOX" for "user" has 2 messages - And mailbox "INBOX" for "user" has messages - | from | to | subject | body | read | deleted | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - | john.doe@mail.com | user@pm.me | response | hello | true | false | - And mailbox "All Mail" for "user" has 3 messages - And mailbox "All Mail" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | false | - | john.doe@mail.com | user@pm.me | response | hello | true | false | - And mailbox "Folders/mbox" for "user" has 1 messages - And mailbox "Folders/mbox" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - - Scenario: Copy all messages to folder does move - Given there is IMAP client selected in "INBOX" - When IMAP client copies message seq "1:*" to "Folders/mbox" - Then IMAP response is "OK" - And mailbox "INBOX" for "user" has 0 messages - And mailbox "Folders/mbox" for "user" has messages - | from | to | subject | body | read | deleted | - | john.doe@mail.com | user@pm.me | foo | hello | true | false | - | jane.doe@mail.com | name@pm.me | bar | world | false | true | - - Scenario: Copy message from Inbox to Sent is not possible - Given there is IMAP client selected in "INBOX" - When IMAP client copies message seq "1" to "Sent" - Then IMAP response is "move from Inbox to Sent is not allowed" - - Scenario: Copy message from Sent to Inbox is not possible - Given there is IMAP client selected in "Sent" - When IMAP client copies message seq "1" to "INBOX" - Then IMAP response is "move from Sent to Inbox is not allowed" diff --git a/tests/features/imap/message/copy.feature b/tests/features/imap/message/copy.feature index 3898296e..8efe4a11 100644 --- a/tests/features/imap/message/copy.feature +++ b/tests/features/imap/message/copy.feature @@ -6,9 +6,9 @@ Feature: IMAP copy messages | mbox | folder | | label | label | And the address "[user:user]@[domain]" of account "[user:user]" has the following messages in "Inbox": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | - | jane.doe@mail.com | name@[domain] | bar | true | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | true | And bridge starts And the user logs in with username "[user:user]" and password "password" And user "[user:user]" finishes syncing @@ -16,36 +16,40 @@ Feature: IMAP copy messages Scenario: Copy message to label When IMAP client "1" copies the message with subject "foo" from "INBOX" to "Labels/label" + And it succeeds Then IMAP client "1" sees the following messages in "INBOX": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | - | jane.doe@mail.com | name@[domain] | bar | true | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | true | And IMAP client "1" sees the following messages in "Labels/label": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | Scenario: Copy all messages to label When IMAP client "1" copies all messages from "INBOX" to "Labels/label" + And it succeeds Then IMAP client "1" sees the following messages in "INBOX": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | - | jane.doe@mail.com | name@[domain] | bar | true | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | true | And IMAP client "1" sees the following messages in "Labels/label": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | - | jane.doe@mail.com | name@[domain] | bar | true | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | true | Scenario: Copy message to folder does move When IMAP client "1" copies the message with subject "foo" from "INBOX" to "Folders/mbox" + And it succeeds Then IMAP client "1" eventually sees the following messages in "INBOX": - | from | to | subject | unread | - | jane.doe@mail.com | name@[domain] | bar | true | + | from | to | subject | unread | deleted | + | jane.doe@mail.com | name@[domain] | bar | true | true | And IMAP client "1" sees the following messages in "Folders/mbox": - | from | to | subject | unread | - | john.doe@mail.com | [user:user]@[domain] | foo | false | + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | true | Scenario: Copy all messages to folder does move When IMAP client "1" copies all messages from "INBOX" to "Folders/mbox" + And it succeeds Then IMAP client "1" sees the following messages in "Folders/mbox": | from | to | subject | unread | | john.doe@mail.com | [user:user]@[domain] | foo | false | @@ -54,8 +58,28 @@ Feature: IMAP copy messages Scenario: Copy message from Inbox to Sent is not possible When IMAP client "1" copies the message with subject "foo" from "INBOX" to "Sent" + And it succeeds Then IMAP client "1" eventually sees the following messages in "INBOX": | from | to | subject | unread | | john.doe@mail.com | [user:user]@[domain] | foo | false | | jane.doe@mail.com | name@[domain] | bar | true | - And IMAP client "1" eventually sees 0 messages in "Sent" \ No newline at end of file + And IMAP client "1" eventually sees 0 messages in "Sent" + + Scenario: Copy message from All mail moves from the original location + Then IMAP client "1" sees the following messages in "INBOX": + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | true | + When IMAP client "1" copies the message with subject "foo" from "All Mail" to "Folders/mbox" + And it succeeds + Then IMAP client "1" sees the following messages in "INBOX": + | from | to | subject | unread | deleted | + | jane.doe@mail.com | name@[domain] | bar | true | true | + Then IMAP client "1" sees the following messages in "All Mail": + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | false | + | jane.doe@mail.com | name@[domain] | bar | true | false | + Then IMAP client "1" sees the following messages in "Folders/mbox": + | from | to | subject | unread | deleted | + | john.doe@mail.com | [user:user]@[domain] | foo | false | true | + diff --git a/tests/imap_test.go b/tests/imap_test.go index 80acf49a..4daf15af 100644 --- a/tests/imap_test.go +++ b/tests/imap_test.go @@ -252,13 +252,21 @@ func (s *scenario) imapClientCopiesTheMessageWithSubjectFromTo(clientID, subject return err } - return clientCopy(client, from, to, uid) + if err := clientCopy(client, from, to, uid); err != nil { + s.t.pushError(err) + } + + return nil } func (s *scenario) imapClientCopiesAllMessagesFromTo(clientID, from, to string) error { _, client := s.t.getIMAPClient(clientID) - return clientCopy(client, from, to) + if err := clientCopy(client, from, to); err != nil { + s.t.pushError(err) + } + + return nil } func (s *scenario) imapClientSeesTheFollowingMessagesInMailbox(clientID, mailbox string, table *godog.Table) error { diff --git a/tests/types_test.go b/tests/types_test.go index fba0194e..f4cfcf74 100644 --- a/tests/types_test.go +++ b/tests/types_test.go @@ -46,7 +46,8 @@ type Message struct { CC string `bdd:"cc"` BCC string `bdd:"bcc"` - Unread bool `bdd:"unread"` + Unread bool `bdd:"unread"` + Deleted bool `bdd:"deleted"` } func (msg Message) Build() []byte { @@ -113,6 +114,7 @@ func newMessageFromIMAP(msg *imap.Message) Message { Attachments: strings.Join(xslices.Map(m.Attachments, func(att message.Attachment) string { return att.Name }), ", "), MessageID: msg.Envelope.MessageId, Unread: !slices.Contains(msg.Flags, imap.SeenFlag), + Deleted: !slices.Contains(msg.Flags, imap.DeletedFlag), } if len(msg.Envelope.From) > 0 {