forked from Silverfish/proton-bridge
GODT-2226: Fix moving drafts to trash
Only handle draft updates if the event was a message update. Also includes Gluon update.
This commit is contained in:
@ -121,6 +121,7 @@ func TestFeatures(testingT *testing.T) {
|
||||
ctx.Step(`^the address "([^"]*)" of account "([^"]*)" has the following messages in "([^"]*)":$`, s.theAddressOfAccountHasTheFollowingMessagesInMailbox)
|
||||
ctx.Step(`^the address "([^"]*)" of account "([^"]*)" has (\d+) messages in "([^"]*)"$`, s.theAddressOfAccountHasMessagesInMailbox)
|
||||
ctx.Step(`^the following fields were changed in draft (\d+) for address "([^"]*)" of account "([^"]*)":$`, s.theFollowingFieldsWereChangedInDraftForAddressOfAccount)
|
||||
ctx.Step(`^draft (\d+) for address "([^"]*)" of account "([^"]*) was moved to trash$`, s.drafAtIndexWasMovedToTrashForAddressOfAccount)
|
||||
|
||||
// === REPORTER ===
|
||||
ctx.Step(`^test skips reporter checks$`, s.skipReporterChecks)
|
||||
|
||||
@ -44,3 +44,10 @@ Feature: IMAP Draft messages
|
||||
| someone@example.com | Basic Draft | This is a draft body, but longer |
|
||||
And IMAP client "1" sees 1 messages in "Drafts"
|
||||
|
||||
Scenario: Draft moved to trash remotely
|
||||
When draft 1 for address "[user:user]@[domain]" of account "[user:user] was moved to trash
|
||||
Then IMAP client "1" eventually sees the following messages in "Trash":
|
||||
| body |
|
||||
| This is a dra |
|
||||
And IMAP client "1" sees 0 messages in "Drafts"
|
||||
|
||||
|
||||
@ -297,6 +297,29 @@ func (s *scenario) theFollowingFieldsWereChangedInDraftForAddressOfAccount(draft
|
||||
})
|
||||
}
|
||||
|
||||
func (s *scenario) drafAtIndexWasMovedToTrashForAddressOfAccount(draftIndex int, address, username string) error {
|
||||
draftID, err := s.t.getDraftID(username, draftIndex)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get draft ID: %w", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
return s.t.withClient(ctx, username, func(ctx context.Context, c *proton.Client) error {
|
||||
return s.t.withAddrKR(ctx, c, username, s.t.getUserAddrID(s.t.getUserID(username), address), func(_ context.Context, addrKR *crypto.KeyRing) error {
|
||||
if err := c.UnlabelMessages(ctx, []string{draftID}, proton.DraftsLabel); err != nil {
|
||||
return fmt.Errorf("failed to unlabel draft")
|
||||
}
|
||||
if err := c.LabelMessages(ctx, []string{draftID}, proton.TrashLabel); err != nil {
|
||||
return fmt.Errorf("failed to label draft to trah")
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (s *scenario) userLogsInWithUsernameAndPassword(username, password string) error {
|
||||
userID, err := s.t.bridge.LoginFull(context.Background(), username, []byte(password), nil, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user