Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ yarn-error.log*

test-results
playwright-report

/scripts/
16 changes: 9 additions & 7 deletions __tests__/unit/components/SortDropdown.test.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import { describe, it, expect, vi } from 'vitest';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import { SortDropdown } from '@/components/utils/SortDropdown';
import { useSearchParams } from 'next/navigation';
import { useRouter, usePathname } from 'next/navigation';
import { useRouter, usePathname } from '@/i18n/routing';

/* eslint-disable @typescript-eslint/no-explicit-any */

// Mock next/navigation
// Mock next/navigation for useSearchParams
vi.mock('next/navigation', () => ({
useRouter: vi.fn(),
useSearchParams: vi.fn(),
}));

// Mock @/i18n/routing
vi.mock('@/i18n/routing', () => ({
useRouter: vi.fn(),
usePathname: vi.fn(),
redirect: vi.fn(),
permanentRedirect: vi.fn(),
notFound: vi.fn(),
Link: ({ children, href, ...props }: any) => <a href={href} {...props}>{children}</a>,
}));

// Mock next-intl
Expand Down
2 changes: 1 addition & 1 deletion __tests__/unit/lib/posts.helper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('posts.helper - API Response Parsing', () => {
};

const result = extractBlogPostFromPage(mockPage);
expect(result.language).toBe('ko');
expect(result.language).toBe('KR');
});

it('should handle missing translation relation', () => {
Expand Down
6 changes: 3 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ export default defineConfig({
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
webServer: {
command: 'npm run dev -- -p 3001',
url: 'http://localhost:3001',
command: 'npm run dev -- -p 3000',
url: process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
use: {
baseURL: 'http://localhost:3001',
baseURL: process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000',
trace: 'on-first-retry',
},
projects: [
Expand Down
2 changes: 2 additions & 0 deletions src/components/error-fallbacks/CommentErrorFallback.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

export function CommentErrorFallback() {
return (
<div className="mt-16 pt-8 border-t border-neutral-200 dark:border-neutral-800">
Expand Down
2 changes: 2 additions & 0 deletions src/components/error-fallbacks/PostErrorFallback.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client';

import { Link } from "@/i18n/routing";

export function PostErrorFallback() {
Expand Down
3 changes: 2 additions & 1 deletion src/components/utils/ActiveFilters.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useRouter, useSearchParams, usePathname } from 'next/navigation';
import { useSearchParams } from 'next/navigation';
import { useRouter, usePathname } from '@/i18n/routing';
import { useTranslations } from 'next-intl';
import { X } from 'lucide-react';

Expand Down
3 changes: 2 additions & 1 deletion src/components/utils/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useRouter, useSearchParams, usePathname } from 'next/navigation';
import { useSearchParams } from 'next/navigation';
import { useRouter, usePathname } from '@/i18n/routing';
import { useTranslations } from 'next-intl';
import { cn } from "@/lib/utils";
import { SortDropdown } from "./SortDropdown";
Expand Down
3 changes: 2 additions & 1 deletion src/components/utils/SortDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useRouter, useSearchParams, usePathname } from 'next/navigation';
import { useSearchParams } from 'next/navigation';
import { useRouter, usePathname } from '@/i18n/routing';
import { useTranslations } from 'next-intl';
import { SortOption } from '@/lib/types';

Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/posts.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function extractBlogPostFromPage(p: PageObjectResponse): BlogPost {

const groupName = getSelectValue(p.properties.group);
const part = getSelectValue(p.properties.part);
const language = getSelectValue(p.properties.language) || 'ko';
const language = getSelectValue(p.properties.language) || 'KR';
const translationId = getRelationId(p.properties.translation);
const viewCount = getNumberValue(p.properties.view_count);
const commentCount = getNumberValue(p.properties.comment_count);
Expand Down
19 changes: 16 additions & 3 deletions src/lib/services/posts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const getCachedAllPosts = unstable_cache(async (): Promise<BlogPost[] | null> =>
try {
response = await notion.dataSources.query({
data_source_id: dataSourceId,
filter: {
property: "published_date",
date: {
before: new Date().toISOString(),
},
},
sorts: [
{
timestamp: "created_time",
Expand All @@ -37,7 +43,7 @@ const getCachedAllPosts = unstable_cache(async (): Promise<BlogPost[] | null> =>
.map(extractBlogPostFromPage);

return posts;
}, ['all-posts-v4'], { revalidate: 3600 });
}, ['all-posts-v5'], { revalidate: 3600 });

export interface GetPublishedPostsOptions {
tag?: string;
Expand Down Expand Up @@ -75,8 +81,15 @@ export const getPublishedPosts = async (options: GetPublishedPostsOptions = {}):
// Filter by locale (Language property)
// Map 'en' locale to 'EN' property value, 'ko' to 'KR' (or whatever is used in Notion)
// Assuming Notion uses 'KR' and 'EN' as select options
const targetLang = locale === 'ko' ? 'KR' : 'EN';
if (post.language && post.language !== targetLang) return false;
if (post.language) {
if (locale === 'ko') {
// For Korean locale, accept 'KR', etc.
if (post.language !== 'KR') return false;
} else {
// For English locale, strictly check for 'EN'
if (post.language !== 'EN') return false;
}
}

// Filter by tags (multi-tag AND filtering)
if (selectedTags.length > 0) {
Expand Down