From a505bd7d4d1e2bdb51e6653db9f00933456700bc Mon Sep 17 00:00:00 2001 From: Ryan Cohen Date: Fri, 19 Aug 2022 14:16:38 +0900 Subject: [PATCH] test: add watchlist test for discover page --- cypress/e2e/discover.cy.ts | 33 +++++++++++++++++++++++++++++++++ cypress/fixtures/watchlist.json | 25 +++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 cypress/fixtures/watchlist.json diff --git a/cypress/e2e/discover.cy.ts b/cypress/e2e/discover.cy.ts index ec4c4afea..bb4fc0115 100644 --- a/cypress/e2e/discover.cy.ts +++ b/cypress/e2e/discover.cy.ts @@ -171,4 +171,37 @@ describe('Discover', () => { .find('[data-testid=request-card-title]') .contains('Movie Not Found'); }); + + it('loads plex watchlist', () => { + cy.intercept('/api/v1/discover/watchlist', { fixture: 'watchlist' }).as( + 'getWatchlist' + ); + + cy.wait('@getWatchlist'); + + // Wait for one of the watchlist movies to resolve + cy.intercept('/api/v1/movie/361743').as('getTmdbMovie'); + + const sliderHeader = cy.contains('.slider-header', 'Plex Watchlist'); + + sliderHeader.scrollIntoView(); + + cy.wait('@getTmdbMovie'); + + sliderHeader + .next('[data-testid=media-slider]') + .find('[data-testid=title-card]') + .first() + .trigger('mouseover') + .find('[data-testid=title-card-title]') + .invoke('text') + .then((text) => { + cy.contains('.slider-header', 'Plex Watchlist') + .next('[data-testid=media-slider]') + .find('[data-testid=title-card]') + .first() + .click(); + cy.get('[data-testid=media-title]').should('contain', text); + }); + }); }); diff --git a/cypress/fixtures/watchlist.json b/cypress/fixtures/watchlist.json new file mode 100644 index 000000000..0f80b27b4 --- /dev/null +++ b/cypress/fixtures/watchlist.json @@ -0,0 +1,25 @@ +{ + "page": 1, + "totalPages": 1, + "totalResults": 20, + "results": [ + { + "ratingKey": "5d776be17a53e9001e732ab9", + "title": "Top Gun: Maverick", + "mediaType": "movie", + "tmdbId": 361743 + }, + { + "ratingKey": "5e16338fbc1372003ea68ab3", + "title": "Nope", + "mediaType": "movie", + "tmdbId": 762504 + }, + { + "ratingKey": "5f409b8452f200004161e126", + "title": "Hocus Pocus 2", + "mediaType": "movie", + "tmdbId": 642885 + } + ] +}