diff --git a/src/__tests__/basic.test.js b/src/__tests__/basic.test.js index f02f15fe..20789e79 100644 --- a/src/__tests__/basic.test.js +++ b/src/__tests__/basic.test.js @@ -10,8 +10,6 @@ import { vi, } from "vitest"; -import { LOGIN_FORM_ID, USER_NAME_INPUT_ID } from "../pages/LoginPage.js"; - beforeAll(async () => { // DOM 초기화 window.alert = vi.fn(); @@ -77,15 +75,9 @@ describe("기본과제 테스트", () => { it("로그인 폼에서 사용자 이름을 입력하고 제출하면 로그인 되고, 로그아웃 버튼 클릭시 로그아웃 된다.", async () => { goTo("/login"); - const loginForm = document.getElementById(LOGIN_FORM_ID); - console.log(loginForm); - document.querySelectorAll("input").forEach((input) => { - console.log(input); - }), - await user.type( - document.getElementById(USER_NAME_INPUT_ID), - "testuser", - ); + const loginForm = document.getElementById("login-form"); + + await user.type(document.getElementById("username"), "testuser"); loginForm.dispatchEvent( new SubmitEvent("submit", { bubbles: true, cancelable: true }), @@ -135,7 +127,7 @@ describe("기본과제 테스트", () => { profileForm.dispatchEvent( new SubmitEvent("submit", { bubbles: true, cancelable: true }), ); - console.log("###", JSON.parse(localStorage.getItem("user"))["email"]); + expect(localStorage.getItem("user")).toEqual( `{"username":"testuser","email":"","bio":"Updated bio"}`, ); diff --git a/src/components/Layout.js b/src/components/Layout.js index b71e83cc..87f2d78b 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -1,6 +1,6 @@ import { userManager } from "../utils/user"; -const ATAG_IN_NAVIGATOR_ATTRIBUTE_VALUE_MAP_LIST = [ +const HREF_TAG_IN_NAVIGATOR_ATTRIBUTE_VALUE_MAP_LIST = [ { href: "/", id: "home", @@ -8,7 +8,7 @@ const ATAG_IN_NAVIGATOR_ATTRIBUTE_VALUE_MAP_LIST = [ }, ]; -const SIGNIN_USER_ATAG_ATTRIBUTE_VALUE_MAP_LIST = [ +const SIGNIN_USER_HREF_TAG_ATTRIBUTE_VALUE_MAP_LIST = [ { href: "/profile", id: "profile", @@ -21,7 +21,7 @@ const SIGNIN_USER_ATAG_ATTRIBUTE_VALUE_MAP_LIST = [ }, ]; -const NON_SIGNIN_USER_ATAG_ATTRIBUTE_VALUE_MAP_LIST = [ +const NON_SIGNIN_USER_HREF_TAG_ATTRIBUTE_VALUE_MAP_LIST = [ { href: "/login", id: "login", @@ -39,18 +39,23 @@ export const Navigation = () => { const isLogin = userManager.isLogin(); const aTagDataList = [ - ...ATAG_IN_NAVIGATOR_ATTRIBUTE_VALUE_MAP_LIST, + ...HREF_TAG_IN_NAVIGATOR_ATTRIBUTE_VALUE_MAP_LIST, ...(isLogin - ? SIGNIN_USER_ATAG_ATTRIBUTE_VALUE_MAP_LIST - : NON_SIGNIN_USER_ATAG_ATTRIBUTE_VALUE_MAP_LIST), + ? SIGNIN_USER_HREF_TAG_ATTRIBUTE_VALUE_MAP_LIST + : NON_SIGNIN_USER_HREF_TAG_ATTRIBUTE_VALUE_MAP_LIST), ]; + const path = window.location.pathname; + + const currentPageTabStyleClassName = "text-blue-600 font-bold"; + const defaultPageTabStyleClassName = "text-gray-600"; + return `