Skip to content

Commit

Permalink
Merge pull request #39 from deipanema/refactoring-3
Browse files Browse the repository at this point in the history
Refactoring 3
  • Loading branch information
deipanema authored Oct 21, 2024
2 parents 98dee9e + be01527 commit 3a21154
Show file tree
Hide file tree
Showing 39 changed files with 1,189 additions and 1,594 deletions.
21 changes: 18 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
version: 2.1
orbs:
cypress: cypress-io/cypress@3
# "cypress-io/cypress@3" installs the latest published
# version "s.x.y" of the orb. We recommend you then use
# the strict explicit version "cypress-io/[email protected]"
# to lock the version and prevent unexpected CI changes
cypress: cypress-io/[email protected]

jobs:
cypress-run:
executor:
name: cypress/default
node-version: "20.6.0"
parallelism: 2
steps:
- cypress/install
- cypress/run-tests:
cypress-command: "npx wait-on@latest http://localhost:3000 && npx cypress run --record --parallel"
start-command: "npm run build && npm run start"

workflows:
build:
jobs:
- "cypress/run":
start-command: "npm run start"
- cypress-run
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEXT_PUBLIC_API_URL=https://sp-slidtodo-api.vercel.app/FESI3-5
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "cypress";

export default defineConfig({
projectId: "rvpvxy",
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
Expand Down
80 changes: 40 additions & 40 deletions cypress/e2e/spec.cy.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
// describe("로그인 페이지 테스트", () => {
// it("로그인 성공.", () => {
// cy.intercept("/dashboard*").as("dashboard");

// cy.visit("http://localhost:3000/login");

// cy.get('input[placeholder="이메일"]').type("[email protected]");
// cy.get('input[placeholder="비밀번호"]').type("012345678");
// cy.contains("로그인").click();

// cy.wait("@dashboard").then((_) => {
// cy.contains("대시보드");
// });
// });
// it.only("로그인 실패.", () => {
// cy.visit("http://localhost:3000/login");

// cy.get('input[placeholder="이메일"]').type("[email protected]");
// cy.get('input[placeholder="비밀번호"]').type("wrongnumber");
// cy.contains("로그인").click();

// cy.wait("@dashboard").then(() => {
// cy.contains("대시보드");
// });
// });

// it("로그인 실패.", () => {
// cy.intercept("/login").as("login");

// cy.visit("http://localhost:3000/login");

// cy.get('input[placeholder="이메일"]').type("[email protected]");
// cy.get('input[placeholder="비밀번호"]').type("wrongnumber");
// cy.contains("로그인").click();

// cy.wait("@login").then(() => {
// cy.contains("로그인에 실패했습니다. 다시 시도해 주세요.").should("be.visible");
// });
// });
// });
describe("로그인 페이지 테스트", () => {
it("로그인 성공.", () => {
cy.intercept("/dashboard*").as("dashboard");

cy.visit("http://localhost:3000/login");

cy.get('input[placeholder="이메일"]').type("[email protected]");
cy.get('input[placeholder="비밀번호"]').type("012345678");
cy.contains("로그인").click();

cy.wait("@dashboard").then(() => {
cy.contains("대시보드");
});
});
// it.only("로그인 실패.", () => {
// cy.visit("http://localhost:3000/login");

// cy.get('input[placeholder="이메일"]').type("[email protected]");
// cy.get('input[placeholder="비밀번호"]').type("wrongnumber");
// cy.contains("로그인").click();

// cy.wait("@dashboard").then(() => {
// cy.contains("대시보드");
// });
// });

// it("로그인 실패.", () => {
// cy.intercept("/login").as("login");

// cy.visit("http://localhost:3000/login");

// cy.get('input[placeholder="이메일"]').type("[email protected]");
// cy.get('input[placeholder="비밀번호"]').type("wrongnumber");
// cy.contains("로그인").click();

// cy.wait("@login").then(() => {
// cy.contains("로그인에 실패했습니다. 다시 시도해 주세요.").should("be.visible");
// });
// });
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"name": "ieum-todo",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "vitest",
"test": "vitest --passWithNoTests",
"cy:open": "wait-on http://localhost:3000/ && cypress open",
"cy:run": "npm-run-all --parallel dev cy:open"
},
Expand Down
Binary file added public/note-header.webp
Binary file not shown.
Binary file added public/note-kebab.webp
Binary file not shown.
18 changes: 13 additions & 5 deletions src/api/goalAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@ export interface ErrorType {
}

// 목표 목록 가져오기 (GET)
// 모든 목표를 가져오는 함수
export const getGoals = async () => {
try {
const response = await api.get(`/goals`);
// console.log(response);
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
toast.error(axiosError.message);
console.error("Goals fetch error:", error);
// const axiosError = error as AxiosError<ErrorType>;
// toast.error(
// axiosError.response?.data?.message || axiosError.message || "목표 목록을 가져오는 중 오류가 발생했습니다.",
// );
}
};

Expand All @@ -35,13 +40,16 @@ export const PostGoal = async (title: string) => {
}
};

// 특정 ID로 목표를 가져오는 함수
export const getGoal = async (id: number) => {
try {
const response = await api.get(`/goals/${id}`);
//console.log(response.data);
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
toast.error(axiosError.message);
console.error("Goal fetch error:", error);
// const axiosError = error as AxiosError<ErrorType>;
// toast.error(axiosError.response?.data?.message || axiosError.message || "목표를 가져오는 중 오류가 발생했습니다.");
}
};

Expand All @@ -68,7 +76,7 @@ export const PatchGoal = async (id: number, title: string) => {
export const getInfinityScrollGoals = async ({
cursor,
size = 3,
sortOrder = "oldest",
sortOrder = "newest",
}: {
cursor: number | undefined;
size: number;
Expand Down
36 changes: 29 additions & 7 deletions src/api/noteAPI.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
import { AxiosError } from "axios";
import { toast } from "react-toastify";

import api from "@/lib/api";

import { ErrorType } from "./goalAPI";

// 노트 목록 가져오기 (GET)
export const getNotes = async (id: number) => {
// 노트 리스트 가져오기 (GET)
export const getNotes = async (goalId: number) => {
try {
const response = await api.get(`/notes/${id}`);
const response = await api.get(`/notes/${goalId}`);
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
toast.error(axiosError.message);
console.error(axiosError.message);
}
};

// 단일 노트 조회
export async function getNote(noteId: number) {
try {
const response = await api.get(`/notes/${noteId}`);
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
console.error(axiosError.message);
}
}

export async function postNotes(todoId: number, title: string, content: string, linkUrl?: string | null) {
try {
const payload: {
Expand All @@ -37,7 +47,7 @@ export async function postNotes(todoId: number, title: string, content: string,
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
toast.error(axiosError.message);
console.error(axiosError.message);
}
}

Expand All @@ -64,6 +74,18 @@ export async function patchNotes(noteId: number, title: string, content: string,
return response.data;
} catch (error) {
const axiosError = error as AxiosError<ErrorType>;
toast.error(axiosError.message);
console.error(axiosError.message);
}
}

export default async function deleteNote(noteId: number) {
try {
const response = await api.delete(`notes/${noteId}`);
console.log(response);
console.log(response.data);
return response.data;
} catch (e) {
const error = e as ErrorType;
console.log(error);
}
}
Loading

0 comments on commit 3a21154

Please sign in to comment.