diff --git a/webapp/src/components/ranking/RankingView.js b/webapp/src/components/ranking/RankingView.js index 33a239fb..6d172024 100644 --- a/webapp/src/components/ranking/RankingView.js +++ b/webapp/src/components/ranking/RankingView.js @@ -17,7 +17,7 @@ const RankingView = () => { try { var ranking = await retriever.getTopTen(); setRankingData(ranking.usersCompetitiveStats); - var myrank = await retriever.getMyPosition("user"); + var myrank = await retriever.getMyPosition(user.username); setMyRankingData(myrank); console.log(myrank) } catch (error) { diff --git a/webapp/src/components/ranking/RankingView.test.js b/webapp/src/components/ranking/RankingView.test.js index c9e44535..dd0c05fd 100644 --- a/webapp/src/components/ranking/RankingView.test.js +++ b/webapp/src/components/ranking/RankingView.test.js @@ -22,7 +22,7 @@ describe('RankingView component', () => { it('renders title', () => { act(()=>{ - render(); + render(); }) const text = screen.getByText(i18en.t('ranking.ranking')); expect(text).toBeInTheDocument(); @@ -93,18 +93,19 @@ describe('RankingView component', () => { ] }); - mockAxios.onGet('http://localhost:8000/record/ranking/user').reply(200, + mockAxios.onGet('http://localhost:8000/record/ranking/myUser').reply(200, { "_id": "myUser", "totalPoints": 250, "totalCompetitiveGames": 1 } ); + const user = { username: 'myUser' }; it('renders position all headers in the table',async ()=>{ await act(async () =>{ - await render(); + await render(); }) await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument()); @@ -114,7 +115,7 @@ describe('RankingView component', () => { }); it('renders position all users usernames',async ()=>{ await act(async () =>{ - await render(); + await render(); }) await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument()); @@ -132,7 +133,7 @@ describe('RankingView component', () => { it('renders position all users totalPoints',async ()=>{ await act(async () =>{ - await render(); + await render(); }) await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument()); @@ -149,7 +150,7 @@ describe('RankingView component', () => { it('renders position all users competitive games',async ()=>{ await act(async () =>{ - await render(); + await render(); }) await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument()); @@ -162,7 +163,7 @@ describe('RankingView component', () => { it('renders position all users competitive games',async ()=>{ await act(async () =>{ - await render(); + await render(); }) await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument());