From 5569182399d350cf93f863ab45095d40c0e9529b Mon Sep 17 00:00:00 2001 From: Jason House Date: Tue, 13 Oct 2020 13:21:44 +0900 Subject: [PATCH] Fixing missing collection data and anchors on cards --- .../jasonhhouse/gaps/MovieFromCollection.java | 8 ++--- .../java/com/jasonhhouse/gaps/Schedule.java | 2 +- .../gaps/BasicMovieFromCollectionTest.java | 16 +++++----- .../gaps/MovieFromCollectionTest.java | 8 ++--- .../gaps/service/GapsSearchService.java | 9 ++++-- .../gaps/service/PlexQueryImpl.java | 2 +- .../main/resources/templates/recommended.html | 20 +++++++------ cypress/integration/common.spec.js | 5 +--- .../integration/configuration/plex.spec.js | 7 ++--- .../integration/configuration/tmdb.spec.js | 4 +-- .../integration/notifications/discord.spec.js | 6 ++-- .../integration/notifications/email.spec.js | 6 ++-- .../integration/notifications/gotify.spec.js | 6 ++-- .../notifications/pushBullet.spec.js | 6 ++-- .../notifications/pushOver.spec.js | 6 ++-- .../notifications/telegram.spec.js | 6 ++-- .../searchRecommendedMovies.spec.js | 30 +++++++++++++------ cypress/integration/rss/rss.spec.js | 4 +-- cypress/support/index.js | 2 +- 19 files changed, 75 insertions(+), 78 deletions(-) diff --git a/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java b/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java index a06ee855..7e388b60 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/MovieFromCollection.java @@ -11,16 +11,16 @@ public final class MovieFromCollection { @NotNull private final String title; @NotNull - private final String tmdbId; + private final Integer tmdbId; @NotNull private final Boolean owned; @JsonCreator public MovieFromCollection(@JsonProperty(value = "title") @Nullable String title, - @JsonProperty(value = "tmdbId") @Nullable String tmdbId, + @JsonProperty(value = "tmdbId") @Nullable Integer tmdbId, @JsonProperty(value = "owned") @Nullable Boolean owned) { this.title = StringUtils.isEmpty(title) ? "" : title; - this.tmdbId = StringUtils.isEmpty(tmdbId) ? "" : tmdbId; + this.tmdbId = tmdbId == null ? -1 : tmdbId; this.owned = owned != null && owned; } @@ -30,7 +30,7 @@ public String getTitle() { } @NotNull - public String getTmdbId() { + public Integer getTmdbId() { return tmdbId; } diff --git a/Core/src/main/java/com/jasonhhouse/gaps/Schedule.java b/Core/src/main/java/com/jasonhhouse/gaps/Schedule.java index b3386982..aef1f138 100644 --- a/Core/src/main/java/com/jasonhhouse/gaps/Schedule.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/Schedule.java @@ -22,7 +22,7 @@ @JsonDeserialize(using = ScheduleDeserializer.class) public enum Schedule { - HOURLY("Hourly", "0 18 * * * ?", 0), + HOURLY("Hourly", "0 35 * * * ?", 0), DAILY_4AM("Daily", "0 0 4 * * ?", 1), EVERY_MONDAY("Weekly", "0 0 4 * * MON", 2), EVERY_TWO_WEEKS("Bi-weekly", "0 0 4 1,15 * ?", 3), diff --git a/Core/src/test/java/com/jasonhhouse/gaps/BasicMovieFromCollectionTest.java b/Core/src/test/java/com/jasonhhouse/gaps/BasicMovieFromCollectionTest.java index 391f0e65..c966a804 100644 --- a/Core/src/test/java/com/jasonhhouse/gaps/BasicMovieFromCollectionTest.java +++ b/Core/src/test/java/com/jasonhhouse/gaps/BasicMovieFromCollectionTest.java @@ -9,32 +9,32 @@ class BasicMovieFromCollectionTest { @Test void MovieFromCollectionTest_Invalid_Owned (){ - MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false); - MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "1234", true); + MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false); + MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, true); assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of owned field"); } @Test void MovieFromCollectionTest_Invalid_Id (){ - MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false); - MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "9874", false); + MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false); + MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 9874, false); assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of ID field"); } @Test void MovieFromCollectionTest_Invalid_Name (){ - MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false); - MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", "1234", false); + MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false); + MovieFromCollection movieFromCollection2 = new MovieFromCollection("qwe", 1234, false); assertNotEquals(movieFromCollection1, movieFromCollection2, "Movies should not be equal because of name field"); } @Test void MovieFromCollectionTest_Valid (){ - MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", "1234", false); - MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", "1234", false); + MovieFromCollection movieFromCollection1 = new MovieFromCollection("ABC", 1234, false); + MovieFromCollection movieFromCollection2 = new MovieFromCollection("ABC", 1234, false); assertEquals(movieFromCollection1, movieFromCollection2, "Movies should be equal"); } diff --git a/Core/src/test/java/com/jasonhhouse/gaps/MovieFromCollectionTest.java b/Core/src/test/java/com/jasonhhouse/gaps/MovieFromCollectionTest.java index ca3006eb..2518817e 100644 --- a/Core/src/test/java/com/jasonhhouse/gaps/MovieFromCollectionTest.java +++ b/Core/src/test/java/com/jasonhhouse/gaps/MovieFromCollectionTest.java @@ -34,16 +34,16 @@ void setUp() { @Test void testReadingFromJson() throws JsonProcessingException { - MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", MovieFromCollection.class); + MovieFromCollection movieFromCollection = objectMapper.readValue("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", MovieFromCollection.class); assertEquals("TITLE", movieFromCollection.getTitle(), "Title should be 'TITLE'"); - assertEquals("123QWE", movieFromCollection.getTmdbId(), "tmdbId should be '123QWE'"); + assertEquals(123, movieFromCollection.getTmdbId(), "tmdbId should be '123'"); assertTrue(movieFromCollection.getOwned(), "Title should be 'TITLE'"); } @Test void testWritingToJson() throws JsonProcessingException { - MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE","123QWE",true); + MovieFromCollection movieFromCollection = new MovieFromCollection("TITLE",123,true); String json = objectMapper.writeValueAsString(movieFromCollection); - assertEquals("{\"title\":\"TITLE\",\"tmdbId\":\"123QWE\",\"owned\":true}", json, "JSON output should be equal"); + assertEquals("{\"title\":\"TITLE\",\"tmdbId\":123,\"owned\":true}", json, "JSON output should be equal"); } } \ No newline at end of file diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java index c348d41f..bf7bfb19 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java @@ -110,6 +110,11 @@ public GapsSearchService(@Qualifier("real") UrlGenerator urlGenerator, SimpMessa public void run(@NotNull String machineIdentifier,@NotNull Integer key) { LOGGER.info("run( {}, {} )", machineIdentifier, key); + //ToDo + if(key.equals(1)) { + return; + } + PlexProperties plexProperties = fileIoService.readProperties(); Optional optionalPlexServer = plexProperties.getPlexServers().stream().filter(tempPlexServer -> tempPlexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst(); PlexServer plexServer; @@ -465,13 +470,13 @@ private void handleCollection(PlexProperties plexProperties, String machineIdent LOGGER.warn("Could not parse date"); } } - String id = jsonNode.get(ID).textValue(); + Integer tmdbId = jsonNode.get(ID).intValue(); BasicMovie collectionBasicMovie = new BasicMovie.Builder(title, year).build(); LOGGER.info(collectionBasicMovie.toString()); Boolean owned = ownedBasicMovies.contains(collectionBasicMovie); - moviesInCollection.add(new MovieFromCollection(title, id, owned)); + moviesInCollection.add(new MovieFromCollection(title, tmdbId, owned)); }); } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java index fa1a36c7..7d44cbeb 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java @@ -62,7 +62,7 @@ public class PlexQueryImpl implements PlexQuery { public static final String ID_IDX_START = "://"; public static final String ID_IDX_END = "?"; - private static final long TIMEOUT = 2500; + private static final long TIMEOUT = 5000; private static final Logger LOGGER = LoggerFactory.getLogger(PlexQueryImpl.class); private final UrlGenerator urlGenerator; diff --git a/GapsWeb/src/main/resources/templates/recommended.html b/GapsWeb/src/main/resources/templates/recommended.html index 3a5fe7b7..0c2ea23c 100755 --- a/GapsWeb/src/main/resources/templates/recommended.html +++ b/GapsWeb/src/main/resources/templates/recommended.html @@ -180,24 +180,26 @@

Searching for Movies

{{name}} ({{year}})
-
{{collection}}
+
{{collectionTitle}}

{{overview}}

English

Owned
- {{#each movies_in_collection}} - {{#if this.owned}} - {{this.title}} - {{/if}} + {{#each moviesInCollection}} + {{#if this.owned}} + {{this.title}} + {{/if}} {{/each}}

Missing
- {{#each movies_in_collection}} - {{#if (isNotOwned this.owned)}} - {{this.title}} - {{/if}} + {{#each moviesInCollection}} + {{#if (isNotOwned this.owned)}} + {{this.title}} + {{/if}} {{/each}}
diff --git a/cypress/integration/common.spec.js b/cypress/integration/common.spec.js index c6f8a22b..9863c219 100755 --- a/cypress/integration/common.spec.js +++ b/cypress/integration/common.spec.js @@ -57,12 +57,9 @@ export function redLibraryBefore() { cy.populatePlexConfiguration(atob('MTkyLjE2OC4xLjg='), atob('MzI0MDA='), atob('bVF3NHVhd3hUeVlFbXFOVXJ2Qno=')); - cy.get('#addPlexServer') + cy.get('#addPlexServer', { timeout: 15000 }) .click(); - // Wait for timeout from plex - cy.wait(10000); - cy.get('#plexSpinner') .should('not.be.visible'); diff --git a/cypress/integration/configuration/plex.spec.js b/cypress/integration/configuration/plex.spec.js index e7ef7a8e..94215437 100755 --- a/cypress/integration/configuration/plex.spec.js +++ b/cypress/integration/configuration/plex.spec.js @@ -42,7 +42,7 @@ describe('Plex Configuration Tests', () => { cy.get('#testPlexServer') .click(); - cy.get('#plexSpinner') + cy.get('#plexSpinner', { timeout: 15000 }) .should('not.be.visible'); cy.get('#plexTestError') @@ -108,10 +108,7 @@ describe('Plex Configuration Tests', () => { cy.get('#addPlexServer') .click(); - // Wait for timeout from plex - cy.wait(5000); - - cy.get('#plexSpinner') + cy.get('#plexSpinner', { timeout: 15000 }) .should('not.be.visible'); cy.get('#plexTestError') diff --git a/cypress/integration/configuration/tmdb.spec.js b/cypress/integration/configuration/tmdb.spec.js index ce6d08fe..fdfebe4a 100755 --- a/cypress/integration/configuration/tmdb.spec.js +++ b/cypress/integration/configuration/tmdb.spec.js @@ -26,9 +26,7 @@ describe('TMDB Configuration Tests', () => { cy.get('#testTmdbKey') .click(); - cy.wait(2000); - - cy.get('#tmdbTestError') + cy.get('#tmdbTestError', { timeout: 5000 }) .should('be.visible'); cy.get('#tmdbTestSuccess') diff --git a/cypress/integration/notifications/discord.spec.js b/cypress/integration/notifications/discord.spec.js index f515855d..0ee72bf6 100644 --- a/cypress/integration/notifications/discord.spec.js +++ b/cypress/integration/notifications/discord.spec.js @@ -290,14 +290,12 @@ describe('Check Discord Notification Agent', () => { cy.get('#testDiscord') .click(); - cy.wait(2000); + cy.get('#discordTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#discordTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#discordTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#discordSaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/notifications/email.spec.js b/cypress/integration/notifications/email.spec.js index cdd32c66..bf7bac85 100644 --- a/cypress/integration/notifications/email.spec.js +++ b/cypress/integration/notifications/email.spec.js @@ -473,14 +473,12 @@ describe('Check Email Notification Agent', () => { cy.get('#testEmail') .click(); - cy.wait(2000); + cy.get('#emailTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#emailTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#emailTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#emailSaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/notifications/gotify.spec.js b/cypress/integration/notifications/gotify.spec.js index 4fc3db43..0ce0e109 100644 --- a/cypress/integration/notifications/gotify.spec.js +++ b/cypress/integration/notifications/gotify.spec.js @@ -305,14 +305,12 @@ describe('Check Gotify Notification Agent', () => { cy.get('#testGotify') .click(); - cy.wait(2000); + cy.get('#gotifyTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#gotifyTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#gotifyTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#gotifySaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/notifications/pushBullet.spec.js b/cypress/integration/notifications/pushBullet.spec.js index 1dc491e0..22603c0d 100644 --- a/cypress/integration/notifications/pushBullet.spec.js +++ b/cypress/integration/notifications/pushBullet.spec.js @@ -305,14 +305,12 @@ describe('Check PushBullet Notification Agent', () => { cy.get('#testPushBullet') .click(); - cy.wait(2000); + cy.get('#pushBulletTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#pushBulletTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#pushBulletTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#pushBulletSaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/notifications/pushOver.spec.js b/cypress/integration/notifications/pushOver.spec.js index 664d3f0f..aa4a6980 100644 --- a/cypress/integration/notifications/pushOver.spec.js +++ b/cypress/integration/notifications/pushOver.spec.js @@ -292,14 +292,12 @@ describe('Check PushOver Notification Agent', () => { cy.get('#testPushOver') .click(); - cy.wait(2000); + cy.get('#pushOverTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#pushOverTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#pushOverTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#pushOverSaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/notifications/telegram.spec.js b/cypress/integration/notifications/telegram.spec.js index 476f3ef0..a7ce78aa 100644 --- a/cypress/integration/notifications/telegram.spec.js +++ b/cypress/integration/notifications/telegram.spec.js @@ -236,14 +236,12 @@ describe('Check Telegram Notification Agent', () => { cy.get('#testTelegram') .click(); - cy.wait(2000); + cy.get('#telegramTestError', { timeout: 5000 }) + .should(CYPRESS_VALUES.beVisible); cy.get('#telegramTestSuccess') .should(CYPRESS_VALUES.notBeVisible); - cy.get('#telegramTestError') - .should(CYPRESS_VALUES.beVisible); - cy.get('#telegramSaveSuccess') .should(CYPRESS_VALUES.notBeVisible); diff --git a/cypress/integration/recommended/searchRecommendedMovies.spec.js b/cypress/integration/recommended/searchRecommendedMovies.spec.js index d19216c8..87f761e0 100755 --- a/cypress/integration/recommended/searchRecommendedMovies.spec.js +++ b/cypress/integration/recommended/searchRecommendedMovies.spec.js @@ -69,10 +69,14 @@ describe('Search for Recommended', () => { cy.get('[data-cy=searchForMovies]') .click(); - cy.wait(5000); - - cy.get('#movies_info') + cy.get('#movies_info', { timeout: 5000 }) .should('have.text', 'Showing 1 to 7 of 7 entries'); + + cy.get('[data-cy=tt0432348-176]') + .should('have.text', 'Saw'); + + cy.get('[data-cy=tt0432348-215]') + .should('have.text', 'Saw II'); }); it('Research Movies', () => { @@ -87,17 +91,25 @@ describe('Search for Recommended', () => { cy.get('[data-cy=searchForMovies]') .click(); - cy.wait(5000); - - cy.get('#movies_info') + cy.get('#movies_info', { timeout: 5000 }) .should('have.text', 'Showing 1 to 7 of 7 entries'); + cy.get('[data-cy=tt0432348-176]') + .should('have.text', 'Saw'); + + cy.get('[data-cy=tt0432348-215]') + .should('have.text', 'Saw II'); + cy.get('#movieContainer > [onclick="searchForMovies()"]') .click(); - cy.wait(5000); - - cy.get('#movies_info') + cy.get('#movies_info', { timeout: 5000 }) .should('have.text', 'Showing 1 to 7 of 7 entries'); + + cy.get('[data-cy=tt0432348-176]') + .should('have.text', 'Saw'); + + cy.get('[data-cy=tt0432348-215]') + .should('have.text', 'Saw II'); }); }); diff --git a/cypress/integration/rss/rss.spec.js b/cypress/integration/rss/rss.spec.js index 1b97cbff..28579b32 100644 --- a/cypress/integration/rss/rss.spec.js +++ b/cypress/integration/rss/rss.spec.js @@ -50,9 +50,7 @@ describe('Searched RSS', () => { cy.get('[data-cy=searchForMovies]') .click(); - cy.wait(5000); - - cy.get('#movies_info') + cy.get('#movies_info', { timeout: 5000 }) .should('have.text', 'Showing 1 to 7 of 7 entries'); cy.visit('/rssCheck', { onBeforeLoad: spyOnAddEventListener }); diff --git a/cypress/support/index.js b/cypress/support/index.js index 63268c1f..d68db96d 100755 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -17,4 +17,4 @@ import './commands' // Alternatively you can use CommonJS syntax: -// require('./commands') \ No newline at end of file +// require('./commands')