fix: missing messages after changing primary address

This commit is contained in:
James Houlahan
2020-05-06 10:34:32 +02:00
parent 2d200f6f8c
commit 4b2977041a
11 changed files with 62 additions and 18 deletions

View File

@ -55,7 +55,7 @@ func (a *TestAccounts) GetTestAccount(username string) *TestAccount {
return a.GetTestAccountWithAddress(username, "")
}
// GetTestAccount returns the test account with the given username configured to use the given bddAddressID.
// GetTestAccountWithAddress returns the test account with the given username configured to use the given bddAddressID.
func (a *TestAccounts) GetTestAccountWithAddress(username, bddAddressID string) *TestAccount {
// Do lookup by full address and convert to name in tests.
// Used by getting real data to ensure correct address or address ID.

View File

@ -142,9 +142,9 @@ func swapsAddressWithAddress(bddUserID, bddAddressID1, bddAddressID2 string) err
address1ID := account.GetAddressID(bddAddressID1)
address2ID := account.GetAddressID(bddAddressID2)
addressIDs := make([]string, len(*account.Addresses()))
var address1Index, address2Index int
var addressIDs []string
for i, v := range *account.Addresses() {
if v.ID == address1ID {
address1Index = i
@ -152,13 +152,12 @@ func swapsAddressWithAddress(bddUserID, bddAddressID1, bddAddressID2 string) err
if v.ID == address2ID {
address2Index = i
}
addressIDs = append(addressIDs, v.ID)
addressIDs[i] = v.ID
}
addressIDs[address1Index], addressIDs[address2Index] = addressIDs[address2Index], addressIDs[address1Index]
ctx.ReorderAddresses(account.Username(), bddAddressID1, bddAddressID2)
ctx.GetPMAPIController().ReorderAddresses(account.User(), addressIDs)
return nil
return ctx.GetPMAPIController().ReorderAddresses(account.User(), addressIDs)
}

View File

@ -113,7 +113,7 @@ func (api *FakePMAPI) addEventAddress(action pmapi.EventAction, address *pmapi.A
Addresses: []*pmapi.EventAddress{{
EventItem: pmapi.EventItem{
ID: address.ID,
Action: pmapi.EventUpdate,
Action: action,
},
Address: address,
}},

View File

@ -47,9 +47,30 @@ Feature: Address mode
Scenario: Make secondary address primary in combined mode
Given there is "userMoreAddresses" in "combined" address mode
When "userMoreAddresses" swaps address "primary" with address "secondary"
And "userMoreAddresses" receives an address event
Then mailbox "Folders/mbox" for address "primary" of "userMoreAddresses" has messages
| from | to | subject |
| john.doe@mail.com | [primary] | foo |
| jane.doe@mail.com | [secondary] | bar |
When "userMoreAddresses" swaps address "primary" with address "secondary"
And "userMoreAddresses" receives an address event
Then mailbox "Folders/mbox" for address "primary" of "userMoreAddresses" has messages
| from | to | subject |
| john.doe@mail.com | [secondary] | foo |
| jane.doe@mail.com | [primary] | bar |
Scenario: Make secondary address primary in split mode
Given there is "userMoreAddresses" in "split" address mode
Then mailbox "Folders/mbox" for address "primary" of "userMoreAddresses" has messages
| from | to | subject |
| john.doe@mail.com | [primary] | foo |
And mailbox "Folders/mbox" for address "secondary" of "userMoreAddresses" has messages
| from | to | subject |
| jane.doe@mail.com | [secondary] | bar |
When "userMoreAddresses" swaps address "primary" with address "secondary"
And "userMoreAddresses" receives an address event
Then mailbox "Folders/mbox" for address "primary" of "userMoreAddresses" has messages
| from | to | subject |
| jane.doe@mail.com | [primary] | bar |
And mailbox "Folders/mbox" for address "secondary" of "userMoreAddresses" has messages
| from | to | subject |
| john.doe@mail.com | [secondary] | foo |