diff --git a/frontend2/src/__test__/utils.test.ts b/frontend2/src/__test__/utils.test.ts index 4226924c7..f005c23f5 100644 --- a/frontend2/src/__test__/utils.test.ts +++ b/frontend2/src/__test__/utils.test.ts @@ -26,13 +26,11 @@ test("API: Generate/Verify API Access Token (STABLE)", async () => { // Located at frontend2\src\__test__\App.test.tsx // TEST 2: Get a submission -// TODO: how??? // test('Download a submission (UNSTABLE)', async () => { // await Auth.login('lmtorola_test', 'pass') // }) // TEST 3: Get a page of submissions -// TODO: ahhhhhhhh // test('Get a page of submissions (UNSTABLE)', async () => { // expect(API.apiCompeteSubmissionList('bc22', 1) // .done((res) => { return res.body.count })) @@ -44,7 +42,9 @@ test("API: Generate/Verify API Access Token (STABLE)", async () => { test("API: Get current user's info (authed) (UNSTABLE)", async () => { await Auth.login("lmtorola_test", "pass"); Auth.setLoginHeader(); - expect(API.apiUserUMeRetrieve().then((res) => res.body.id)).toBeTruthy(); + await ApiUnsafe.getUserUserProfile().then((res) => { + expect(res.username).toEqual("lmtorola_test"); + }); }); // TEST 2: Get current user's info (unauthed) diff --git a/frontend2/src/utils/Warning.md b/frontend2/src/utils/READ_THIS.md similarity index 100% rename from frontend2/src/utils/Warning.md rename to frontend2/src/utils/READ_THIS.md diff --git a/frontend2/src/utils/api.ts b/frontend2/src/utils/api.ts index f1c323684..6c85e2399 100644 --- a/frontend2/src/utils/api.ts +++ b/frontend2/src/utils/api.ts @@ -12,7 +12,7 @@ const PAGE_SIZE = 10; // TODO: how does url work? @index.tsx? const API = new ApiApi(baseUrl); -export class ApiSafe { +export class Api { //-- TOKEN HANDLING --// /** @@ -39,9 +39,7 @@ export class ApiSafe { return false; } }; -} -export class ApiUnsafe { //-- EPISODES --// /** * Get all maps for the provided episode. @@ -129,15 +127,8 @@ export class ApiUnsafe { // }; /** - * Get the Mu history of the currently logged in user's team. + * getTeamMuHistoryByTeam */ - public static getTeamMuHistoryByTeam = async (teamId: number) => { - $.get(`${baseUrl}/api/${LEAGUE}/team/${teamId}/history/`).done( - (data, status) => { - console.log(data); - } - ); - }; /** * getTeamWinStatsByTeam @@ -671,7 +662,7 @@ export class Auth { refresh: "", }; - return await ApiSafe.getApiTokens(credentials) + return await Api.getApiTokens(credentials) .then((res) => { Cookies.set("access", res.body.access); Cookies.set("refresh", res.body.refresh); @@ -705,7 +696,7 @@ export class Auth { * If not logged in, then api calls will give 403s, and the website will tell you to log in anyways. */ public static loginCheck = async (): Promise => { - return await ApiSafe.verifyCurrentToken(); + return await Api.verifyCurrentToken(); }; /** @@ -713,7 +704,7 @@ export class Auth { * @param user The user to register. */ public static register = async (user: models.UserCreate): Promise => { - await ApiUnsafe.createUser(user); + await Api.createUser(user); return await Auth.login(user.username, user.password); };