@@ -611,6 +611,53 @@ test.describe('Timeline', () => {
611611 await page . getByText ( 'Photos' , { exact : true } ) . click ( ) ;
612612 await thumbnailUtils . expectInViewport ( page , assetToArchive . id ) ;
613613 } ) ;
614+ test ( 'open /archive, favorite photo, unfavorite' , async ( { page } ) => {
615+ const assetToFavorite = assets [ 0 ] ;
616+ changes . assetArchivals . push ( assetToFavorite . id ) ;
617+ await pageUtils . openArchivePage ( page ) ;
618+ const favorite = pageRoutePromise ( page , '**/api/assets' , async ( route , request ) => {
619+ const requestJson = request . postDataJSON ( ) ;
620+ if ( requestJson . isFavorite === undefined ) {
621+ return await route . continue ( ) ;
622+ }
623+ const isFavorite = requestJson . isFavorite ;
624+ if ( isFavorite ) {
625+ changes . assetFavorites . push ( ...requestJson . ids ) ;
626+ }
627+ await route . fulfill ( {
628+ status : 204 ,
629+ } ) ;
630+ } ) ;
631+ await thumbnailUtils . withAssetId ( page , assetToFavorite . id ) . hover ( ) ;
632+ await thumbnailUtils . selectButton ( page , assetToFavorite . id ) . click ( ) ;
633+ await page . getByLabel ( 'Favorite' ) . click ( ) ;
634+ await expect ( favorite ) . resolves . toEqual ( {
635+ isFavorite : true ,
636+ ids : [ assetToFavorite . id ] ,
637+ } ) ;
638+ await expect ( thumbnailUtils . withAssetId ( page , assetToFavorite . id ) ) . toHaveCount ( 1 ) ;
639+ await thumbnailUtils . expectInViewport ( page , assetToFavorite . id ) ;
640+ await thumbnailUtils . expectThumbnailIsFavorite ( page , assetToFavorite . id ) ;
641+ await thumbnailUtils . withAssetId ( page , assetToFavorite . id ) . hover ( ) ;
642+ await thumbnailUtils . selectButton ( page , assetToFavorite . id ) . click ( ) ;
643+ const unFavoriteRequest = pageRoutePromise ( page , '**/api/assets' , async ( route , request ) => {
644+ const requestJson = request . postDataJSON ( ) ;
645+ if ( requestJson . isFavorite === undefined ) {
646+ return await route . continue ( ) ;
647+ }
648+ changes . assetFavorites = changes . assetFavorites . filter ( ( id ) => ! requestJson . ids . includes ( id ) ) ;
649+ await route . fulfill ( {
650+ status : 204 ,
651+ } ) ;
652+ } ) ;
653+ await page . getByLabel ( 'Remove from favorites' ) . click ( ) ;
654+ await expect ( unFavoriteRequest ) . resolves . toEqual ( {
655+ isFavorite : false ,
656+ ids : [ assetToFavorite . id ] ,
657+ } ) ;
658+ await expect ( thumbnailUtils . withAssetId ( page , assetToFavorite . id ) ) . toHaveCount ( 1 ) ;
659+ await thumbnailUtils . expectThumbnailIsNotFavorite ( page , assetToFavorite . id ) ;
660+ } ) ;
614661 test ( 'open album, archive photo, open album, unarchive' , async ( { page } ) => {
615662 const album = timelineRestData . album ;
616663 await pageUtils . openAlbumPage ( page , album . id ) ;
@@ -633,8 +680,7 @@ test.describe('Timeline', () => {
633680 visibility : 'archive' ,
634681 ids : [ assetToArchive . id ] ,
635682 } ) ;
636- console . log ( 'Skipping assertion - TODO - fix that archiving in album doesnt add icon' ) ;
637- // await thumbnail.expectThumbnailIsArchive(page, assetToArchive.id);
683+ await thumbnailUtils . expectThumbnailIsArchive ( page , assetToArchive . id ) ;
638684 await page . locator ( '#asset-selection-app-bar' ) . getByLabel ( 'Close' ) . click ( ) ;
639685 await page . getByRole ( 'link' ) . getByText ( 'Archive' ) . click ( ) ;
640686 await timelineUtils . waitForTimelineLoad ( page ) ;
@@ -656,8 +702,7 @@ test.describe('Timeline', () => {
656702 visibility : 'timeline' ,
657703 ids : [ assetToArchive . id ] ,
658704 } ) ;
659- console . log ( 'Skipping assertion - TODO - fix bug with not removing asset from timeline-manager after unarchive' ) ;
660- // await expect(thumbnail.withAssetId(page, assetToArchive.id)).toHaveCount(0);
705+ await expect ( thumbnailUtils . withAssetId ( page , assetToArchive . id ) ) . toHaveCount ( 0 ) ;
661706 await pageUtils . openAlbumPage ( page , album . id ) ;
662707 await thumbnailUtils . expectInViewport ( page , assetToArchive . id ) ;
663708 } ) ;
@@ -712,6 +757,50 @@ test.describe('Timeline', () => {
712757 await page . getByText ( 'Photos' , { exact : true } ) . click ( ) ;
713758 await thumbnailUtils . expectInViewport ( page , assetToFavorite . id ) ;
714759 } ) ;
760+ test ( 'open /favorites, archive photo, unarchive photo' , async ( { page } ) => {
761+ await pageUtils . openFavorites ( page ) ;
762+ const assetToArchive = getAsset ( timelineRestData , 'ad31e29f-2069-4574-b9a9-ad86523c92cb' ) ! ;
763+ await thumbnailUtils . withAssetId ( page , assetToArchive . id ) . hover ( ) ;
764+ await thumbnailUtils . selectButton ( page , assetToArchive . id ) . click ( ) ;
765+ await page . getByLabel ( 'Menu' ) . click ( ) ;
766+ const archive = pageRoutePromise ( page , '**/api/assets' , async ( route , request ) => {
767+ const requestJson = request . postDataJSON ( ) ;
768+ if ( requestJson . visibility !== 'archive' ) {
769+ return await route . continue ( ) ;
770+ }
771+ await route . fulfill ( {
772+ status : 204 ,
773+ } ) ;
774+ changes . assetArchivals . push ( ...requestJson . ids ) ;
775+ } ) ;
776+ await page . getByRole ( 'menuitem' ) . getByText ( 'Archive' ) . click ( ) ;
777+ await expect ( archive ) . resolves . toEqual ( {
778+ visibility : 'archive' ,
779+ ids : [ assetToArchive . id ] ,
780+ } ) ;
781+ await page . getByRole ( 'link' ) . getByText ( 'Archive' ) . click ( ) ;
782+ await thumbnailUtils . expectInViewport ( page , assetToArchive . id ) ;
783+ await thumbnailUtils . expectThumbnailIsNotArchive ( page , assetToArchive . id ) ;
784+ await thumbnailUtils . withAssetId ( page , assetToArchive . id ) . hover ( ) ;
785+ await thumbnailUtils . selectButton ( page , assetToArchive . id ) . click ( ) ;
786+ const unarchiveRequest = pageRoutePromise ( page , '**/api/assets' , async ( route , request ) => {
787+ const requestJson = request . postDataJSON ( ) ;
788+ if ( requestJson . visibility !== 'timeline' ) {
789+ return await route . continue ( ) ;
790+ }
791+ changes . assetArchivals = changes . assetArchivals . filter ( ( id ) => ! requestJson . ids . includes ( id ) ) ;
792+ await route . fulfill ( {
793+ status : 204 ,
794+ } ) ;
795+ } ) ;
796+ await page . getByLabel ( 'Unarchive' ) . click ( ) ;
797+ await expect ( unarchiveRequest ) . resolves . toEqual ( {
798+ visibility : 'timeline' ,
799+ ids : [ assetToArchive . id ] ,
800+ } ) ;
801+ await expect ( thumbnailUtils . withAssetId ( page , assetToArchive . id ) ) . toHaveCount ( 0 ) ;
802+ await thumbnailUtils . expectThumbnailIsNotArchive ( page , assetToArchive . id ) ;
803+ } ) ;
715804 test ( 'Open album, favorite photo, open /favorites, remove favorite, Open album' , async ( { page } ) => {
716805 const album = timelineRestData . album ;
717806 await pageUtils . openAlbumPage ( page , album . id ) ;
0 commit comments