diff --git a/webapp/src/components/ranking/RankingView.js b/webapp/src/components/ranking/RankingView.js
index e88581e..f2aad16 100644
--- a/webapp/src/components/ranking/RankingView.js
+++ b/webapp/src/components/ranking/RankingView.js
@@ -8,12 +8,14 @@ import { useUserContext } from '../loginAndRegistration/UserContext';
const retriever = new RankingRetriever();
const RankingView = () => {
+ const[t] = useTranslation("global");
+ const {user} = useUserContext();
+
const [rankingData, setRankingData] = useState(null);
const [myRankingData, setMyRankingData] = useState(null);
- const [searchTerm, setSearchTerm] = useState(""); // Nuevo estado para el término de búsqueda
+ const [searchTerm, setSearchTerm] = useState(user.username);
+
- const[t] = useTranslation("global");
- const {user} = useUserContext();
const getRanking = async () => {
try {
@@ -21,7 +23,6 @@ const RankingView = () => {
setRankingData(ranking.usersCompetitiveStats);
var myrank = await retriever.getUser(user.username);
setMyRankingData(myrank);
- console.log(myrank)
} catch (error) {
console.log(error);
}
diff --git a/webapp/src/components/ranking/RankingView.test.js b/webapp/src/components/ranking/RankingView.test.js
index a0a5762..76c0506 100644
--- a/webapp/src/components/ranking/RankingView.test.js
+++ b/webapp/src/components/ranking/RankingView.test.js
@@ -18,24 +18,23 @@ global.i18en = i18en;
const mockAxios = new MockAdapter(axios);
describe('RankingView component', () => {
-
+ const user = { username: 'myUser' };
it('renders title', () => {
act(()=>{
- render();
+ render();
})
const text = screen.getByText(i18en.t('ranking.ranking'));
expect(text).toBeInTheDocument();
});
it('renders Loading if the call to the gateway has not been done', () => {
act(()=>{
- render();
+ render();
})
const text = screen.getByText('Loading...');
expect(text).toBeInTheDocument();
});
});
-
describe('RankingView component with endpoint', ()=>{
mockAxios.onGet('http://localhost:8000/record/ranking/top10').reply(200,
{
@@ -94,7 +93,7 @@ describe('RankingView component', () => {
});
mockAxios.onGet('http://localhost:8000/record/ranking/myUser').reply(200,
- {usersCompetitiveStats:
+ {userCompetitiveStats:
{
"_id": "myUser",
"totalPoints": 250,
@@ -111,11 +110,12 @@ describe('RankingView component', () => {
await render();
})
- await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument());
+ await waitFor(() => expect(screen.getByText(i18en.t('ranking.position'))).toBeInTheDocument());
expect(screen.getByText(i18en.t('ranking.username'))).toBeInTheDocument()
expect(screen.getByText(i18en.t('ranking.points'))).toBeInTheDocument()
expect(screen.getByText(i18en.t('ranking.num_games'))).toBeInTheDocument()
- });
+ });
+
it('renders position all users usernames',async ()=>{
await act(async () =>{
await render();
@@ -177,5 +177,6 @@ describe('RankingView component', () => {
expect(screen.getAllByText(/1/).length).toBeGreaterThanOrEqual(2);//hay dos pq hay una posicion
});
+
})