Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #303

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
35 changes: 35 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Cypress Tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
# Runs tests in parallel with matrix strategy https://docs.cypress.io/guides/guides/parallelization
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
# Also see warning here https://github.com/cypress-io/github-action#parallel
strategy:
fail-fast: false # https://github.com/cypress-io/github-action/issues/48
matrix:
containers: [1, 2] # Uses 2 parallel instances
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Dependencies
run: yarn install
- name: Cypress run
# Uses the official Cypress GitHub action https://github.com/cypress-io/github-action
uses: cypress-io/github-action@v6
with:
# Starts web server for E2E tests - replace with your own server invocation
# https://docs.cypress.io/guides/continuous-integration/introduction#Boot-your-server
start: yarn dev
wait-on: "http://localhost:3000" # Waits for above
# Records to Cypress Cloud
# https://docs.cypress.io/guides/cloud/projects#Set-up-a-project-to-record
record: true
parallel: true # Runs test in parallel using settings above
env:
# For recording and parallelization to work you must set your CYPRESS_RECORD_KEY
# in GitHub repo → Settings → Secrets → Actions
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# Creating a token https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 12 additions & 5 deletions app/(pages)/(withoutFooter)/place/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { Metadata } from "next";
import { PLACE_SUB_TYPE } from "@/feature/place/constants/place-tag-category";
import { Suspense } from "react";
import PlaceDetailTopBar from "@/feature/place/components/PlaceDetail/organisms/PlaceDetailTopBar";
import UseDeferredComponent from "@/common/hooks/useDeferredComponent";
import LoadingUI from "@/common/components/ui/loading/LoadingUI";
import RelatedSliderLists from "@/feature/place/components/PlaceDetail/organisms/RelatedSliderLists";
import PlaceDetailSkeleton from "@/feature/place/components/PlaceDetail/skeleton/PlaceDetailSkeleton";
import PlaceRelatedSkeleton from "@/feature/place/components/PlaceDetail/skeleton/PlaceRelatedSkeleton";
import UseDeferredComponent from "@/common/hooks/useDeferredComponent";

type Props = {
params: { id: number };
Expand Down Expand Up @@ -56,7 +57,13 @@ export default async function PlaceDetailPage({
return (
<div className="w-[100%] h-[100%] relative pb-[60px] overflow-auto">
{/* Template */}
<Suspense fallback={null}>
<Suspense
fallback={
<UseDeferredComponent>
<PlaceDetailSkeleton />
</UseDeferredComponent>
}
>
<PlaceDetailTopBar
type={detailData.info.type}
address={detailData.info.address}
Expand All @@ -76,7 +83,7 @@ export default async function PlaceDetailPage({
optionalService={detailData.info.optionalService}
dishDesc={detailData.info.dishDesc}
/>
<Divider className="h-[0.4rem] mb-[3.6rem] bg-line-gray-3" />
<Divider className="h-[0.4rem] mb-[36px] bg-line-gray-3" />
<PlaceKeywordSummary
mainText="유저들이 기록한 키워드 요약"
description="이 공간을 가장 잘 설명하는 키워드에요"
Expand All @@ -100,7 +107,7 @@ export default async function PlaceDetailPage({
<Suspense
fallback={
<UseDeferredComponent>
<LoadingUI className="h-0" />
<PlaceRelatedSkeleton />
</UseDeferredComponent>
}
>
Expand Down
1 change: 0 additions & 1 deletion app/(pages)/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default function Error({
}) {
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
}, [error]);

return (
Expand Down
1 change: 0 additions & 1 deletion app/api/auth/register/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from "next/server";

export async function POST(request: NextRequest) {
const body = await request.json();
console.log("hi");
const res = await fetch(
`${process.env.NEXT_PUBLIC_SERVER_API}/api/v1/auth/signup`,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export default async function PlaceDetailInfo({
return (
<>
<div className="flex-col relative">
<Title className="mb-[0.8rem] px-[2rem] headline0">{name}</Title>
<Title className="mb-[8px] px-[20px] headline0">{name}</Title>
<PlaceScrapIcon id={id} />
<TextWithDivider
leftText={
type === "CAFE" ? "카페" : subType && PLACE_SUB_TYPE[subType]
}
rightText={address}
className="px-[2rem] mb-[24px]"
className="px-[20px] mb-[24px]"
/>
<PlaceDetailSubInfo
type={type}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function PlaceKeywordSummaryPurpose({
<Label className="body2-medium text-text-gray-6">
{PLACE_CATEGORY["purpose"]}
</Label>
<div className="flex justify-between mt-[0.8rem] mb-[1.6rem]">
<div className="flex justify-between mt-[8px] mb-[16px]">
{purpose.map((text, i) => (
<PlacePurposeBox key={text + i} purpose={text} />
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function RelatedSlider({ title, children }: RelatedSliderProps) {
return (
<div>
<Title className="headline2">{title}</Title>
<SliderLayout className="mt-[1.6rem] mb-[6rem]">{children}</SliderLayout>
<SliderLayout className="mt-[16px] mb-[60px]">{children}</SliderLayout>
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function RelatedSliderLists({
const relatedData = await GetPlaceRelatedInfo(id);

return (
<section className="pl-[2rem] w-[100%]">
<section className="pl-[20px] w-[100%]">
<RelatedSlider title={`${name}와(과) 비슷한 장소`}>
{relatedData?.similarSpaceList.slice(0, 6).map((data) => (
<PlaceInfoCard
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import Divider from "@/common/components/ui/divider/Divider";

export default function PlaceDetailSkeleton() {
return (
<div className="animate-pulse">
<div className="h-[30rem] bg-background-gray-2 mb-[20px]" />
<div className="pl-[20px]">
<div className="w-[40%] h-[25px] bg-text-gray-4 mb-[8px]" />
<div className="w-[60%] h-[16px] bg-background-gray-2 mb-[24px]" />
<div className="w-[10%] h-[16px] bg-background-gray-2 mb-[20px]" />
</div>
<Divider className="h-[0.4rem] mb-[36px] bg-line-gray-3" />
<div className="px-[20px] mb-[56px]">
<div className="w-[60%] h-[18px] bg-text-gray-4 mb-[8px]" />
<div className="w-[55%] h-[12px] bg-background-gray-2 mb-[24px]" />
<div className="w-[20%] h-[15px] bg-line-gray-3 mb-[8px]" />
<div className="flex justify-between mb-[16px]">
<div className="w-[48%] h-[8rem] bg-background-gray-2 rounded-[8px]" />
<div className="w-[48%] h-[8rem] bg-background-gray-2 rounded-[8px]" />
</div>
<div className="w-[60%] h-[15px] bg-line-gray-3 mb-[16px]" />
<div className="w-[60%] h-[15px] bg-line-gray-3 mb-[16px]" />
</div>
<div className="px-[20px]">
<div className="w-[35%] h-[18px] bg-text-gray-4 mb-[12px]" />
<div className="w-[50%] h-[30px] bg-background-gray-2 rounded-[36px] mb-[12px]" />
<div className="w-[50%] h-[30px] bg-background-gray-2 rounded-[36px] mb-[12px]" />
<div className="flex flex-col items-end">
<div className="w-[50%] h-[30px] bg-background-gray-2 rounded-[36px] mb-[12px]" />
<div className="w-[50%] h-[30px] bg-background-gray-2 rounded-[36px]" />
</div>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export default function PlaceRelatedSkeleton() {
return (
<div className="animate-pulse pl-[20px]">
<div className="w-[70%] h-[20px] pl-[20px] bg-text-gray-4 mb-[16px]" />
<div className="flex gap-[12px] overflow-auto">
{Array.from({ length: 5 }, (_, i) => (
<div key={i}>
<div className="w-[16rem] h-[16rem] bg-background-gray-2 rounded-[8px] mb-[16px]" />
<div className="w-[10rem] h-[16px] bg-text-gray-4 mb-[8px]" />
<div className="w-[14rem] h-[12px] bg-background-gray-2" />
</div>
))}
</div>
</div>
);
}
1 change: 0 additions & 1 deletion app/feature/place/queries/getPlaceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ApiErrorMessage from "@/common/utils/error/api-error-message";
export default async function GetPlaceDetail(
id: number
): Promise<PlaceDetailResponse> {
console.log("hi");
const res = await fetch(
`${process.env.NEXT_PUBLIC_SERVER_API}/api/v1/spaces/${id}`,
{
Expand Down
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: "7tj4he",
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
Expand Down
28 changes: 11 additions & 17 deletions cypress/e2e/register.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,19 @@ describe("로컬 회원가입 화면", () => {
cy.get("@passwordInput").invoke("val").should("eq", "Gusals990^^");
cy.get("@nicknameInput").invoke("val").should("eq", "brian");

cy.intercept(
{
method: "POST",
url: "/api/auth/register",
},
{
statusCode: 200,
}
).as("register");
// cy.intercept(
// {
// method: "POST",
// url: "/api/auth/register",
// },
// {
// statusCode: 200,
// }
// ).as("register");

cy.get("[data-cy=register-button]").should("exist").click();
cy.get("[data-cy=loading-ui]").should("exist");
// cy.get("[data-cy=register-button]").should("exist").click();

cy.wait("@register").then((interception) => {
if (interception && interception.response) {
expect(interception.response.statusCode).to.eq(200);
}
});
// then: 가입 성공 페이지로 넘어간다
cy.url().should("include", "/register/success");
// cy.url().should("include", "/register/success");
});
});
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
"lint": "next lint",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"cypress": "npx cypress open",
"test": "jest --watchAll",
"cypress": "npx cypress open"
"cypress-test": "cypress run",
"start-server": "yarn dev",
"ci": "start-server-and-test start-server http://localhost:3000 cypress-test"
},
"dependencies": {
"@opentelemetry/api": "^1.8.0",
Expand Down Expand Up @@ -39,6 +42,7 @@
"recoil": "^0.7.7",
"recoil-persist": "^5.1.0",
"slick-carousel": "^1.8.1",
"start-server-and-test": "^2.0.4",
"tailwind-merge": "^2.2.1",
"undici": "^6.19.2"
},
Expand Down
Loading