Skip to content
Snippets Groups Projects
Commit b053068d authored by heikkkk's avatar heikkkk
Browse files

test: add e2e test for loading leaderboard

parent 7a48a6fd
No related branches found
No related tags found
1 merge request!72Test/e2e
describe("Leaderboard Test", () => {
beforeEach(() => {
cy.visit('/login');
cy.get('#emailInput input').type('user@example.com');
cy.get('#passwordInput input').type('John1');
cy.get('form').submit();
cy.wait(1000);
cy.visit('/leaderboard')
});
it('loads global leaderboards', () => {
cy.get('[data-cy="total-points-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 10);
cy.get('[data-cy="total-points-board"]')
.find('[data-cy="surrounding-user-leaderboard-tablerow"]')
.should('have.length', 4);
cy.get('[data-cy="current-points-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 10);
cy.get('[data-cy="streak-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 10);
})
it('loads friends leaderboards', () => {
cy.get('[data-cy="friends-leaderboard-btn"]').click()
cy.get('[data-cy="total-points-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 3);
cy.get('[data-cy="current-points-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 3);
cy.get('[data-cy="streak-board"]')
.find('[data-cy="top-leaderboard-tablerow"]')
.should('have.length', 3);
})
})
\ No newline at end of file
...@@ -2,8 +2,10 @@ ...@@ -2,8 +2,10 @@
<div id="leaderboard"> <div id="leaderboard">
<div class="ribbon"></div> <div class="ribbon"></div>
<table> <table>
<tbody> <tbody data-cy="top-leaderboard-table">
<tr v-for="(entry, index) in leaderboard" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.id === userStore.id }"> <tr data-cy="top-leaderboard-tablerow" v-for="(entry, index) in leaderboard"
:key="entry.user?.id" :class="{ 'is-user-5':
entry.user?.id === userStore.id }">
<td class="number">{{ entry.rank }}</td> <td class="number">{{ entry.rank }}</td>
<td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td> <td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td>
<td class="points" v-if="index === 0"> <td class="points" v-if="index === 0">
...@@ -18,9 +20,11 @@ ...@@ -18,9 +20,11 @@
</tr> </tr>
</tbody> </tbody>
<tbody id="line">`</tbody> <tbody id="line">`</tbody>
<tbody v-if="!userInLeaderboard"> <tbody data-cy="surrounding-user-leaderboard-table" v-if="!userInLeaderboard">
<tr></tr> <tr></tr>
<tr v-for="(entry, index) in leaderboardExtra" :key="entry.user?.id" :class="{ 'is-user-5': entry.user?.id === userStore.id }"> <tr data-cy="surrounding-user-leaderboard-tablerow" v-for="(entry, index) in
leaderboardExtra" :key="entry.user?.id" :class="{
'is-user-5': entry.user?.id === userStore.id }">
<td class="number">{{ entry.rank }}</td> <td class="number">{{ entry.rank }}</td>
<td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td> <td class="name" @click="navigateToUserProfile(entry.user?.id ?? 0)">{{ entry.user?.firstName }}</td>
<td class="points">{{ entry.score }}</td> <td class="points">{{ entry.score }}</td>
......
...@@ -11,22 +11,27 @@ ...@@ -11,22 +11,27 @@
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio1" autocomplete="off" checked> <input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio1" autocomplete="off" checked>
<label class="btn btn-outline-primary" for="vbtn-radio1" @click="global"><img src="@/assets/globe.png" style="width: 60px" alt="globus"> Global</label> <label class="btn btn-outline-primary" for="vbtn-radio1" @click="global"><img src="@/assets/globe.png" style="width: 60px" alt="globus"> Global</label>
<input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio2" autocomplete="off"> <input type="radio" class="btn-check" name="vbtn-radio" id="vbtn-radio2" autocomplete="off">
<label class="btn btn-outline-primary" for="vbtn-radio2" @click="friends"><img src="@/assets/friends.png" style="width: 60px" alt="venner"> Venner</label> <label data-cy="friends-leaderboard-btn" class="btn btn-outline-primary"
for="vbtn-radio2"
@click="friends"><img src="@/assets/friends.png" style="width: 60px" alt="venner"> Venner</label>
</div> </div>
</div> </div>
</div> </div>
<main> <main>
<div id="leaderboard"> <div id="leaderboard">
<h1><img src="@/assets/items/pigcoin.png" style="width: 2rem" alt="pig coin"> Totale poeng</h1> <h1><img src="@/assets/items/pigcoin.png" style="width: 2rem" alt="pig coin"> Totale poeng</h1>
<Leaderboard :leaderboard="pointsLeaderboardData" :leaderboardExtra="pointsLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" /> <Leaderboard data-cy="total-points-board" :leaderboard="pointsLeaderboardData"
:leaderboardExtra="pointsLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" />
</div> </div>
<div id="leaderboard"> <div id="leaderboard">
<h1><img src="@/assets/icons/fire.png" style="width: 2rem" alt="ild"> Nåværende rekke</h1> <h1><img src="@/assets/icons/fire.png" style="width: 2rem" alt="ild"> Nåværende rekke</h1>
<Leaderboard :leaderboard="currentLeaderboardData" :leaderboardExtra="currentLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" /> <Leaderboard data-cy="current-points-board" :leaderboard="currentLeaderboardData"
:leaderboardExtra="currentLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" />
</div> </div>
<div id="leaderboard"> <div id="leaderboard">
<h1><img src="@/assets/icons/fire.png" style="width: 2rem" alt="ild"> Høyeste rekke</h1> <h1><img src="@/assets/icons/fire.png" style="width: 2rem" alt="ild"> Høyeste rekke</h1>
<Leaderboard :leaderboard="streakLeaderboardData" :leaderboardExtra="streakLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" /> <Leaderboard data-cy="streak-board" :leaderboard="streakLeaderboardData"
:leaderboardExtra="streakLeaderboardDataExtra" @navigateToUserProfile="navigateToUserProfile" />
</div> </div>
</main> </main>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment