Albums: Refresh updated timestamp when photos are added (#3566)
Related Issue: - #3080
This commit is contained in:
parent
ff25b5f755
commit
1df12bd5c9
8 changed files with 162 additions and 6 deletions
|
@ -76,7 +76,7 @@
|
|||
flat solo hide-details
|
||||
color="secondary-dark"
|
||||
background-color="secondary"
|
||||
:items="options.sorting"
|
||||
:items="context === 'album' ? options.sorting : options.sorting.filter(item => item.value !== 'edited')"
|
||||
@change="(v) => {updateQuery({'order': v})}">
|
||||
</v-select>
|
||||
</v-flex>
|
||||
|
@ -346,7 +346,7 @@ export default {
|
|||
{value: 'newest', text: this.$gettext('Newest First')},
|
||||
{value: 'oldest', text: this.$gettext('Oldest First')},
|
||||
{value: 'added', text: this.$gettext('Recently Added')},
|
||||
{value: 'edited', text: this.$gettext('Recently Edited')},
|
||||
{value: 'edited', text: this.$gettext('Recently Edited')}
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -275,3 +275,11 @@ test.meta("testID", "albums-007").meta({ type: "short", mode: "public" })(
|
|||
await page.testCreateEditDeleteSharingLink("albums");
|
||||
}
|
||||
);
|
||||
|
||||
test.meta("testID", "albums-008").meta({ type: "short", mode: "public" })(
|
||||
"Common: Verify album sort options",
|
||||
async (t) => {
|
||||
await menu.openPage("albums");
|
||||
await album.checkSortOptions("album");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -161,3 +161,11 @@ test.meta("testID", "calendar-004").meta({ type: "short", mode: "public" })(
|
|||
await photo.checkPhotoVisibility(SecondPhotoUid, true);
|
||||
}
|
||||
);
|
||||
|
||||
test.meta("testID", "calendar-005").meta({ type: "short", mode: "public" })(
|
||||
"Common: Verify calendar sort options",
|
||||
async (t) => {
|
||||
await menu.openPage("calendar");
|
||||
await album.checkSortOptions("calendar");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -169,3 +169,11 @@ test.meta("testID", "folders-004").meta({ mode: "public" })(
|
|||
await photo.checkPhotoVisibility(FirstPhotoUid, true);
|
||||
}
|
||||
);
|
||||
|
||||
test.meta("testID", "folders-005").meta({ type: "short", mode: "public" })(
|
||||
"Common: Verify folder sort options",
|
||||
async (t) => {
|
||||
await menu.openPage("folders");
|
||||
await album.checkSortOptions("folder");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -155,3 +155,11 @@ test.meta("testID", "moments-003").meta({ mode: "public" })(
|
|||
await photo.checkPhotoVisibility(SecondPhotoUid, true);
|
||||
}
|
||||
);
|
||||
|
||||
test.meta("testID", "moments-004").meta({ type: "short", mode: "public" })(
|
||||
"Common: Verify moment sort options",
|
||||
async (t) => {
|
||||
await menu.openPage("moments");
|
||||
await album.checkSortOptions("moment");
|
||||
}
|
||||
);
|
||||
|
|
|
@ -150,4 +150,18 @@ export default class Page {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
async checkSortOptions(type) {
|
||||
await t.click(Selector(".p-expand-search"));
|
||||
await t.click(Selector(".p-sort-select"));
|
||||
await t.expect(Selector(".v-menu__content:first-of-type").visible).ok();
|
||||
|
||||
const sortOptionsCount = Selector(".v-menu__content:first-of-type div[role=listitem]").count;
|
||||
|
||||
if (type === "album") {
|
||||
await t.expect(sortOptionsCount).eql(7);
|
||||
} else {
|
||||
await t.expect(sortOptionsCount).eql(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -830,7 +830,12 @@ func (m *Album) RemovePhotos(UIDs []string) (removed PhotoAlbums) {
|
|||
removed = append(removed, entry)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Refresh updated timestamp.
|
||||
if err := UpdateAlbum(m.AlbumUID, Values{"updated_at": TimePointer()}); err != nil {
|
||||
log.Errorf("album: %s (update %s)", err.Error(), m)
|
||||
}
|
||||
|
||||
return removed
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package entity
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -178,8 +179,23 @@ func TestAddPhotoToAlbums(t *testing.T) {
|
|||
t.Error("at least one album entry expected")
|
||||
}
|
||||
|
||||
// t.Logf("photo album entries: %+v", entries)
|
||||
})
|
||||
var album Album
|
||||
if err = Db().Where("album_uid = ?", "at6axuzitogaaiax").Find(
|
||||
&album,
|
||||
).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
photo_updatedAt := strings.Split(entries[0].UpdatedAt.String(), ".")[0]
|
||||
album_updatedAt := strings.Split(album.UpdatedAt.String(), ".")[0]
|
||||
|
||||
assert.Truef(
|
||||
t, photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" new photos are added",
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
t.Run("empty photo", func(t *testing.T) {
|
||||
err := AddPhotoToAlbums("", []string{"at6axuzitogaaiax"})
|
||||
|
@ -216,7 +232,21 @@ func TestAddPhotoToAlbums(t *testing.T) {
|
|||
t.Error("at least one album entry expected")
|
||||
}
|
||||
|
||||
// t.Logf("photo album entries: %+v", entries)
|
||||
var album Album
|
||||
if err = Db().Where("album_uid = ?", "at6axuzitogaaiax").Find(
|
||||
&album,
|
||||
).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
photo_updatedAt := strings.Split(entries[0].UpdatedAt.String(), ".")[0]
|
||||
album_updatedAt := strings.Split(album.UpdatedAt.String(), ".")[0]
|
||||
|
||||
assert.Truef(
|
||||
t, photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" new photos are added",
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -489,6 +519,43 @@ func TestAlbum_AddPhotos(t *testing.T) {
|
|||
AlbumTitle: "Test Title",
|
||||
}
|
||||
added := album.AddPhotos([]string{"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8"})
|
||||
|
||||
var entries PhotoAlbums
|
||||
|
||||
if err := Db().Where(
|
||||
"album_uid = ? AND photo_uid in (?)", "at9lxuqxpogaaba7",
|
||||
[]string{
|
||||
"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8",
|
||||
},
|
||||
).Find(&entries).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(entries) < 2 {
|
||||
t.Error("at least one album entry expected")
|
||||
}
|
||||
|
||||
var a Album
|
||||
if err := Db().Where("album_uid = ?", "at9lxuqxpogaaba7").Find(
|
||||
&a,
|
||||
).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
first_photo_updatedAt := strings.Split(entries[0].UpdatedAt.String(), ".")[0]
|
||||
second_photo_updatedAt := strings.Split(entries[1].UpdatedAt.String(), ".")[0]
|
||||
album_updatedAt := strings.Split(a.UpdatedAt.String(), ".")[0]
|
||||
|
||||
assert.Truef(
|
||||
t, first_photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" new photos are added",
|
||||
)
|
||||
assert.Truef(
|
||||
t, second_photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" new photos are added",
|
||||
)
|
||||
assert.Equal(t, 2, len(added))
|
||||
})
|
||||
}
|
||||
|
@ -503,6 +570,44 @@ func TestAlbum_RemovePhotos(t *testing.T) {
|
|||
AlbumTitle: "Test Title",
|
||||
}
|
||||
removed := album.RemovePhotos([]string{"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8"})
|
||||
|
||||
var entries PhotoAlbums
|
||||
|
||||
if err := Db().Where(
|
||||
"album_uid = ? AND photo_uid in (?)", "at9lxuqxpogaaba7",
|
||||
[]string{
|
||||
"pt9jtdre2lvl0yh7", "pt9jtdre2lvl0yh8",
|
||||
},
|
||||
).Find(&entries).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(entries) < 2 {
|
||||
t.Error("at least one album entry expected")
|
||||
}
|
||||
|
||||
var a Album
|
||||
if err := Db().Where("album_uid = ?", "at9lxuqxpogaaba7").Find(
|
||||
&a,
|
||||
).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
first_photo_updatedAt := strings.Split(entries[0].UpdatedAt.String(), ".")[0]
|
||||
second_photo_updatedAt := strings.Split(entries[1].UpdatedAt.String(), ".")[0]
|
||||
album_updatedAt := strings.Split(a.UpdatedAt.String(), ".")[0]
|
||||
|
||||
assert.Truef(
|
||||
t, first_photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" photos are removed",
|
||||
)
|
||||
assert.Truef(
|
||||
t, second_photo_updatedAt <= album_updatedAt,
|
||||
"Expected the UpdatedAt field of an album to be updated when"+
|
||||
" photos are removed",
|
||||
)
|
||||
|
||||
assert.Equal(t, 2, len(removed))
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue