-
Notifications
You must be signed in to change notification settings - Fork 3
[feature] 앱 출시 배너를 추가한다 #938
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 all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8a0d26e
feat: 모아동 앱출시 배너 추가
seongwon030 38ec1f1
fix: useNavigator 외부 URL 판별 시 허용 프로토콜 화이트리스트 적용
seongwon030 a33dde5
feat: 앱 릴리즈 배너 데이터 추가
seongwon030 57db215
feat: user-agent 기반 OS별 스토어 링크 분기 처리
seongwon030 9e174c3
refactor: console 제거
seongwon030 8afe9cb
fix: 악성 프로토콜 차단 및 외부 URL 화이트리스트 적용
seongwon030 6203c5d
test: 링크 이동 기능 단위 테스트 추가
seongwon030 54ea58e
refactor: useNavigator 테스트 가독성 개선
seongwon030 5454edd
feat: 배너 순서 변경 (앱 릴리즈 1번으로)
seongwon030 eee9400
feat: 배너 클릭 이벤트 트래킹 추가
seongwon030 1c8d5c6
refactor: useNavigator 테스트에 it.each 적용으로 중복 제거
seongwon030 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,105 @@ | ||
| import { renderHook, RenderHookResult } from '@testing-library/react'; | ||
| import { useNavigate } from 'react-router-dom'; | ||
| import useNavigator from '../useNavigator'; | ||
|
|
||
| jest.mock('react-router-dom', () => ({ | ||
| useNavigate: jest.fn(), | ||
| })); | ||
|
|
||
| describe('useNavigator - 사용자가 링크를 클릭했을 때', () => { | ||
| const mockNavigate = jest.fn(); | ||
| const originalLocation = window.location; | ||
| let handleLink: RenderHookResult<(url: string) => void, unknown>; | ||
|
|
||
| beforeEach(() => { | ||
| jest.clearAllMocks(); | ||
| (useNavigate as jest.Mock).mockReturnValue(mockNavigate); | ||
|
|
||
| Object.defineProperty(window, 'location', { | ||
| writable: true, | ||
| value: { href: '' }, | ||
| }); | ||
|
|
||
| // given | ||
| handleLink = renderHook(() => useNavigator()); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| Object.defineProperty(window, 'location', { | ||
| writable: true, | ||
| value: originalLocation, | ||
| }); | ||
| }); | ||
|
|
||
| describe('링크가 비어있으면', () => { | ||
| it('아무 페이지로도 이동하지 않는다', () => { | ||
| // When | ||
| handleLink.result.current(''); | ||
|
|
||
| // Then | ||
| expect(mockNavigate).not.toHaveBeenCalled(); | ||
| expect(window.location.href).toBe(''); | ||
| }); | ||
|
|
||
| it('공백만 있는 링크도 이동하지 않는다', () => { | ||
| // When | ||
| handleLink.result.current(' '); | ||
|
|
||
| // Then | ||
| expect(mockNavigate).not.toHaveBeenCalled(); | ||
| expect(window.location.href).toBe(''); | ||
| }); | ||
| }); | ||
|
|
||
| describe('악성 링크를 클릭하면', () => { | ||
| it.each([ | ||
| ['javascript', 'javascript:alert("XSS")'], | ||
| ['data', 'data:text/html,<script>alert("XSS")</script>'], | ||
| ['vbscript', 'vbscript:msgbox("XSS")'], | ||
| ['대문자 javascript', 'JAVASCRIPT:alert("XSS")'], | ||
| ])('%s 프로토콜 링크는 차단된다', (_, maliciousUrl) => { | ||
| // When | ||
| handleLink.result.current(maliciousUrl); | ||
|
|
||
| // Then | ||
| expect(mockNavigate).not.toHaveBeenCalled(); | ||
| expect(window.location.href).toBe(''); | ||
| }); | ||
| }); | ||
|
|
||
| describe('외부 사이트 링크를 클릭하면', () => { | ||
| it.each([ | ||
| ['https', 'https://example.com'], | ||
| ['http', 'http://example.com'], | ||
| ['App Store (itms-apps)', 'itms-apps://itunes.apple.com/app/123456'], | ||
| ])('%s 링크는 해당 사이트로 이동한다', (_, externalUrl) => { | ||
| // When | ||
| handleLink.result.current(externalUrl); | ||
|
|
||
| // Then | ||
| expect(window.location.href).toBe(externalUrl); | ||
| expect(mockNavigate).not.toHaveBeenCalled(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('내부 페이지 링크를 클릭하면', () => { | ||
| it('소개 페이지로 이동할 수 있다', () => { | ||
| // When | ||
| handleLink.result.current('/introduce'); | ||
|
|
||
| // Then | ||
| expect(mockNavigate).toHaveBeenCalledWith('/introduce'); | ||
| expect(window.location.href).toBe(''); | ||
| }); | ||
|
|
||
| it('상대 경로로도 이동할 수 있다', () => { | ||
| // When | ||
| handleLink.result.current('about'); | ||
|
|
||
| // Then | ||
| expect(mockNavigate).toHaveBeenCalledWith('about'); | ||
| expect(window.location.href).toBe(''); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
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
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.
Uh oh!
There was an error while loading. Please reload this page.