-
-
Notifications
You must be signed in to change notification settings - Fork 10
[feat] 問題集の詳細ページのグレードアイコンから投票できるようにする #3589
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
8 commits
Select commit
Hold shift + click to select a range
a05606e
feat(workbooks): enable voting from grade icons on workbook detail page
river0525 5e05054
fix: fix coderabbit review
river0525 b04ba39
fix: address additional coderabbit review findings
river0525 b12ca24
Merge branch 'staging' of github.com:AtCoder-NoviSteps/AtCoderNoviSte…
KATO-Hiro 00eecee
test(votes): add unit tests for voteAbsoluteGradeSchema
KATO-Hiro 359f29f
fix(votes): adjust GradeLabel width props in VotableGrade
KATO-Hiro 179982c
feat(votes): expose GradeLabel width/padding as VotableGrade props
KATO-Hiro 8369ebe
test(votes): use omitted keys instead of explicit undefined in schema…
KATO-Hiro 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
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,80 @@ | ||
| import { describe, expect, test } from 'vitest'; | ||
| import { TaskGrade } from '@prisma/client'; | ||
|
|
||
| import { voteAbsoluteGradeSchema } from '$features/votes/zod/schema'; | ||
|
|
||
| describe('voteAbsoluteGradeSchema', () => { | ||
| function validate(data: unknown): boolean { | ||
| return voteAbsoluteGradeSchema.safeParse(data).success; | ||
| } | ||
|
|
||
| describe('valid inputs', () => { | ||
| test('ABC task with Q-grade', () => { | ||
| expect(validate({ taskId: 'abc408_a', grade: TaskGrade.Q7 })).toBe(true); | ||
| }); | ||
|
|
||
| test('ARC task with D-grade', () => { | ||
| expect(validate({ taskId: 'arc188_c', grade: TaskGrade.D3 })).toBe(true); | ||
| }); | ||
|
|
||
| test('ABC G problem with D6 grade', () => { | ||
| expect(validate({ taskId: 'abc399_g', grade: TaskGrade.D6 })).toBe(true); | ||
| }); | ||
|
|
||
| test('AOJ 4-digit task ID', () => { | ||
| expect(validate({ taskId: '1001', grade: TaskGrade.Q5 })).toBe(true); | ||
| }); | ||
|
|
||
| test('taskId with surrounding whitespace is trimmed', () => { | ||
| expect(validate({ taskId: ' abc408_a ', grade: TaskGrade.Q7 })).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('boundary values', () => { | ||
| test('taskId of exactly 1 character is accepted', () => { | ||
| expect(validate({ taskId: 'a', grade: TaskGrade.Q5 })).toBe(true); | ||
| }); | ||
|
|
||
| test('Q11 (first valid grade) is accepted', () => { | ||
| expect(validate({ taskId: 'abc408_a', grade: TaskGrade.Q11 })).toBe(true); | ||
| }); | ||
|
|
||
| test('D6 (last valid grade) is accepted', () => { | ||
| expect(validate({ taskId: 'abc399_g', grade: TaskGrade.D6 })).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe('invalid inputs', () => { | ||
| test('empty taskId is rejected', () => { | ||
| expect(validate({ taskId: '', grade: TaskGrade.Q5 })).toBe(false); | ||
| }); | ||
|
|
||
| test('whitespace-only taskId is rejected after trimming', () => { | ||
| expect(validate({ taskId: ' ', grade: TaskGrade.Q5 })).toBe(false); | ||
| }); | ||
|
|
||
| test('PENDING grade is rejected', () => { | ||
| expect(validate({ taskId: 'abc408_a', grade: TaskGrade.PENDING })).toBe(false); | ||
| }); | ||
|
|
||
| test('unknown grade string is rejected', () => { | ||
| expect(validate({ taskId: 'abc408_a', grade: 'INVALID' })).toBe(false); | ||
| }); | ||
|
|
||
| test('missing grade is rejected', () => { | ||
| expect(validate({ taskId: 'abc408_a' })).toBe(false); | ||
| }); | ||
|
|
||
| test('missing taskId is rejected', () => { | ||
| expect(validate({ grade: TaskGrade.Q5 })).toBe(false); | ||
| }); | ||
|
|
||
| test('null taskId is rejected', () => { | ||
| expect(validate({ taskId: null, grade: TaskGrade.Q5 })).toBe(false); | ||
| }); | ||
|
|
||
| test('null grade is rejected', () => { | ||
| expect(validate({ taskId: 'abc408_a', grade: null })).toBe(false); | ||
| }); | ||
| }); | ||
| }); | ||
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,11 @@ | ||
| import { z } from 'zod'; | ||
| import { TaskGrade } from '@prisma/client'; | ||
|
|
||
| export const voteAbsoluteGradeSchema = z.object({ | ||
| taskId: z.string().trim().min(1), | ||
| grade: z | ||
| .nativeEnum(TaskGrade) | ||
| .refine((val) => val !== TaskGrade.PENDING, { message: 'Cannot vote for PENDING grade' }), | ||
| }); | ||
|
|
||
| export type VoteAbsoluteGradeInput = z.infer<typeof voteAbsoluteGradeSchema>; |
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
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.
Uh oh!
There was an error while loading. Please reload this page.