-
Notifications
You must be signed in to change notification settings - Fork 4
엑셀 다운로드 핸들러 함수 (handle Excel Download) 리팩터링 #159
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
ohinhyuk
merged 10 commits into
dev-refactoring
from
refactor/158-handleexceldownload-refactoring
Oct 25, 2025
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2666368
chore: e2e test 폴더 이름 변경
ohinhyuk 899b88e
refactor: 엑셀 다운로드 핸들러 함수 (handle Excel Download) 리팩터링
ohinhyuk 90ad3a6
refactor: 엑셀 테스트 명 변경
ohinhyuk 7a35d50
refactor: 엑셀 유틸 buildWorkBook 내의 지역변수명 구체화
ohinhyuk 68b81ef
refactor: 엑셀 다운로드 함수 추상화
ohinhyuk bb95559
refactor: 엑셀 다운로드 함수 리팩터링
ohinhyuk f9cd5c5
test: 엑셀 테스트 경로 수정
ohinhyuk 767dfa8
chore: playwright timeout 설정
ohinhyuk c795d3d
test: 다운로드 버튼 클릭 테스트 Promise 적용
ohinhyuk a46fe10
test: 엑셀 테스트 이동 후 딜레이 추가
ohinhyuk 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,4 +34,4 @@ node_modules/ | |
|
|
||
| playwright/.auth | ||
|
|
||
| tests/auth/ | ||
| e2e-tests/auth/ | ||
File renamed without changes.
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 { paths } from '@/const/paths'; | ||
| import test, { expect } from '@playwright/test'; | ||
|
|
||
| test.use({ storageState: 'e2e-tests/auth/admin.json' }); | ||
|
|
||
| test.describe('엑셀 다운로드 테스트', () => { | ||
| test('스터디 관리 페이지 (manage-study) 엑셀 다운로드 테스트', async ({ page }) => { | ||
| await page.goto(paths.admin.manageStudy); | ||
|
|
||
| await page.waitForTimeout(3000); | ||
| const [download] = await Promise.all([ | ||
| page.waitForEvent('download'), | ||
| page.getByRole('button', { name: '그룹 활동 목록 엑셀 다운' }).click(), | ||
| ]); | ||
|
|
||
| expect(download.suggestedFilename()).toBe('스터디그룹활동.xlsx'); | ||
|
|
||
| const failure = await download.failure(); | ||
| expect(failure).toBeNull(); | ||
| }); | ||
|
|
||
| test('스터디 신청자 목록 페이지 (manage-student) 엑셀 다운로드 테스트', async ({ page }) => { | ||
| await page.goto(paths.admin.manageStudent); | ||
| await page.waitForTimeout(3000); | ||
|
|
||
| const [download] = await Promise.all([ | ||
| page.waitForEvent('download'), | ||
| page.getByRole('button', { name: '신청자 목록 다운로드' }).click(), | ||
| ]); | ||
|
|
||
| expect(download.suggestedFilename()).toBe('스터디신청자목록.xlsx'); | ||
|
|
||
| const failure = await download.failure(); | ||
| expect(failure).toBeNull(); | ||
| }); | ||
| }); |
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
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,16 @@ | ||
| import * as xlsx from 'xlsx'; | ||
|
|
||
| export function downloadExcelFromSheetData<T>(sheetData: T[], filename: string) { | ||
| const workBook = buildWorkBook(sheetData); | ||
| xlsx.writeFile(workBook, filename); | ||
|
|
||
| function buildWorkBook<T>(sheetData: T[]) { | ||
| const workBook = xlsx.utils.book_new(); | ||
|
|
||
| const workSheet = xlsx.utils.json_to_sheet(sheetData); | ||
|
|
||
| xlsx.utils.book_append_sheet(workBook, workSheet); | ||
|
|
||
| return workBook; | ||
| } | ||
| } |
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.
buildApplicantsSheetData 함수에서 applicants의 존재 유무를 확인한다면 기존 로직과 다르게 동작할 것 같습니다.
handleExcelDownload 함수 상단에서 처리해주는 건 어떨까요?
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.
bb95559 에서 수정하였습니다.