diff --git a/client/src/components/room/AnswerJudgeResult.fixture.ts b/client/src/components/room/AnswerJudgeResult.fixture.ts new file mode 100644 index 0000000..a2ad442 --- /dev/null +++ b/client/src/components/room/AnswerJudgeResult.fixture.ts @@ -0,0 +1,35 @@ +import type { components } from '@/generated/api' +import { mockContract } from '@/mocks/data' + +type AnswerResponse = components['schemas']['AnswerResponse'] + +function getAnswerFixture( + example: 'incorrect_answer' | 'correct_answer_unlocks_problem', +): AnswerResponse { + return mockContract.getResponseExample('submitAnswer', 200, example) as AnswerResponse +} + +function judgeStateFromAnswer(response: AnswerResponse) { + return response.correct ? ('correct' as const) : ('incorrect' as const) +} + +const incorrectAnswer = getAnswerFixture('incorrect_answer') +const correctAnswer = getAnswerFixture('correct_answer_unlocks_problem') + +export const answerJudgeResultFixtures = { + idle: { + state: 'idle', + }, + pending: { + state: 'pending', + }, + correct: { + state: judgeStateFromAnswer(correctAnswer), + }, + incorrect: { + state: judgeStateFromAnswer(incorrectAnswer), + }, + error: { + state: 'error', + }, +} as const diff --git a/client/src/components/room/AnswerJudgeResult.story.vue b/client/src/components/room/AnswerJudgeResult.story.vue new file mode 100644 index 0000000..033410c --- /dev/null +++ b/client/src/components/room/AnswerJudgeResult.story.vue @@ -0,0 +1,38 @@ + + + diff --git a/client/src/components/room/AnswerJudgeResult.vue b/client/src/components/room/AnswerJudgeResult.vue new file mode 100644 index 0000000..ce20f4f --- /dev/null +++ b/client/src/components/room/AnswerJudgeResult.vue @@ -0,0 +1,85 @@ + + + diff --git a/client/src/components/room/AnswerPanel.fixture.ts b/client/src/components/room/AnswerPanel.fixture.ts new file mode 100644 index 0000000..fb63d9d --- /dev/null +++ b/client/src/components/room/AnswerPanel.fixture.ts @@ -0,0 +1,20 @@ +import type { components } from '@/generated/api' +import { mockContract } from '@/mocks/data' + +type ProblemResponse = components['schemas']['ProblemResponse'] +type AnswerRequest = components['schemas']['AnswerRequest'] + +const problem = mockContract.getResponseExample( + 'getProblem', + 200, + 'available_problem', +) as ProblemResponse +const submittedAnswer = mockContract.getRequestExample( + 'submitAnswer', + 'submitted_answer', +) as AnswerRequest + +export const answerPanelFixture = { + maxLength: problem.input_schema.answer.max_length, + submittedAnswer: submittedAnswer.answer, +} as const diff --git a/client/src/components/room/AnswerPanel.story.vue b/client/src/components/room/AnswerPanel.story.vue new file mode 100644 index 0000000..f1b5676 --- /dev/null +++ b/client/src/components/room/AnswerPanel.story.vue @@ -0,0 +1,25 @@ + + + diff --git a/client/src/components/room/AnswerPanel.vue b/client/src/components/room/AnswerPanel.vue new file mode 100644 index 0000000..059d925 --- /dev/null +++ b/client/src/components/room/AnswerPanel.vue @@ -0,0 +1,89 @@ + + +