diff --git a/core/models/groups_test.go b/core/models/groups_test.go index b4339dc73..8917aa77b 100644 --- a/core/models/groups_test.go +++ b/core/models/groups_test.go @@ -35,22 +35,23 @@ func TestLoadGroups(t *testing.T) { require.NoError(t, err) tcs := []struct { - ID models.GroupID - UUID assets.GroupUUID - Name string - Query string + id models.GroupID + uuid assets.GroupUUID + name string + query string }{ {testdata.DoctorsGroup.ID, testdata.DoctorsGroup.UUID, "Doctors", ""}, + {testdata.OpenTicketsGroup.ID, testdata.OpenTicketsGroup.UUID, "Open Tickets", "tickets > 0"}, {testdata.TestersGroup.ID, testdata.TestersGroup.UUID, "Testers", ""}, } - assert.Equal(t, 2, len(groups)) + assert.Equal(t, 3, len(groups)) for i, tc := range tcs { group := groups[i].(*models.Group) - assert.Equal(t, tc.UUID, group.UUID()) - assert.Equal(t, tc.ID, group.ID()) - assert.Equal(t, tc.Name, group.Name()) - assert.Equal(t, tc.Query, group.Query()) + assert.Equal(t, tc.uuid, group.UUID()) + assert.Equal(t, tc.id, group.ID()) + assert.Equal(t, tc.name, group.Name()) + assert.Equal(t, tc.query, group.Query()) } } diff --git a/core/models/search_test.go b/core/models/search_test.go index 19f85dd80..16a5bc2de 100644 --- a/core/models/search_test.go +++ b/core/models/search_test.go @@ -43,7 +43,7 @@ func TestGetContactIDsForQueryPage(t *testing.T) { ExpectedError string }{ { - Group: testdata.AllContactsGroup.UUID, + Group: testdata.ActiveGroup.UUID, Query: "george", ExpectedESRequest: `{ "_source": false, @@ -63,7 +63,7 @@ func TestGetContactIDsForQueryPage(t *testing.T) { }, { "term": { - "groups": "d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008" + "groups": "b97f69f7-5edf-45c7-9fda-d37066eae91d" } }, { @@ -117,7 +117,7 @@ func TestGetContactIDsForQueryPage(t *testing.T) { ExpectedTotal: 1, }, { - Group: testdata.BlockedContactsGroup.UUID, + Group: testdata.BlockedGroup.UUID, ExcludeIDs: []models.ContactID{testdata.Bob.ID, testdata.Cathy.ID}, Query: "age > 32", Sort: "-age", @@ -139,7 +139,7 @@ func TestGetContactIDsForQueryPage(t *testing.T) { }, { "term": { - "groups": "9295ebab-5c2d-4eb1-86f9-7c15ed2f3219" + "groups": "14f6ea01-456b-4417-b0b8-35e942f549f1" } }, { diff --git a/core/models/tickets_test.go b/core/models/tickets_test.go index 10eaeb4ce..c541de906 100644 --- a/core/models/tickets_test.go +++ b/core/models/tickets_test.go @@ -282,8 +282,6 @@ func TestCloseTickets(t *testing.T) { }, })) - testdata.InsertContactGroup(db, testdata.Org1, "94c816d7-cc87-42db-a577-ce072ceaab80", "Tickets", "tickets > 0") - oa, err := models.GetOrgAssetsWithRefresh(ctx, rt, testdata.Org1.ID, models.RefreshTicketers|models.RefreshGroups) require.NoError(t, err) @@ -299,7 +297,7 @@ func TestCloseTickets(t *testing.T) { require.NoError(t, err) assert.Equal(t, "Doctors", cathy.Groups().All()[0].Name()) - assert.Equal(t, "Tickets", cathy.Groups().All()[1].Name()) + assert.Equal(t, "Open Tickets", cathy.Groups().All()[1].Name()) logger := &models.HTTPLogger{} evts, err := models.CloseTickets(ctx, rt, oa, testdata.Admin.ID, []*models.Ticket{modelTicket1, modelTicket2}, true, false, logger) @@ -354,8 +352,6 @@ func TestReopenTickets(t *testing.T) { }, })) - testdata.InsertContactGroup(db, testdata.Org1, "94c816d7-cc87-42db-a577-ce072ceaab80", "Two Tickets", "tickets = 2") - oa, err := models.GetOrgAssetsWithRefresh(ctx, rt, testdata.Org1.ID, models.RefreshTicketers|models.RefreshGroups) require.NoError(t, err) @@ -385,9 +381,9 @@ func TestReopenTickets(t *testing.T) { // but no events for ticket #2 which waas already open assertdb.Query(t, db, `SELECT count(*) FROM tickets_ticketevent WHERE ticket_id = $1 AND event_type = 'R'`, ticket2.ID).Returns(0) - // check Cathy is now in the two tickets group + // check Cathy is now in the open tickets group _, cathy := testdata.Cathy.Load(db, oa) assert.Equal(t, 2, len(cathy.Groups().All())) assert.Equal(t, "Doctors", cathy.Groups().All()[0].Name()) - assert.Equal(t, "Two Tickets", cathy.Groups().All()[1].Name()) + assert.Equal(t, "Open Tickets", cathy.Groups().All()[1].Name()) } diff --git a/mailroom_test.dump b/mailroom_test.dump index d0defeec0..3e39779eb 100644 Binary files a/mailroom_test.dump and b/mailroom_test.dump differ diff --git a/testsuite/testdata/constants.go b/testsuite/testdata/constants.go index 0722cea89..29718067a 100644 --- a/testsuite/testdata/constants.go +++ b/testsuite/testdata/constants.go @@ -27,21 +27,25 @@ var IncomingExtraFlow = &Flow{10006, "376d3de6-7f0e-408c-80d6-b1919738bc80"} var ParentTimeoutFlow = &Flow{10007, "81c0f323-7e06-4e0c-a960-19c20f17117c"} var CampaignFlow = &Flow{10009, "3a92a964-3a8d-420b-9206-2cd9d884ac30"} -var CreatedOnField = &Field{3, "53499958-0a0a-48a5-bb5f-8f9f4d8af77b"} -var LastSeenOnField = &Field{5, "4307df2e-b00b-42b6-922b-4a1dcfc268d8"} +var CreatedOnField = &Field{3, "fd18a69d-7514-4b76-9fad-072641995e17"} +var LanguageField = &Field{4, "4307df2e-b00b-42b6-922b-4a1dcfc268d8"} +var LastSeenOnField = &Field{5, "660ebe03-b717-4a80-aebf-9b7c718266e1"} var GenderField = &Field{6, "3a5891e4-756e-4dc9-8e12-b7a766168824"} var AgeField = &Field{7, "903f51da-2717-47c7-a0d3-f2f32877013d"} var JoinedField = &Field{8, "d83aae24-4bbf-49d0-ab85-6bfd201eac6d"} -var AllContactsGroup = &Group{1, "d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008"} -var BlockedContactsGroup = &Group{2, "9295ebab-5c2d-4eb1-86f9-7c15ed2f3219"} +var ActiveGroup = &Group{1, "b97f69f7-5edf-45c7-9fda-d37066eae91d"} +var BlockedGroup = &Group{2, "14f6ea01-456b-4417-b0b8-35e942f549f1"} +var StoppedGroup = &Group{3, "d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008"} +var ArchivedGroup = &Group{4, "9295ebab-5c2d-4eb1-86f9-7c15ed2f3219"} +var OpenTicketsGroup = &Group{5, "361838c4-2866-495a-8990-9f3c222a7604"} var DoctorsGroup = &Group{10000, "c153e265-f7c9-4539-9dbc-9b358714b638"} var TestersGroup = &Group{10001, "5e9d8fab-5e7e-4f51-b533-261af5dea70d"} var ReportingLabel = &Label{10000, "ebc4dedc-91c4-4ed4-9dd6-daa05ea82698"} var TestingLabel = &Label{10001, "a6338cdc-7938-4437-8b05-2d5d785e3a08"} -var DefaultTopic = &Topic{1, "ffc903f7-8cbb-443f-9627-87106842d1aa"} +var DefaultTopic = &Topic{1, "5cc1848a-357c-4de9-9720-45770ec18d11"} var SalesTopic = &Topic{2, "9ef2ff21-064a-41f1-8560-ccc990b4f937"} var SupportTopic = &Topic{3, "0a8f2e00-fef6-402c-bd79-d789446ec0e0"} diff --git a/web/contact/search_test.go b/web/contact/search_test.go index 2ff3871ea..9966bee1e 100644 --- a/web/contact/search_test.go +++ b/web/contact/search_test.go @@ -99,21 +99,21 @@ func TestSearch(t *testing.T) { { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "birthday = tomorrow", "group_uuid": "%s"}`, testdata.AllContactsGroup.UUID), + body: fmt.Sprintf(`{"org_id": 1, "query": "birthday = tomorrow", "group_uuid": "%s"}`, testdata.ActiveGroup.UUID), expectedStatus: 400, expectedError: "can't resolve 'birthday' to attribute, scheme or field", }, { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "age > tomorrow", "group_uuid": "%s"}`, testdata.AllContactsGroup.UUID), + body: fmt.Sprintf(`{"org_id": 1, "query": "age > tomorrow", "group_uuid": "%s"}`, testdata.ActiveGroup.UUID), expectedStatus: 400, expectedError: "can't convert 'tomorrow' to a number", }, { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "Cathy", "group_uuid": "%s"}`, testdata.AllContactsGroup.UUID), + body: fmt.Sprintf(`{"org_id": 1, "query": "Cathy", "group_uuid": "%s"}`, testdata.ActiveGroup.UUID), esResponse: singleESResponse, expectedStatus: 200, expectedHits: []models.ContactID{testdata.Cathy.ID}, @@ -126,7 +126,7 @@ func TestSearch(t *testing.T) { { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "Cathy", "group_uuid": "%s", "exclude_ids": [%d, %d]}`, testdata.AllContactsGroup.UUID, testdata.Bob.ID, testdata.George.ID), + body: fmt.Sprintf(`{"org_id": 1, "query": "Cathy", "group_uuid": "%s", "exclude_ids": [%d, %d]}`, testdata.ActiveGroup.UUID, testdata.Bob.ID, testdata.George.ID), esResponse: singleESResponse, expectedStatus: 200, expectedHits: []models.ContactID{testdata.Cathy.ID}, @@ -153,7 +153,7 @@ func TestSearch(t *testing.T) { }, { "term": { - "groups": "d1ee73f0-bdb5-47ce-99dd-0c95d4ebf008" + "groups": "b97f69f7-5edf-45c7-9fda-d37066eae91d" } }, { @@ -188,7 +188,7 @@ func TestSearch(t *testing.T) { { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "AGE = 10 and gender = M", "group_uuid": "%s"}`, testdata.AllContactsGroup.UUID), + body: fmt.Sprintf(`{"org_id": 1, "query": "AGE = 10 and gender = M", "group_uuid": "%s"}`, testdata.ActiveGroup.UUID), esResponse: singleESResponse, expectedStatus: 200, expectedHits: []models.ContactID{testdata.Cathy.ID}, @@ -204,7 +204,7 @@ func TestSearch(t *testing.T) { { method: "POST", url: "/mr/contact/search", - body: fmt.Sprintf(`{"org_id": 1, "query": "", "group_uuid": "%s"}`, testdata.AllContactsGroup.UUID), + body: fmt.Sprintf(`{"org_id": 1, "query": "", "group_uuid": "%s"}`, testdata.ActiveGroup.UUID), esResponse: singleESResponse, expectedStatus: 200, expectedHits: []models.ContactID{testdata.Cathy.ID},