mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-24 02:46:44 +00:00
Tests for deleted flag GODT-496
This commit is contained in:
@ -4,42 +4,50 @@ Feature: IMAP copy messages
|
||||
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 |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world |
|
||||
| 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 is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "INBOX"
|
||||
|
||||
Scenario: Copy message to label
|
||||
When IMAP client copies messages "2" to "Labels/label"
|
||||
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 |
|
||||
| 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 |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| from | to | subject | body | read | deleted |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
|
||||
|
||||
Scenario: Copy all messages to label
|
||||
When IMAP client copies messages "1:*" to "Labels/label"
|
||||
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 |
|
||||
| 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 |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
| 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
|
||||
When IMAP client copies messages "2" to "Folders/mbox"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 1 message
|
||||
And mailbox "INBOX" for "user" has messages
|
||||
| from | to | subject | body | read | deleted |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello | true | false |
|
||||
And mailbox "Folders/mbox" for "user" has messages
|
||||
| from | to | subject |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| from | to | subject | body | read | deleted |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world | false | true |
|
||||
|
||||
Scenario: Copy all messages to folder does move
|
||||
When IMAP client copies messages "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 |
|
||||
| john.doe@mail.com | user@pm.me | foo |
|
||||
| jane.doe@mail.com | name@pm.me | bar |
|
||||
| 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 |
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
Feature: IMAP delete messages
|
||||
Feature: IMAP remove messages from mailbox
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
And there is "user" with mailbox "Folders/mbox"
|
||||
And there is "user" with mailbox "Labels/label"
|
||||
|
||||
Scenario Outline: Delete message
|
||||
Scenario Outline: Mark message as deleted and EXPUNGE
|
||||
Given there are 10 messages in mailbox "<mailbox>" for "user"
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "<mailbox>"
|
||||
When IMAP client deletes messages "1"
|
||||
When IMAP client marks message "2" as deleted
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "<mailbox>" for "user" has 10 messages
|
||||
And message "2" in "INBOX" for "user" is marked as deleted
|
||||
When IMAP client sends expunge
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "* 2 EXPUNGE"
|
||||
And mailbox "<mailbox>" for "user" has 9 messages
|
||||
|
||||
Examples:
|
||||
@ -17,14 +22,22 @@ Feature: IMAP delete messages
|
||||
| INBOX |
|
||||
| Folders/mbox |
|
||||
| Labels/label |
|
||||
| Spam |
|
||||
| Trash |
|
||||
|
||||
Scenario Outline: Delete all messages
|
||||
Given there are 10 messages in mailbox "<mailbox>" for "user"
|
||||
Scenario Outline: Mark all messages as deleted and EXPUNGE
|
||||
Given there are 5 messages in mailbox "<mailbox>" for "user"
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "<mailbox>"
|
||||
When IMAP client deletes messages "1:*"
|
||||
When IMAP client marks message "1:*" as deleted
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client sends expunge
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "* 1 EXPUNGE"
|
||||
And IMAP response contains "* 2 EXPUNGE"
|
||||
And IMAP response contains "* 3 EXPUNGE"
|
||||
And IMAP response contains "* 4 EXPUNGE"
|
||||
And IMAP response contains "* 5 EXPUNGE"
|
||||
And mailbox "<mailbox>" for "user" has 0 messages
|
||||
|
||||
Examples:
|
||||
@ -32,14 +45,50 @@ Feature: IMAP delete messages
|
||||
| INBOX |
|
||||
| Folders/mbox |
|
||||
| Labels/label |
|
||||
| Spam |
|
||||
| Trash |
|
||||
|
||||
Scenario: Delete message by setting flags
|
||||
Given there are 1 messages in mailbox "INBOX" for "user"
|
||||
Scenario Outline: Mark messages as undeleted and EXPUNGE
|
||||
Given there are 5 messages in mailbox "<mailbox>" for "user"
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "<mailbox>"
|
||||
When IMAP client marks message "1:*" as deleted
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client marks message "1:3" as undeleted
|
||||
Then IMAP response is "OK"
|
||||
When IMAP client sends expunge
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "* 4 EXPUNGE"
|
||||
And IMAP response contains "* 5 EXPUNGE"
|
||||
And mailbox "<mailbox>" for "user" has 3 messages
|
||||
|
||||
Examples:
|
||||
| mailbox |
|
||||
| INBOX |
|
||||
| Folders/mbox |
|
||||
| Labels/label |
|
||||
| Spam |
|
||||
| Trash |
|
||||
|
||||
Scenario Outline: Mark message as deleted and leave mailbox
|
||||
Given there are 10 messages in mailbox "INBOX" for "user"
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "INBOX"
|
||||
When IMAP client marks message "1" with "\Deleted"
|
||||
When IMAP client marks message "2" as deleted
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has 0 messages
|
||||
# Unread because we set flags without \Seen.
|
||||
And message "1" in "Trash" for "user" is marked as unread
|
||||
And mailbox "INBOX" for "user" has 10 messages
|
||||
And message "2" in "INBOX" for "user" is marked as deleted
|
||||
When IMAP client sends command "<leave>"
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "INBOX" for "user" has <n> messages
|
||||
|
||||
Examples:
|
||||
| leave | n |
|
||||
| CLOSE | 9 |
|
||||
| SELECT INBOX | 9 |
|
||||
| SELECT Trash | 9 |
|
||||
| EXAMINE INBOX | 9 |
|
||||
| EXAMINE Trash | 9 |
|
||||
| LOGOUT | 9 |
|
||||
| UNSELECT | 10 |
|
||||
|
||||
|
||||
@ -49,3 +49,14 @@ Feature: IMAP fetch messages
|
||||
When IMAP client fetches by UID "11:*"
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response has 1 message
|
||||
|
||||
Scenario: Fetch returns also messages that are marked as deleted
|
||||
Given there are messages in mailbox "Folders/mbox" for "user"
|
||||
| from | to | subject | body | read | starred | deleted |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world | true | true | true |
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "Folders/mbox"
|
||||
When IMAP client fetches by UID "1:*"
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response has 2 message
|
||||
|
||||
@ -4,10 +4,10 @@ Feature: IMAP search messages
|
||||
# Messages are inserted in opposite way to keep increasing ID.
|
||||
# Sequence numbers are then opposite than listed above.
|
||||
Given there are messages in mailbox "INBOX" for "user"
|
||||
| from | to | cc | subject | read | starred | body |
|
||||
| john.doe@email.com | user@pm.me | | foo | false | false | hello |
|
||||
| jane.doe@email.com | user@pm.me | name@pm.me | bar | true | true | world |
|
||||
| jane.doe@email.com | name@pm.me | | baz | true | false | bye |
|
||||
| from | to | cc | subject | read | starred | deleted | body |
|
||||
| john.doe@email.com | user@pm.me | | foo | false | false | false | hello |
|
||||
| jane.doe@email.com | user@pm.me | name@pm.me | bar | true | true | false | world |
|
||||
| jane.doe@email.com | name@pm.me | | baz | true | false | true | bye |
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "INBOX"
|
||||
|
||||
@ -71,6 +71,16 @@ Feature: IMAP search messages
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "SEARCH 3[^0-9]*$"
|
||||
|
||||
Scenario: Search deleted messages
|
||||
When IMAP client searches for "DELETED"
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "SEARCH 1 2[^0-9]*$"
|
||||
|
||||
Scenario: Search undeleted messages
|
||||
When IMAP client searches for "UNDELETED"
|
||||
Then IMAP response is "OK"
|
||||
And IMAP response contains "SEARCH 3[^0-9]*$"
|
||||
|
||||
Scenario: Search recent messages
|
||||
When IMAP client searches for "RECENT"
|
||||
Then IMAP response is "OK"
|
||||
|
||||
@ -4,9 +4,9 @@ Feature: IMAP update messages
|
||||
# Messages are inserted in opposite way to keep increasing ID.
|
||||
# Sequence numbers are then opposite than listed above.
|
||||
And there are messages in mailbox "INBOX" for "user"
|
||||
| from | to | subject | body | read | starred |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello | false | false |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world | true | true |
|
||||
| from | to | subject | body | read | starred | deleted |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello | false | false | false |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world | true | true | false |
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "INBOX"
|
||||
|
||||
@ -55,3 +55,25 @@ Feature: IMAP update messages
|
||||
# Unread and unstarred because we set flags without \Seen and \Starred.
|
||||
And message "1" in "Spam" for "user" is marked as unread
|
||||
And message "1" in "Spam" for "user" is marked as unstarred
|
||||
|
||||
Scenario: Mark message as deleted
|
||||
When IMAP client marks message "2" as deleted
|
||||
Then IMAP response is "OK"
|
||||
And message "2" in "INBOX" for "user" is marked as read
|
||||
And message "2" in "INBOX" for "user" is marked as starred
|
||||
And message "2" in "INBOX" for "user" is marked as deleted
|
||||
|
||||
Scenario: Mark message as undeleted
|
||||
When IMAP client marks message "2" as undeleted
|
||||
Then IMAP response is "OK"
|
||||
And message "2" in "INBOX" for "user" is marked as read
|
||||
And message "2" in "INBOX" for "user" is marked as starred
|
||||
And message "2" in "INBOX" for "user" is marked as undeleted
|
||||
|
||||
Scenario: Mark message as deleted only
|
||||
When IMAP client marks message "2" with "\Deleted"
|
||||
Then IMAP response is "OK"
|
||||
And message "2" in "INBOX" for "user" is marked as unread
|
||||
And message "2" in "INBOX" for "user" is marked as unstarred
|
||||
And message "2" in "INBOX" for "user" is marked as undeleted
|
||||
|
||||
|
||||
51
test/features/imap/message/delete-trash.feature
Normal file
51
test/features/imap/message/delete-trash.feature
Normal file
@ -0,0 +1,51 @@
|
||||
Feature: IMAP remove messages from Trash
|
||||
Background:
|
||||
Given there is connected user "user"
|
||||
And there is "user" with mailbox "Folders/mbox"
|
||||
And there is "user" with mailbox "Labels/label"
|
||||
|
||||
Scenario Outline: Delete messages from Trash/Spam removes all labels first
|
||||
Given there are messages in mailbox "<mailbox>" for "user"
|
||||
| from | to | subject | body |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world |
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "<mailbox>"
|
||||
And IMAP client copies messages "2" to "Labels/label"
|
||||
When IMAP client marks message "2" as deleted
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "<mailbox>" for "user" has 2 messages
|
||||
And mailbox "All Mail" for "user" has 2 messages
|
||||
And mailbox "Labels/label" for "user" has 1 messages
|
||||
When IMAP client sends expunge
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "<mailbox>" for "user" has 2 messages
|
||||
And mailbox "All Mail" for "user" has 2 messages
|
||||
And mailbox "Labels/label" for "user" has 0 messages
|
||||
|
||||
Examples:
|
||||
| mailbox |
|
||||
| Spam |
|
||||
| Trash |
|
||||
|
||||
|
||||
Scenario Outline: Delete messages from Trash/Spamm deletes from All Mail
|
||||
Given there are messages in mailbox "<mailbox>" for "user"
|
||||
| from | to | subject | body |
|
||||
| john.doe@mail.com | user@pm.me | foo | hello |
|
||||
| jane.doe@mail.com | name@pm.me | bar | world |
|
||||
And there is IMAP client logged in as "user"
|
||||
And there is IMAP client selected in "<mailbox>"
|
||||
When IMAP client marks message "2" as deleted
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "<mailbox>" for "user" has 2 messages
|
||||
And mailbox "All Mail" for "user" has 2 messages
|
||||
When IMAP client sends expunge
|
||||
Then IMAP response is "OK"
|
||||
And mailbox "<mailbox>" for "user" has 1 messages
|
||||
And mailbox "All Mail" for "user" has 1 messages
|
||||
|
||||
Examples:
|
||||
| mailbox |
|
||||
| Spam |
|
||||
| Trash |
|
||||
@ -26,11 +26,10 @@ import (
|
||||
)
|
||||
|
||||
func IMAPActionsMessagesFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^IMAP client sends command "([^"]*)"$`, imapClientSendsCommand)
|
||||
s.Step(`^IMAP client fetches "([^"]*)"$`, imapClientFetches)
|
||||
s.Step(`^IMAP client fetches by UID "([^"]*)"$`, imapClientFetchesByUID)
|
||||
s.Step(`^IMAP client searches for "([^"]*)"$`, imapClientSearchesFor)
|
||||
s.Step(`^IMAP client deletes messages "([^"]*)"$`, imapClientDeletesMessages)
|
||||
s.Step(`^IMAP client "([^"]*)" deletes messages "([^"]*)"$`, imapClientNamedDeletesMessages)
|
||||
s.Step(`^IMAP client copies messages "([^"]*)" to "([^"]*)"$`, imapClientCopiesMessagesTo)
|
||||
s.Step(`^IMAP client moves messages "([^"]*)" to "([^"]*)"$`, imapClientMovesMessagesTo)
|
||||
s.Step(`^IMAP client imports message to "([^"]*)"$`, imapClientCreatesMessage)
|
||||
@ -48,8 +47,20 @@ func IMAPActionsMessagesFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^IMAP client "([^"]*)" marks message "([^"]*)" as starred$`, imapClientNamedMarksMessageAsStarred)
|
||||
s.Step(`^IMAP client marks message "([^"]*)" as unstarred$`, imapClientMarksMessageAsUnstarred)
|
||||
s.Step(`^IMAP client "([^"]*)" marks message "([^"]*)" as unstarred$`, imapClientNamedMarksMessageAsUnstarred)
|
||||
s.Step(`^IMAP client marks message "([^"]*)" as deleted$`, imapClientMarksMessageAsDeleted)
|
||||
s.Step(`^IMAP client "([^"]*)" marks message "([^"]*)" as deleted$`, imapClientNamedMarksMessageAsDeleted)
|
||||
s.Step(`^IMAP client marks message "([^"]*)" as undeleted$`, imapClientMarksMessageAsUndeleted)
|
||||
s.Step(`^IMAP client "([^"]*)" marks message "([^"]*)" as undeleted$`, imapClientNamedMarksMessageAsUndeleted)
|
||||
s.Step(`^IMAP client starts IDLE-ing$`, imapClientStartsIDLEing)
|
||||
s.Step(`^IMAP client "([^"]*)" starts IDLE-ing$`, imapClientNamedStartsIDLEing)
|
||||
s.Step(`^IMAP client sends expunge$`, imapClientExpunge)
|
||||
s.Step(`^IMAP client "([^"]*)" sends expunge$`, imapClientNamedExpunge)
|
||||
}
|
||||
|
||||
func imapClientSendsCommand(command string) error {
|
||||
res := ctx.GetIMAPClient("imap").SendCommand(command)
|
||||
ctx.SetIMAPLastResponse("imap", res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientFetches(fetchRange string) error {
|
||||
@ -70,16 +81,6 @@ func imapClientSearchesFor(query string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientDeletesMessages(messageRange string) error {
|
||||
return imapClientNamedDeletesMessages("imap", messageRange)
|
||||
}
|
||||
|
||||
func imapClientNamedDeletesMessages(imapClient, messageRange string) error {
|
||||
res := ctx.GetIMAPClient(imapClient).Delete(messageRange)
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientCopiesMessagesTo(messageRange, newMailboxName string) error {
|
||||
res := ctx.GetIMAPClient("imap").Copy(messageRange, newMailboxName)
|
||||
ctx.SetIMAPLastResponse("imap", res)
|
||||
@ -190,6 +191,26 @@ func imapClientNamedMarksMessageAsUnstarred(imapClient, messageRange string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientMarksMessageAsDeleted(messageRange string) error {
|
||||
return imapClientNamedMarksMessageAsDeleted("imap", messageRange)
|
||||
}
|
||||
|
||||
func imapClientNamedMarksMessageAsDeleted(imapClient, messageRange string) error {
|
||||
res := ctx.GetIMAPClient(imapClient).MarkAsDeleted(messageRange)
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientMarksMessageAsUndeleted(messageRange string) error {
|
||||
return imapClientNamedMarksMessageAsUndeleted("imap", messageRange)
|
||||
}
|
||||
|
||||
func imapClientNamedMarksMessageAsUndeleted(imapClient, messageRange string) error {
|
||||
res := ctx.GetIMAPClient(imapClient).MarkAsUndeleted(messageRange)
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientStartsIDLEing() error {
|
||||
return imapClientNamedStartsIDLEing("imap")
|
||||
}
|
||||
@ -199,3 +220,13 @@ func imapClientNamedStartsIDLEing(imapClient string) error {
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientExpunge() error {
|
||||
return imapClientNamedExpunge("imap")
|
||||
}
|
||||
|
||||
func imapClientNamedExpunge(imapClient string) error {
|
||||
res := ctx.GetIMAPClient(imapClient).Expunge()
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -179,10 +179,6 @@ func (c *IMAPClient) AppendBody(mailboxName, subject, from, to, body string) *IM
|
||||
return c.SendCommand(cmd)
|
||||
}
|
||||
|
||||
func (c *IMAPClient) Delete(ids string) *IMAPResponse {
|
||||
return c.AddFlags(ids, "\\Deleted")
|
||||
}
|
||||
|
||||
func (c *IMAPClient) Copy(ids, newMailboxName string) *IMAPResponse {
|
||||
return c.SendCommand(fmt.Sprintf("COPY %s \"%s\"", ids, newMailboxName))
|
||||
}
|
||||
@ -207,6 +203,14 @@ func (c *IMAPClient) MarkAsUnstarred(ids string) *IMAPResponse {
|
||||
return c.RemoveFlags(ids, "\\Flagged")
|
||||
}
|
||||
|
||||
func (c *IMAPClient) MarkAsDeleted(ids string) *IMAPResponse {
|
||||
return c.AddFlags(ids, "\\Deleted")
|
||||
}
|
||||
|
||||
func (c *IMAPClient) MarkAsUndeleted(ids string) *IMAPResponse {
|
||||
return c.RemoveFlags(ids, "\\Deleted")
|
||||
}
|
||||
|
||||
func (c *IMAPClient) SetFlags(ids, flags string) *IMAPResponse {
|
||||
return c.changeFlags(ids, flags, "")
|
||||
}
|
||||
@ -223,6 +227,10 @@ func (c *IMAPClient) changeFlags(ids, flags, op string) *IMAPResponse {
|
||||
return c.SendCommand(fmt.Sprintf("STORE %s %sflags (%s)", ids, op, flags))
|
||||
}
|
||||
|
||||
func (c *IMAPClient) Expunge() *IMAPResponse {
|
||||
return c.SendCommand("EXPUNGE")
|
||||
}
|
||||
|
||||
// IDLE
|
||||
|
||||
func (c *IMAPClient) StartIDLE() *IMAPResponse {
|
||||
|
||||
@ -42,6 +42,8 @@ func StoreChecksFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^message "([^"]*)" in "([^"]*)" for "([^"]*)" is marked as unread$`, messagesInMailboxForUserIsMarkedAsUnread)
|
||||
s.Step(`^message "([^"]*)" in "([^"]*)" for "([^"]*)" is marked as starred$`, messagesInMailboxForUserIsMarkedAsStarred)
|
||||
s.Step(`^message "([^"]*)" in "([^"]*)" for "([^"]*)" is marked as unstarred$`, messagesInMailboxForUserIsMarkedAsUnstarred)
|
||||
s.Step(`^message "([^"]*)" in "([^"]*)" for "([^"]*)" is marked as deleted$`, messagesInMailboxForUserIsMarkedAsDeleted)
|
||||
s.Step(`^message "([^"]*)" in "([^"]*)" for "([^"]*)" is marked as undeleted$`, messagesInMailboxForUserIsMarkedAsUndeleted)
|
||||
}
|
||||
|
||||
func userHasMailbox(bddUserID, mailboxName string) error {
|
||||
@ -217,6 +219,9 @@ func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []*pm
|
||||
if message.Unread != unread {
|
||||
matches = false
|
||||
}
|
||||
case "deleted":
|
||||
// TODO
|
||||
matches = false
|
||||
default:
|
||||
return false, fmt.Errorf("unexpected column name: %s", head[n].Value)
|
||||
}
|
||||
@ -277,6 +282,20 @@ func messagesInMailboxForUserIsMarkedAsUnstarred(messageIDs, mailboxName, bddUse
|
||||
})
|
||||
}
|
||||
|
||||
func messagesInMailboxForUserIsMarkedAsDeleted(messageIDs, mailboxName, bddUserID string) error {
|
||||
return checkMessages(bddUserID, mailboxName, messageIDs, func(message *pmapi.Message) error {
|
||||
// TODO
|
||||
return fmt.Errorf("TODO message %s \"%s\" is expected to be deleted but is not", message.ID, message.Subject)
|
||||
})
|
||||
}
|
||||
|
||||
func messagesInMailboxForUserIsMarkedAsUndeleted(messageIDs, mailboxName, bddUserID string) error {
|
||||
return checkMessages(bddUserID, mailboxName, messageIDs, func(message *pmapi.Message) error {
|
||||
// TODO
|
||||
return fmt.Errorf("TODO message %s \"%s\" is expected to not be deleted but is", message.ID, message.Subject)
|
||||
})
|
||||
}
|
||||
|
||||
func checkMessages(bddUserID, mailboxName, messageIDs string, callback func(*pmapi.Message) error) error {
|
||||
account := ctx.GetTestAccount(bddUserID)
|
||||
if account == nil {
|
||||
|
||||
@ -80,12 +80,13 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
return godog.ErrPending
|
||||
}
|
||||
head := messages.Rows[0].Cells
|
||||
for i := 1; i < len(messages.Rows); i++ {
|
||||
labelIDs, err := ctx.GetPMAPIController().GetLabelIDs(account.Username(), strings.Split(mailboxNames, ","))
|
||||
if err != nil {
|
||||
return internalError(err, "getting labels %s for %s", mailboxNames, account.Username())
|
||||
}
|
||||
|
||||
labelIDs, err := ctx.GetPMAPIController().GetLabelIDs(account.Username(), strings.Split(mailboxNames, ","))
|
||||
if err != nil {
|
||||
return internalError(err, "getting labels %s for %s", mailboxNames, account.Username())
|
||||
}
|
||||
|
||||
for _, row := range messages.Rows {
|
||||
message := &pmapi.Message{
|
||||
MIMEType: "text/plain",
|
||||
LabelIDs: labelIDs,
|
||||
@ -96,7 +97,7 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
message.Flags |= pmapi.FlagSent
|
||||
}
|
||||
|
||||
for n, cell := range messages.Rows[i].Cells {
|
||||
for n, cell := range row.Cells {
|
||||
switch head[n].Value {
|
||||
case "from":
|
||||
message.Sender = &mail.Address{
|
||||
@ -132,6 +133,12 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
return internalError(err, "parsing time")
|
||||
}
|
||||
message.Time = date.Unix()
|
||||
case "deleted":
|
||||
if cell.Value == "true" {
|
||||
/* TODO
|
||||
Remember that this message should be marked as deleted
|
||||
*/
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unexpected column name: %s", head[n].Value)
|
||||
}
|
||||
@ -140,6 +147,11 @@ func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bdd
|
||||
return internalError(err, "adding message")
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
storeMailbox.MarkMessageAsDeleted(msgID)
|
||||
*/
|
||||
|
||||
return internalError(ctx.WaitForSync(account.Username()), "waiting for sync")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user