test: update expected results for archived project propagation
Adjust test assertions to reflect that projects inheriting archived state from parents are now correctly filtered out of ReadAll results, task collections, and search results across all database backends.
This commit is contained in:
parent
e3045dfd00
commit
13be01de9f
|
|
@ -115,16 +115,6 @@ func TestLabel_ReadAll(t *testing.T) {
|
|||
CreatedBy: user2,
|
||||
},
|
||||
},
|
||||
{
|
||||
Label: Label{
|
||||
ID: 5,
|
||||
Title: "Label #5",
|
||||
CreatedByID: 2,
|
||||
CreatedBy: user2,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -504,12 +504,12 @@ func TestProject_ReadAll(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, reflect.Slice, reflect.TypeOf(projects3).Kind())
|
||||
ls := projects3.([]*Project)
|
||||
assert.Len(t, ls, 29)
|
||||
assert.Len(t, ls, 27)
|
||||
assert.Equal(t, int64(3), ls[0].ID) // Project 3 has a position of 1 and should be sorted first
|
||||
assert.Equal(t, int64(1), ls[1].ID)
|
||||
assert.Equal(t, int64(6), ls[2].ID)
|
||||
assert.Equal(t, int64(-1), ls[27].ID)
|
||||
assert.Equal(t, int64(-2), ls[28].ID)
|
||||
assert.Equal(t, int64(-1), ls[25].ID)
|
||||
assert.Equal(t, int64(-2), ls[26].ID)
|
||||
})
|
||||
t.Run("projects for nonexistent user", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
|
|
|
|||
|
|
@ -89,14 +89,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
label5 := &Label{
|
||||
ID: 5,
|
||||
Title: "Label #5",
|
||||
CreatedByID: 2,
|
||||
CreatedBy: user2,
|
||||
Created: testCreatedTime,
|
||||
Updated: testUpdatedTime,
|
||||
}
|
||||
|
||||
// We use individual variables for the tasks here to be able to rearrange or remove ones more easily
|
||||
task1 := &Task{
|
||||
|
|
@ -602,50 +594,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
Created: time.Unix(1543626724, 0).In(loc),
|
||||
Updated: time.Unix(1543626724, 0).In(loc),
|
||||
}
|
||||
task35 := &Task{
|
||||
ID: 35,
|
||||
Title: "task #35",
|
||||
Identifier: "test21-1",
|
||||
Index: 1,
|
||||
CreatedByID: 1,
|
||||
CreatedBy: user1,
|
||||
ProjectID: 21,
|
||||
Assignees: []*user.User{
|
||||
user2,
|
||||
},
|
||||
Labels: []*Label{
|
||||
label4,
|
||||
label5,
|
||||
},
|
||||
RelatedTasks: map[RelationKind][]*Task{
|
||||
RelationKindRelated: {
|
||||
{
|
||||
ID: 1,
|
||||
Title: "task #1",
|
||||
Description: "Lorem Ipsum",
|
||||
Index: 1,
|
||||
CreatedByID: 1,
|
||||
ProjectID: 1,
|
||||
IsFavorite: true,
|
||||
Created: time.Unix(1543626724, 0).In(loc),
|
||||
Updated: time.Unix(1543626724, 0).In(loc),
|
||||
},
|
||||
{
|
||||
ID: 1,
|
||||
Title: "task #1",
|
||||
Description: "Lorem Ipsum",
|
||||
Index: 1,
|
||||
CreatedByID: 1,
|
||||
ProjectID: 1,
|
||||
IsFavorite: true,
|
||||
Created: time.Unix(1543626724, 0).In(loc),
|
||||
Updated: time.Unix(1543626724, 0).In(loc),
|
||||
},
|
||||
},
|
||||
},
|
||||
Created: time.Unix(1543626724, 0).In(loc),
|
||||
Updated: time.Unix(1543626724, 0).In(loc),
|
||||
}
|
||||
task39 := &Task{
|
||||
ID: 39,
|
||||
Title: "task #39",
|
||||
|
|
@ -775,7 +723,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task39,
|
||||
task47,
|
||||
task48,
|
||||
|
|
@ -822,7 +769,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task39,
|
||||
task47,
|
||||
task48,
|
||||
|
|
@ -840,7 +786,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
want: []*Task{
|
||||
task48,
|
||||
task47,
|
||||
task35,
|
||||
task33,
|
||||
task32,
|
||||
task31,
|
||||
|
|
@ -990,7 +935,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task47,
|
||||
task48,
|
||||
},
|
||||
|
|
@ -1057,7 +1001,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31, // has nil dates
|
||||
task32, // has nil dates
|
||||
task33, // has nil dates
|
||||
task35, // has nil dates
|
||||
task39, // has nil dates
|
||||
task47, // has nil dates
|
||||
task48, // has nil dates
|
||||
|
|
@ -1231,7 +1174,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task39,
|
||||
task47,
|
||||
task48,
|
||||
|
|
@ -1275,7 +1217,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
args: defaultArgs,
|
||||
want: []*Task{
|
||||
task30,
|
||||
task35,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
|
@ -1327,7 +1268,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task39,
|
||||
task47,
|
||||
task48,
|
||||
|
|
@ -1351,7 +1291,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
args: defaultArgs,
|
||||
want: []*Task{
|
||||
task30,
|
||||
task35,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
|
@ -1364,7 +1303,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
want: []*Task{
|
||||
task1,
|
||||
task2,
|
||||
task35,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
|
|
@ -1405,7 +1343,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task31,
|
||||
task32,
|
||||
task33,
|
||||
task35,
|
||||
task39,
|
||||
task47,
|
||||
task48,
|
||||
|
|
@ -1511,10 +1448,8 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
fields: fields{
|
||||
Filter: "labels = 4 && labels = 5",
|
||||
},
|
||||
args: defaultArgs,
|
||||
want: []*Task{
|
||||
task35, // only task with both labels 4 and 5
|
||||
},
|
||||
args: defaultArgs,
|
||||
want: []*Task{},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
|
@ -1671,7 +1606,6 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
|||
task48,
|
||||
task47,
|
||||
task39,
|
||||
task35,
|
||||
task33,
|
||||
task32,
|
||||
task31,
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ func TestProject(t *testing.T) {
|
|||
assert.Contains(t, rec.Body.String(), `Test3`) // Shared directly via users_project
|
||||
assert.Contains(t, rec.Body.String(), `Test12`) // Shared via parent project
|
||||
assert.NotContains(t, rec.Body.String(), `Test5`)
|
||||
assert.NotContains(t, rec.Body.String(), `Test21`) // Archived through parent project
|
||||
assert.NotContains(t, rec.Body.String(), `Test22`) // Archived directly
|
||||
})
|
||||
t.Run("Search", func(t *testing.T) {
|
||||
|
|
@ -60,7 +61,7 @@ func TestProject(t *testing.T) {
|
|||
// ParadeDB fuzzy(1, prefix=true) on "Test1" matches Test2-Test9
|
||||
// (edit distance 1), Test10+ (prefix), etc. The recursive CTE
|
||||
// also pulls in child projects of matched parents.
|
||||
require.Len(t, projects, 28)
|
||||
require.Len(t, projects, 26)
|
||||
} else {
|
||||
// ILIKE '%Test1%' matches Test1, Test10, Test11, Test19, + favorites
|
||||
require.Len(t, projects, 5)
|
||||
|
|
@ -80,6 +81,15 @@ func TestProject(t *testing.T) {
|
|||
assert.NotContains(t, rec.Body.String(), `Test5`)
|
||||
assert.Contains(t, rec.Body.String(), `Test21`) // Archived through project
|
||||
assert.Contains(t, rec.Body.String(), `Test22`) // Archived directly
|
||||
|
||||
// Verify is_archived is propagated to child projects of archived parents
|
||||
var projects []models.Project
|
||||
require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &projects))
|
||||
for _, p := range projects {
|
||||
if p.ID == 21 {
|
||||
assert.True(t, p.IsArchived, "Project 21 should have is_archived=true because its parent is archived")
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
t.Run("ReadOne", func(t *testing.T) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue