Saved filters (#655)
Fix updating saved filters Fix filter not loadable because of missing param declaration Add fancy special cases for postgres exists in db Add special case for postgrs json Add read one test Add rights tests Fix lint Fixed getting a single saved filter from db Add tests for the usual crud methods Add test stubs and TODOs Add test for converting saved filter ids to list ids and vice versa Add test fixture for saved filters and fix existing tests Fix exposed json variables of filters Fix creating saved filters table for tests Add getting saved filters as pseudo namespace Cleanup Refactor getting all namespaces to use a map for easier handling of pseudo namespaces Add custom erros for saved filters Swagger docs Fix lint Add routes for saved filters Add alias for mage build Add method to get a saved filter from the lists endpoint Add getting tasks from a saved filter Add create, update, delete, read one methods Add rights methods for saved filters Fix docs minLength Add saved filters column Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/655 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -142,12 +142,13 @@ func TestNamespace_ReadAll(t *testing.T) {
|
||||
t.Run("normal", func(t *testing.T) {
|
||||
n := &Namespace{}
|
||||
nn, _, _, err := n.ReadAll(user1, "", 1, -1)
|
||||
namespaces := nn.([]*NamespaceWithLists)
|
||||
assert.NoError(t, err)
|
||||
namespaces := nn.([]*NamespaceWithLists)
|
||||
assert.NotNil(t, namespaces)
|
||||
assert.Len(t, namespaces, 10) // Total of 10 including shared & favorites
|
||||
assert.Equal(t, int64(-2), namespaces[0].ID) // The first one should be the one with favorites
|
||||
assert.Equal(t, int64(-1), namespaces[1].ID) // The second one should be the one with the shared namespaces
|
||||
assert.Len(t, namespaces, 11) // Total of 10 including shared, favorites and saved filters
|
||||
assert.Equal(t, int64(-3), namespaces[0].ID) // The first one should be the one with shared filters
|
||||
assert.Equal(t, int64(-2), namespaces[1].ID) // The second one should be the one with favorites
|
||||
assert.Equal(t, int64(-1), namespaces[2].ID) // The third one should be the one with the shared namespaces
|
||||
// Ensure every list and namespace are not archived
|
||||
for _, namespace := range namespaces {
|
||||
assert.False(t, namespace.IsArchived)
|
||||
@ -164,9 +165,10 @@ func TestNamespace_ReadAll(t *testing.T) {
|
||||
namespaces := nn.([]*NamespaceWithLists)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, namespaces)
|
||||
assert.Len(t, namespaces, 11) // Total of 11 including shared & favorites, one is archived
|
||||
assert.Equal(t, int64(-2), namespaces[0].ID) // The first one should be the one with favorites
|
||||
assert.Equal(t, int64(-1), namespaces[1].ID) // The second one should be the one with the shared namespaces
|
||||
assert.Len(t, namespaces, 12) // Total of 12 including shared & favorites, one is archived
|
||||
assert.Equal(t, int64(-3), namespaces[0].ID) // The first one should be the one with shared filters
|
||||
assert.Equal(t, int64(-2), namespaces[1].ID) // The second one should be the one with favorites
|
||||
assert.Equal(t, int64(-1), namespaces[2].ID) // The third one should be the one with the shared namespaces
|
||||
})
|
||||
t.Run("no favorites", func(t *testing.T) {
|
||||
n := &Namespace{}
|
||||
@ -185,4 +187,12 @@ func TestNamespace_ReadAll(t *testing.T) {
|
||||
assert.Equal(t, FavoritesPseudoNamespace.ID, namespaces[0].ID)
|
||||
assert.NotEqual(t, 0, namespaces[0].Lists)
|
||||
})
|
||||
t.Run("no saved filters", func(t *testing.T) {
|
||||
n := &Namespace{}
|
||||
nn, _, _, err := n.ReadAll(user11, "", 1, -1)
|
||||
namespaces := nn.([]*NamespaceWithLists)
|
||||
assert.NoError(t, err)
|
||||
// Assert the first namespace is not the favorites namespace
|
||||
assert.NotEqual(t, SavedFiltersPseudoNamespace.ID, namespaces[0].ID)
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user