-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: Flex wrapper 마이그레이션 #188
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b2eac41
test(flex): cover active video card migration target
KYBee 69e43da
refactor(flex): migrate active video card wrappers
KYBee 19a6be5
test(flex): cover user card migration target
KYBee 414369a
refactor(flex): migrate user card wrappers
KYBee 8889992
Merge remote-tracking branch 'origin/develop' into refact/flex-migrat…
KYBee f26ae74
refactor: migrate activity cards to Flex
KYBee dd52e19
refactor: migrate static flex wrappers
KYBee 13e9bf2
refactor: remove unused UserCard period prop
KYBee f93a144
test: verify ActiveCard fallback icon accessibility
KYBee e7a17b3
fix: restore Recruit flex justification
KYBee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import Button from './index'; | ||
|
|
||
| describe('Button', () => { | ||
| it('renders a native button with disabled state', () => { | ||
| render( | ||
| <Button buttonType="apply" disabled> | ||
| 지원하기 | ||
| </Button>, | ||
| ); | ||
|
|
||
| const button = screen.getByRole('button', { name: '지원하기' }); | ||
|
|
||
| expect(button).toBeDisabled(); | ||
| expect(button).toHaveAttribute('aria-disabled', 'true'); | ||
| }); | ||
|
|
||
| it('renders an external link with safe link attributes', () => { | ||
| render( | ||
| <Button | ||
| buttonType="apply" | ||
| href="https://example.com/apply" | ||
| isExternalLink | ||
| > | ||
| 지원하기 | ||
| </Button>, | ||
| ); | ||
|
|
||
| const link = screen.getByRole('link', { name: '지원하기' }); | ||
|
|
||
| expect(link).toHaveAttribute('href', 'https://example.com/apply'); | ||
| expect(link).toHaveAttribute('target', '_blank'); | ||
| expect(link).toHaveAttribute('rel', 'noopener noreferrer'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/components/organisms/about/SponsorSection/SponsorImage.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { fireEvent, render, screen } from '@testing-library/react'; | ||
|
|
||
| import SponsorImage from './SponsorImage'; | ||
|
|
||
| vi.mock('next/image', () => ({ | ||
| default: ({ | ||
| alt, | ||
| onError, | ||
| src, | ||
| }: { | ||
| alt: string; | ||
| onError?: () => void; | ||
| src: string; | ||
| }) => ( | ||
| // Tests only need an element with alt text semantics. | ||
| // eslint-disable-next-line @next/next/no-img-element | ||
| <img alt={alt} onError={onError} src={src} /> | ||
| ), | ||
| })); | ||
|
|
||
| describe('SponsorImage', () => { | ||
| it('renders the sponsor image with the provided alt text', () => { | ||
| render(<SponsorImage src="/sponsor.png" alt="후원사" />); | ||
|
|
||
| expect(screen.getByAltText('후원사')).toHaveAttribute( | ||
| 'src', | ||
| '/sponsor.png', | ||
| ); | ||
| }); | ||
|
|
||
| it('renders the fallback image when the sponsor image fails to load', () => { | ||
| render(<SponsorImage src="/broken.png" alt="후원사" />); | ||
|
|
||
| fireEvent.error(screen.getByAltText('후원사')); | ||
|
|
||
| expect(screen.getByAltText('Image not available')).toHaveAttribute( | ||
| 'src', | ||
| '/assets/empty_image.png', | ||
| ); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/components/organisms/activity/ActiveCard/index.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import ActiveCard from './index'; | ||
|
|
||
| vi.mock('@/components/molecules/Image', () => ({ | ||
| default: ({ alt, src }: { alt: string; src?: string }) => ( | ||
| // Tests only need an element with alt text semantics. | ||
| // eslint-disable-next-line @next/next/no-img-element | ||
| <img alt={alt} src={src} /> | ||
| ), | ||
| })); | ||
|
|
||
| vi.mock('@/libs/assets/icons', () => ({ | ||
| UserIcon: ({ className }: { className?: string }) => ( | ||
| <svg aria-label="default user profile" className={className} /> | ||
| ), | ||
| })); | ||
|
|
||
| describe('ActiveCard', () => { | ||
| it('renders the post thumbnail, content, profile, metadata, and outbound link', () => { | ||
| render( | ||
| <ActiveCard | ||
| thumbnail="/activity-post.png" | ||
| profile="/profile.png" | ||
| contentTitle="사이프 블로그 글" | ||
| contentBody="사이프 활동을 정리한 글입니다" | ||
| userName="김사이퍼" | ||
| createDate="2026.06.22" | ||
| link="https://example.com/post" | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByRole('link')).toHaveAttribute( | ||
| 'href', | ||
| 'https://example.com/post', | ||
| ); | ||
| expect(screen.getByAltText('thumbnail')).toHaveAttribute( | ||
| 'src', | ||
| '/activity-post.png', | ||
| ); | ||
| expect(screen.getByAltText('user profile')).toHaveAttribute( | ||
| 'src', | ||
| '/profile.png', | ||
| ); | ||
| expect(screen.getByText('사이프 블로그 글')).toBeInTheDocument(); | ||
| expect( | ||
| screen.getByText('사이프 활동을 정리한 글입니다'), | ||
| ).toBeInTheDocument(); | ||
| expect(screen.getByText('김사이퍼')).toBeInTheDocument(); | ||
| expect(screen.getByText('2026.06.22')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders the default user icon when profile is omitted', () => { | ||
| render( | ||
| <ActiveCard | ||
| thumbnail="/activity-post.png" | ||
| contentTitle="프로필 없는 글" | ||
| contentBody="기본 아이콘 확인" | ||
| userName="박사이퍼" | ||
| createDate="2026.06.23" | ||
| link="https://example.com/no-profile" | ||
| />, | ||
| ); | ||
|
|
||
| expect(screen.getByLabelText('default user profile')).toBeInTheDocument(); | ||
| expect(screen.queryByAltText('user profile')).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 내용은 props와 무관하게 aria-label="default user profile"을 항상 렌더링해서,
아래에 있는,
expect(screen.getByLabelText('default user profile')).toBeInTheDocument();에서 실제 UserIcon 의 접근성을 검증하지 못하고 있습니다
실제 코드에서 aria-label 값을 넘겨주도록 수정하시거나,
<UserIcon aria-label="default user profile" className={styles.userIcon} />이 mock 을 패스 스루 해주시면 어떨까요?
UserIcon: (props: React.SVGProps<SVGSVGElement>) => <svg {...props} />,There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞습니다. mock이
aria-label을 직접 만들어 실제 컴포넌트의 접근성 계약을 검증하지 못하고 있었습니다. fallbackUserIcon에aria-label을 명시하고, mock은 전달받은 props를 그대로 적용하도록 수정하겠습니다.