From ea40ef12c9cb7c8e8946f43dc01c32d946a21e3d Mon Sep 17 00:00:00 2001 From: Gaston Gaiduk Date: Wed, 18 Dec 2024 20:53:03 +0100 Subject: [PATCH] Add almost full coverage tests --- cypress/e2e/game_leaderboards.cy.ts | 72 ++++++++ cypress/e2e/leaderboard_entries.cy.ts | 159 ++++++++++++++++++ cypress/e2e/recently_played_games_page.cy.ts | 40 +---- .../fixtures/game-list-with-leaderboard.json | 20 +++ .../game-list-without-leaderboard.json | 20 +++ .../fixtures/leaderboard-entries-refresh.json | 76 +++++++++ cypress/fixtures/leaderboard-entries.json | 76 +++++++++ cypress/fixtures/leaderboards-refresh.json | 126 ++++++++++++++ cypress/fixtures/leaderboards.json | 126 ++++++++++++++ cypress/fixtures/no-leaderboard-entries.json | 5 + cypress/fixtures/no-leaderboards.json | 5 + .../fixtures/users-i-follow-with-matias.json | 18 ++ cypress/fixtures/users-i-follow.json | 12 ++ cypress/support/commands.ts | 58 +++---- 14 files changed, 744 insertions(+), 69 deletions(-) create mode 100644 cypress/e2e/game_leaderboards.cy.ts create mode 100644 cypress/e2e/leaderboard_entries.cy.ts create mode 100644 cypress/fixtures/game-list-with-leaderboard.json create mode 100644 cypress/fixtures/game-list-without-leaderboard.json create mode 100644 cypress/fixtures/leaderboard-entries-refresh.json create mode 100644 cypress/fixtures/leaderboard-entries.json create mode 100644 cypress/fixtures/leaderboards-refresh.json create mode 100644 cypress/fixtures/leaderboards.json create mode 100644 cypress/fixtures/no-leaderboard-entries.json create mode 100644 cypress/fixtures/no-leaderboards.json create mode 100644 cypress/fixtures/users-i-follow-with-matias.json create mode 100644 cypress/fixtures/users-i-follow.json diff --git a/cypress/e2e/game_leaderboards.cy.ts b/cypress/e2e/game_leaderboards.cy.ts new file mode 100644 index 0000000..c73b50a --- /dev/null +++ b/cypress/e2e/game_leaderboards.cy.ts @@ -0,0 +1,72 @@ +describe('game leaderboards page', () => { + beforeEach(() => { + cy.clearAllLocalStorage() + }) + + it('no leaderboards', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-without-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'no-leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.wait('@getLeaderboards').its('response.body') + .should('have.property', 'Results') + + cy.url().should('include', '/game/769/leaderboards') + cy.contains('Kirby & The Amazing Mirror') + cy.contains('No leaderboards found for this game.') + }) + + it('leaderboards list with refresh', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.wait('@getLeaderboards').its('response.body') + .should('have.property', 'Results') + .should('have.length', 10) + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.get('.leaderboard-list li').eq(1).contains('New Zealand Two') + cy.get('.leaderboard-list li').eq(1).contains('Thebpg13') + cy.get('.leaderboard-list li').eq(1).contains('2:38.36') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards-refresh.json' }).as('getLeaderboardsRefresh') + + cy.get('.refresh-button').click() + + cy.wait('@getLeaderboardsRefresh').its('response.body') + .should('have.property', 'Results') + .should('have.length', 10) + + cy.get('.leaderboard-list li').eq(1).contains('New Zealand Two') + cy.get('.leaderboard-list li').eq(1).contains('zuliman92') + cy.get('.leaderboard-list li').eq(1).contains('2:35.23') + }) + + it('go back to recently played games', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.visit('#/game/16557/leaderboards') + + cy.get('.back-button').click() + + cy.url().should('include', '/games') + }) +}) diff --git a/cypress/e2e/leaderboard_entries.cy.ts b/cypress/e2e/leaderboard_entries.cy.ts new file mode 100644 index 0000000..9dc152d --- /dev/null +++ b/cypress/e2e/leaderboard_entries.cy.ts @@ -0,0 +1,159 @@ +describe('leaderboard entries page', () => { + beforeEach(() => { + cy.clearAllLocalStorage() + }) + + it('no entries', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.interceptUsersIFollow() + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'no-leaderboard-entries.json' }).as('getLeaderboardEntries') + + cy.get('.leaderboard-list li').eq(1).click() + + cy.url().should('include', '/leaderboard/19063') + cy.contains('Colin McRae Rally') + cy.contains('New Zealand Two') + cy.contains('No entries found for this leaderboard.') + }) + + it('entries with refresh and no entry from me or my friends', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.interceptUsersIFollow() + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'leaderboard-entries.json' }).as('getLeaderboardEntries') + + cy.get('.leaderboard-list li').eq(1).click() + + cy.url().should('include', '/leaderboard/19063') + cy.contains('Colin McRae Rally') + cy.contains('New Zealand Two') + + cy.get('.entries-list li').eq(0).contains('Thebpg13') + cy.get('.entries-list li').eq(0).contains('2:38.36') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'leaderboard-entries-refresh.json' }).as('getLeaderboardEntriesRefresh') + + cy.get('.refresh-button').click() + + cy.wait('@getLeaderboardEntriesRefresh').its('response.body') + .should('have.property', 'Results') + .should('have.length', 10) + + cy.get('.entries-list li').eq(0).contains('josef733') + cy.get('.entries-list li').eq(0).contains('2:34.45') + + cy.get('.entries-list li').eq(1).contains('Thebpg13') + cy.get('.entries-list li').eq(1).contains('2:38.36') + }) + + it('entries with an entry only from me', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('matias721744', 'matias721744-secret') + cy.interceptUsersIFollow() + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'leaderboard-entries.json' }).as('getLeaderboardEntries') + + cy.get('.leaderboard-list li').eq(1).click() + + cy.url().should('include', '/leaderboard/19063') + cy.contains('Colin McRae Rally') + cy.contains('New Zealand Two') + + cy.get('.entries-list li').eq(0).contains('matias721744') + cy.get('.entries-list li').eq(0).contains('2:51.55') + + cy.get('.entries-list li').eq(1).contains('Thebpg13') + cy.get('.entries-list li').eq(1).contains('2:38.36') + }) + + it('entries with entry only from a friend', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('player', 'player-secret') + cy.intercept('GET', '**/API/API_GetUsersIFollow.php*', { fixture: 'users-i-follow-with-matias.json' }).as('getUsersIFollow') + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'leaderboard-entries.json' }).as('getLeaderboardEntries') + + cy.get('.leaderboard-list li').eq(1).click() + + cy.url().should('include', '/leaderboard/19063') + cy.contains('Colin McRae Rally') + cy.contains('New Zealand Two') + + cy.get('.entries-list li').eq(0).contains('matias721744') + cy.get('.entries-list li').eq(0).contains('2:51.55') + + cy.get('.entries-list li').eq(1).contains('Thebpg13') + cy.get('.entries-list li').eq(1).contains('2:38.36') + }) + + it('entries with a entry from me and a friend', () => { + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'game-list-with-leaderboard.json' }).as('getRecentlyPlayedGames') + + cy.authenticate('masakimu', 'masakimu-secret') + cy.intercept('GET', '**/API/API_GetUsersIFollow.php*', { fixture: 'users-i-follow-with-matias.json' }).as('getUsersIFollow') + cy.visit('/') + + cy.intercept('GET', '**/API/API_GetGameLeaderboards.php*', { fixture: 'leaderboards.json' }).as('getLeaderboards') + + cy.get('.game-button').click() + + cy.url().should('include', '/game/16557/leaderboards') + cy.contains('Colin McRae Rally') + + cy.intercept('GET', '**/API/API_GetLeaderboardEntries.php*', { fixture: 'leaderboard-entries.json' }).as('getLeaderboardEntries') + + cy.get('.leaderboard-list li').eq(1).click() + + cy.url().should('include', '/leaderboard/19063') + cy.contains('Colin McRae Rally') + cy.contains('New Zealand Two') + + cy.get('.entries-list li').eq(0).contains('masakimu') + cy.get('.entries-list li').eq(0).contains('2:46.59') + + cy.get('.entries-list li').eq(1).contains('matias721744') + cy.get('.entries-list li').eq(1).contains('2:51.55') + + cy.get('.entries-list li').eq(2).contains('Thebpg13') + cy.get('.entries-list li').eq(2).contains('2:38.36') + }) +}) diff --git a/cypress/e2e/recently_played_games_page.cy.ts b/cypress/e2e/recently_played_games_page.cy.ts index df6c6c1..40bbef2 100644 --- a/cypress/e2e/recently_played_games_page.cy.ts +++ b/cypress/e2e/recently_played_games_page.cy.ts @@ -4,17 +4,10 @@ describe('recently played games page', () => { }) it('no games played', () => { - cy.visit('/') - - cy.url().should('include', '/login') - cy.contains('Authenticate') - - cy.get('input[id="username"]').type('player') - cy.get('input[id="key"]').type('player-secret') - cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'no-played-games.json' }).as('getRecentlyPlayedGames') - cy.contains('Submit').click() + cy.authenticate('player', 'player-secret') + cy.visit('/') cy.wait('@getRecentlyPlayedGames').its('response.body') .should('deep.equal', []) @@ -24,17 +17,10 @@ describe('recently played games page', () => { }) it('recently played games list with refresh', () => { - cy.visit('/') - - cy.url().should('include', '/login') - cy.contains('Authenticate') - - cy.get('input[id="username"]').type('example') - cy.get('input[id="key"]').type('example-secret') - cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'recently-played-games-1.json' }).as('getRecentlyPlayedGames') - cy.contains('Submit').click() + cy.authenticate('player', 'player-secret') + cy.visit('/') cy.wait('@getRecentlyPlayedGames').its('response.body') .should('have.length', 1) @@ -42,11 +28,11 @@ describe('recently played games page', () => { cy.url().should('include', '/games') cy.contains('Colin McRae Rally') - cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'recently-played-games-2.json' }).as('getRecentlyPlayedGames') + cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'recently-played-games-2.json' }).as('getRecentlyPlayedGamesTwo') cy.get('.refresh-button').click() - cy.wait('@getRecentlyPlayedGames').its('response.body') + cy.wait('@getRecentlyPlayedGamesTwo').its('response.body') .should('have.length', 2) cy.get('.game-list li').eq(0).contains('Colin McRae Rally') @@ -54,20 +40,10 @@ describe('recently played games page', () => { }) it('logout', () => { - cy.visit('/') - - cy.url().should('include', '/login') - cy.contains('Authenticate') - - cy.get('input[id="username"]').type('player') - cy.get('input[id="key"]').type('player-secret') - cy.intercept('GET', '**/API/API_GetUserRecentlyPlayedGames.php*', { fixture: 'no-played-games.json' }).as('getRecentlyPlayedGames') - cy.contains('Submit').click() - - cy.wait('@getRecentlyPlayedGames').its('response.body') - .should('deep.equal', []) + cy.authenticate('player', 'player-secret') + cy.visit('/') cy.contains('Logout').click() diff --git a/cypress/fixtures/game-list-with-leaderboard.json b/cypress/fixtures/game-list-with-leaderboard.json new file mode 100644 index 0000000..f24c72f --- /dev/null +++ b/cypress/fixtures/game-list-with-leaderboard.json @@ -0,0 +1,20 @@ +[ + { + "GameID": 16557, + "ConsoleID": 12, + "ConsoleName": "PlayStation", + "Title": "Colin McRae Rally", + "ImageIcon": "/Images/036840.png", + "ImageTitle": "/Images/036689.png", + "ImageIngame": "/Images/036690.png", + "ImageBoxArt": "/Images/065054.png", + "LastPlayed": "2024-12-16 22:22:54", + "AchievementsTotal": 104, + "NumPossibleAchievements": 104, + "PossibleScore": 436, + "NumAchieved": 53, + "ScoreAchieved": 173, + "NumAchievedHardcore": 53, + "ScoreAchievedHardcore": 173 + } +] diff --git a/cypress/fixtures/game-list-without-leaderboard.json b/cypress/fixtures/game-list-without-leaderboard.json new file mode 100644 index 0000000..8ef6a60 --- /dev/null +++ b/cypress/fixtures/game-list-without-leaderboard.json @@ -0,0 +1,20 @@ +[ + { + "GameID": 769, + "ConsoleID": 5, + "ConsoleName": "Game Boy Advance", + "Title": "Kirby & The Amazing Mirror", + "ImageIcon": "/Images/042405.png", + "ImageTitle": "/Images/033746.png", + "ImageIngame": "/Images/002643.png", + "ImageBoxArt": "/Images/014483.png", + "LastPlayed": "2024-11-24 21:31:43", + "AchievementsTotal": 55, + "NumPossibleAchievements": 55, + "PossibleScore": 311, + "NumAchieved": 21, + "ScoreAchieved": 31, + "NumAchievedHardcore": 21, + "ScoreAchievedHardcore": 31 + } +] diff --git a/cypress/fixtures/leaderboard-entries-refresh.json b/cypress/fixtures/leaderboard-entries-refresh.json new file mode 100644 index 0000000..f7cf4a3 --- /dev/null +++ b/cypress/fixtures/leaderboard-entries-refresh.json @@ -0,0 +1,76 @@ +{ + "Count": 10, + "Total": 366, + "Results": [ + { + "User": "josef733", + "DateSubmitted": "2024-05-28T21:45:32+00:00", + "Score": 15445, + "FormattedScore": "2:34.45", + "Rank": 1 + }, + { + "User": "Thebpg13", + "DateSubmitted": "2024-10-08T21:22:07+00:00", + "Score": 15836, + "FormattedScore": "2:38.36", + "Rank": 2 + }, + { + "User": "masakimu", + "DateSubmitted": "2023-10-28T17:20:02+00:00", + "Score": 16659, + "FormattedScore": "2:46.59", + "Rank": 3 + }, + { + "User": "JollyClubber", + "DateSubmitted": "2024-11-22T11:44:03+00:00", + "Score": 16682, + "FormattedScore": "2:46.82", + "Rank": 4 + }, + { + "User": "Ryszard", + "DateSubmitted": "2023-10-01T17:12:55+00:00", + "Score": 16965, + "FormattedScore": "2:49.65", + "Rank": 5 + }, + { + "User": "matias721744", + "DateSubmitted": "2024-09-27T21:08:48+00:00", + "Score": 17155, + "FormattedScore": "2:51.55", + "Rank": 6 + }, + { + "User": "ReAPer13AW", + "DateSubmitted": "2024-10-22T21:50:54+00:00", + "Score": 17339, + "FormattedScore": "2:53.39", + "Rank": 7 + }, + { + "User": "KboxGames", + "DateSubmitted": "2024-10-03T14:25:26+00:00", + "Score": 17342, + "FormattedScore": "2:53.42", + "Rank": 8 + }, + { + "User": "Pluxer", + "DateSubmitted": "2023-08-09T15:29:40+00:00", + "Score": 17509, + "FormattedScore": "2:55.09", + "Rank": 9 + }, + { + "User": "suXin", + "DateSubmitted": "2021-11-06T14:53:10+00:00", + "Score": 17559, + "FormattedScore": "2:55.59", + "Rank": 10 + } + ] +} \ No newline at end of file diff --git a/cypress/fixtures/leaderboard-entries.json b/cypress/fixtures/leaderboard-entries.json new file mode 100644 index 0000000..4b3d783 --- /dev/null +++ b/cypress/fixtures/leaderboard-entries.json @@ -0,0 +1,76 @@ +{ + "Count": 10, + "Total": 366, + "Results": [ + { + "User": "Thebpg13", + "DateSubmitted": "2024-10-08T21:22:07+00:00", + "Score": 15836, + "FormattedScore": "2:38.36", + "Rank": 1 + }, + { + "User": "josef733", + "DateSubmitted": "2024-05-28T21:45:32+00:00", + "Score": 16445, + "FormattedScore": "2:44.45", + "Rank": 2 + }, + { + "User": "masakimu", + "DateSubmitted": "2023-10-28T17:20:02+00:00", + "Score": 16659, + "FormattedScore": "2:46.59", + "Rank": 3 + }, + { + "User": "JollyClubber", + "DateSubmitted": "2024-11-22T11:44:03+00:00", + "Score": 16682, + "FormattedScore": "2:46.82", + "Rank": 4 + }, + { + "User": "Ryszard", + "DateSubmitted": "2023-10-01T17:12:55+00:00", + "Score": 16965, + "FormattedScore": "2:49.65", + "Rank": 5 + }, + { + "User": "matias721744", + "DateSubmitted": "2024-09-27T21:08:48+00:00", + "Score": 17155, + "FormattedScore": "2:51.55", + "Rank": 6 + }, + { + "User": "ReAPer13AW", + "DateSubmitted": "2024-10-22T21:50:54+00:00", + "Score": 17339, + "FormattedScore": "2:53.39", + "Rank": 7 + }, + { + "User": "KboxGames", + "DateSubmitted": "2024-10-03T14:25:26+00:00", + "Score": 17342, + "FormattedScore": "2:53.42", + "Rank": 8 + }, + { + "User": "Pluxer", + "DateSubmitted": "2023-08-09T15:29:40+00:00", + "Score": 17509, + "FormattedScore": "2:55.09", + "Rank": 9 + }, + { + "User": "suXin", + "DateSubmitted": "2021-11-06T14:53:10+00:00", + "Score": 17559, + "FormattedScore": "2:55.59", + "Rank": 10 + } + ] +} \ No newline at end of file diff --git a/cypress/fixtures/leaderboards-refresh.json b/cypress/fixtures/leaderboards-refresh.json new file mode 100644 index 0000000..80f28a8 --- /dev/null +++ b/cypress/fixtures/leaderboards-refresh.json @@ -0,0 +1,126 @@ +{ + "Count": 10, + "Total": 64, + "Results": [ + { + "ID": 19062, + "RankAsc": true, + "Title": "New Zealand One", + "Description": "Complete New Zealand S1 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 11903, + "FormattedScore": "1:59.03" + } + }, + { + "ID": 19063, + "RankAsc": true, + "Title": "New Zealand Two", + "Description": "Complete New Zealand S2 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "zuliman92", + "Score": 15836, + "FormattedScore": "2:35.23" + } + }, + { + "ID": 19064, + "RankAsc": true, + "Title": "New Zealand Three", + "Description": "Complete New Zealand S3 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 17619, + "FormattedScore": "2:56.19" + } + }, + { + "ID": 19065, + "RankAsc": true, + "Title": "New Zealand Four", + "Description": "Complete New Zealand S4 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 14173, + "FormattedScore": "2:21.73" + } + }, + { + "ID": 19066, + "RankAsc": true, + "Title": "New Zealand Five", + "Description": "Complete New Zealand S5 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 13963, + "FormattedScore": "2:19.63" + } + }, + { + "ID": 19067, + "RankAsc": true, + "Title": "New Zealand Six", + "Description": "Complete New Zealand S6 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "JollyClubber", + "Score": 15422, + "FormattedScore": "2:34.22" + } + }, + { + "ID": 19068, + "RankAsc": true, + "Title": "Greece One", + "Description": "Complete Greece S1 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 15252, + "FormattedScore": "2:32.52" + } + }, + { + "ID": 19069, + "RankAsc": true, + "Title": "Greece Two", + "Description": "Complete Greece S2 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "josef733", + "Score": 13953, + "FormattedScore": "2:19.53" + } + }, + { + "ID": 19070, + "RankAsc": true, + "Title": "Greece Three", + "Description": "Complete Greece S3 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "josef733", + "Score": 12140, + "FormattedScore": "2:01.40" + } + }, + { + "ID": 19071, + "RankAsc": true, + "Title": "Greece Four", + "Description": "Complete Greece S4 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 15219, + "FormattedScore": "2:32.19" + } + } + ] + } \ No newline at end of file diff --git a/cypress/fixtures/leaderboards.json b/cypress/fixtures/leaderboards.json new file mode 100644 index 0000000..bbbbcf4 --- /dev/null +++ b/cypress/fixtures/leaderboards.json @@ -0,0 +1,126 @@ +{ + "Count": 10, + "Total": 64, + "Results": [ + { + "ID": 19062, + "RankAsc": true, + "Title": "New Zealand One", + "Description": "Complete New Zealand S1 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 11903, + "FormattedScore": "1:59.03" + } + }, + { + "ID": 19063, + "RankAsc": true, + "Title": "New Zealand Two", + "Description": "Complete New Zealand S2 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 15836, + "FormattedScore": "2:38.36" + } + }, + { + "ID": 19064, + "RankAsc": true, + "Title": "New Zealand Three", + "Description": "Complete New Zealand S3 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 17619, + "FormattedScore": "2:56.19" + } + }, + { + "ID": 19065, + "RankAsc": true, + "Title": "New Zealand Four", + "Description": "Complete New Zealand S4 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 14173, + "FormattedScore": "2:21.73" + } + }, + { + "ID": 19066, + "RankAsc": true, + "Title": "New Zealand Five", + "Description": "Complete New Zealand S5 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 13963, + "FormattedScore": "2:19.63" + } + }, + { + "ID": 19067, + "RankAsc": true, + "Title": "New Zealand Six", + "Description": "Complete New Zealand S6 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "JollyClubber", + "Score": 15422, + "FormattedScore": "2:34.22" + } + }, + { + "ID": 19068, + "RankAsc": true, + "Title": "Greece One", + "Description": "Complete Greece S1 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 15252, + "FormattedScore": "2:32.52" + } + }, + { + "ID": 19069, + "RankAsc": true, + "Title": "Greece Two", + "Description": "Complete Greece S2 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "josef733", + "Score": 13953, + "FormattedScore": "2:19.53" + } + }, + { + "ID": 19070, + "RankAsc": true, + "Title": "Greece Three", + "Description": "Complete Greece S3 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "josef733", + "Score": 12140, + "FormattedScore": "2:01.40" + } + }, + { + "ID": 19071, + "RankAsc": true, + "Title": "Greece Four", + "Description": "Complete Greece S4 in least time", + "Format": "MILLISECS", + "TopEntry": { + "User": "Thebpg13", + "Score": 15219, + "FormattedScore": "2:32.19" + } + } + ] + } \ No newline at end of file diff --git a/cypress/fixtures/no-leaderboard-entries.json b/cypress/fixtures/no-leaderboard-entries.json new file mode 100644 index 0000000..a61ac39 --- /dev/null +++ b/cypress/fixtures/no-leaderboard-entries.json @@ -0,0 +1,5 @@ +{ + "Count": 0, + "Total": 0, + "Results": [] +} \ No newline at end of file diff --git a/cypress/fixtures/no-leaderboards.json b/cypress/fixtures/no-leaderboards.json new file mode 100644 index 0000000..a61ac39 --- /dev/null +++ b/cypress/fixtures/no-leaderboards.json @@ -0,0 +1,5 @@ +{ + "Count": 0, + "Total": 0, + "Results": [] +} \ No newline at end of file diff --git a/cypress/fixtures/users-i-follow-with-matias.json b/cypress/fixtures/users-i-follow-with-matias.json new file mode 100644 index 0000000..687f531 --- /dev/null +++ b/cypress/fixtures/users-i-follow-with-matias.json @@ -0,0 +1,18 @@ +{ + "Count": 2, + "Total": 2, + "Results": [ + { + "User": "matias721744", + "Points": 7081, + "PointsSoftcore": 0, + "IsFollowingMe": true + }, + { + "User": "zuliman92", + "Points": 2442, + "PointsSoftcore": 258, + "IsFollowingMe": true + } + ] +} \ No newline at end of file diff --git a/cypress/fixtures/users-i-follow.json b/cypress/fixtures/users-i-follow.json new file mode 100644 index 0000000..8cac5cf --- /dev/null +++ b/cypress/fixtures/users-i-follow.json @@ -0,0 +1,12 @@ +{ + "Count": 1, + "Total": 1, + "Results": [ + { + "User": "zuliman92", + "Points": 2442, + "PointsSoftcore": 258, + "IsFollowingMe": true + } + ] +} \ No newline at end of file diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 698b01a..0dc4d44 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -1,37 +1,21 @@ -/// -// *********************************************** -// This example commands.ts shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -// -// declare global { -// namespace Cypress { -// interface Chainable { -// login(email: string, password: string): Chainable -// drag(subject: string, options?: Partial): Chainable -// dismiss(subject: string, options?: Partial): Chainable -// visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable -// } -// } -// } \ No newline at end of file +import {} from 'cypress' + +Cypress.Commands.add('authenticate', (username: string, webApiKey: string) => { + cy.visit('/login') + cy.get('input[id="username"]').type(username) + cy.get('input[id="key"]').type(webApiKey) + cy.contains('Submit').click() + }) + +Cypress.Commands.add('interceptUsersIFollow', () => { + cy.intercept('GET', '**/API/API_GetUsersIFollow.php*', { fixture: 'users-i-follow.json' }).as('getUsersIFollow') +}) + +declare global { + namespace Cypress { + interface Chainable { + authenticate(username: string, webApiKey: string): Chainable + interceptUsersIFollow(): Chainable + } + } +}