From c8421f1aa61e6563f728e2a2f0e56211473a35d2 Mon Sep 17 00:00:00 2001
From: K-shir0 <50326556+K-shir0@users.noreply.github.com>
Date: Mon, 18 Dec 2023 23:34:53 +0900
Subject: [PATCH] =?UTF-8?q?update:=20=E4=BA=88=E9=81=B8=E7=94=A8=E3=82=AB?=
=?UTF-8?q?=E3=82=B9=E3=82=BF=E3=83=A0=E3=82=92=E8=BF=BD=E5=8A=A0=20(#114)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* update: 予選用カスタムを追加
* add: preRoundMode フラグ
* fix: session が切れたときにログアウト状態にするようにするようにした
* update: 筆記問題と選択問題をグループ分けするように変更
* update: 回答済み一覧の採点のところを見えないように変更
* update: 回答送信済みか分かるように追加
* update: 筆記問題のときに再展開情報を取り行かないように修正
* update: 参加者一覧に所属を表示するように変更
* update: ranking hook に preRound の分岐を追加
* update: users 所属のテストを追加
* update: users 所属の e2e テストを追加
* update: commit hash used in e2e
* fix: add _preRoundMode in _const
---
.github/workflows/e2e.yml | 4 +-
frontend/octavio/.env | 2 +
.../octavio/__e2e__/scoring/index.test.ts | 13 ++--
frontend/octavio/__e2e__/users.test.ts | 27 ++++---
.../octavio/__test__/pages/login.test.tsx | 18 ++---
.../__test__/pages/problems/index.test.tsx | 5 +-
.../__test__/pages/scoring/index.test.tsx | 21 -----
.../octavio/__test__/pages/signUp.test.tsx | 78 ++++++++++++++-----
.../octavio/__test__/pages/users.test.tsx | 3 +-
.../_components/answer-list-section.tsx | 33 +++++---
.../_components/multiple-answer-form.tsx | 2 +-
.../octavio/app/problems/[problemId]/page.tsx | 2 +-
frontend/octavio/app/problems/page.tsx | 42 ++++++++--
frontend/octavio/app/ranking/layout.tsx | 6 ++
frontend/octavio/app/scoring/page.tsx | 2 -
frontend/octavio/app/users/page.tsx | 4 +
frontend/octavio/components/_const.ts | 5 +-
.../octavio/components/markdown-preview.tsx | 4 +-
frontend/octavio/components/navbar.tsx | 15 ++--
frontend/octavio/components/problem-card.tsx | 27 +++++--
frontend/octavio/hooks/auth.ts | 12 ++-
frontend/octavio/hooks/problems.ts | 12 ++-
frontend/octavio/hooks/ranking.ts | 3 +-
frontend/octavio/types/Problem.ts | 4 +-
24 files changed, 222 insertions(+), 122 deletions(-)
diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml
index b43aa342..afbebec1 100644
--- a/.github/workflows/e2e.yml
+++ b/.github/workflows/e2e.yml
@@ -138,7 +138,7 @@ jobs:
with:
repository: ictsc/ictsc-rikka
path: ictsc-rikka
- ref: c9fb8c2731f6bd2d1eeb3c3083732e296162fa01
+ ref: 023061a63b1a2fb425939c36bcb7dd8bd2235b7c
# MariaDB cache
- name: Cache a MariaDB Docker image
@@ -252,7 +252,7 @@ jobs:
working-directory: ictsc-rikka
run: |
set +e # curlのエラーを無視する
- cp scripts/docker-compose.override.yml docker-compose.override.yml
+ cp scripts/compose.ci.yml compose.override.yml
make up
url="http://localhost:8080"
diff --git a/frontend/octavio/.env b/frontend/octavio/.env
index 8ca5d405..1bc8e9f1 100644
--- a/frontend/octavio/.env
+++ b/frontend/octavio/.env
@@ -10,3 +10,5 @@ NEXT_PUBLIC_RULE=
NEXT_PUBLIC_SHORT_RULE=
# 再展開時のモーダルに表示される再展開時の注意事項
NEXT_PUBLIC_RECREATE_RULE=
+# 予選モードを有効化
+NEXT_PUBLIC_PRE_ROUND_MODE=
\ No newline at end of file
diff --git a/frontend/octavio/__e2e__/scoring/index.test.ts b/frontend/octavio/__e2e__/scoring/index.test.ts
index 9fd5de0a..9282f484 100644
--- a/frontend/octavio/__e2e__/scoring/index.test.ts
+++ b/frontend/octavio/__e2e__/scoring/index.test.ts
@@ -20,7 +20,7 @@ test("画面項目が表示されること", async ({ page }) => {
const problem1 = problems.nth(0).locator("td");
await expect(problem1.nth(1)).toHaveText("1/1/1");
await expect(problem1.nth(2)).toHaveText(
- "00000000-0000-4000-a000-000000000000"
+ "00000000-0000-4000-a000-000000000000",
);
await expect(problem1.nth(3)).toHaveText("abc");
await expect(problem1.nth(4)).toHaveText("問題タイトル1");
@@ -28,12 +28,11 @@ test("画面項目が表示されること", async ({ page }) => {
await expect(problem1.nth(6)).toHaveText("100");
await expect(problem1.nth(7)).toHaveText("100");
await expect(problem1.nth(8)).toHaveText("");
- await expect(problem1.nth(9)).toHaveText("自分");
const problem2 = problems.nth(1).locator("td");
await expect(problem2.nth(1)).toHaveText("1/1/1");
await expect(problem2.nth(2)).toHaveText(
- "00000000-0000-4000-a000-000000000001"
+ "00000000-0000-4000-a000-000000000001",
);
await expect(problem2.nth(3)).toHaveText("def");
await expect(problem2.nth(4)).toHaveText("問題タイトル2");
@@ -41,12 +40,11 @@ test("画面項目が表示されること", async ({ page }) => {
await expect(problem2.nth(6)).toHaveText("200");
await expect(problem2.nth(7)).toHaveText("200");
await expect(problem2.nth(8)).toHaveText("");
- await expect(problem2.nth(9)).toHaveText("自分");
const problem3 = problems.nth(2).locator("td");
await expect(problem3.nth(1)).toHaveText("1/1/1");
await expect(problem3.nth(2)).toHaveText(
- "00000000-0000-4000-a000-000000000002"
+ "00000000-0000-4000-a000-000000000002",
);
await expect(problem3.nth(3)).toHaveText("ghi");
await expect(problem3.nth(4)).toHaveText("問題タイトル3");
@@ -54,7 +52,6 @@ test("画面項目が表示されること", async ({ page }) => {
await expect(problem3.nth(6)).toHaveText("300");
await expect(problem3.nth(7)).toHaveText("300");
await expect(problem3.nth(8)).toHaveText("");
- await expect(problem3.nth(9)).toHaveText("自分");
});
test("採点ページへ遷移できること", async ({ page }) => {
@@ -83,10 +80,10 @@ test("問題のプレビューができること", async ({ page }) => {
// then
await expect(ScoringPage.ProblemPreviewProblemInfo(page)).toHaveText(
- "問題タイトル1満点100 pt 採点基準100 pt採点する"
+ "問題タイトル1満点100 pt 採点基準100 pt採点する",
);
await expect(ScoringPage.ProblemPreviewProblemContent(page)).toHaveText(
- "問題内容1"
+ "問題内容1",
);
});
diff --git a/frontend/octavio/__e2e__/users.test.ts b/frontend/octavio/__e2e__/users.test.ts
index 84896afa..9f9a104d 100644
--- a/frontend/octavio/__e2e__/users.test.ts
+++ b/frontend/octavio/__e2e__/users.test.ts
@@ -20,45 +20,54 @@ test("画面項目が表示されること", async ({ page }) => {
const user1 = await cols.nth(0).locator("td");
await expect(user1.nth(0)).toHaveText("user1");
await expect(user1.nth(1)).toHaveText("team1");
- await expect(user1.nth(2)).toHaveText("自己紹介内容1");
+ await expect(user1.nth(2)).toHaveText("user-org1");
+ await expect(user1.nth(3)).toHaveText("自己紹介内容1");
const user2 = await cols.nth(1).locator("td");
await expect(user2.nth(0)).toHaveText("user2");
await expect(user2.nth(1)).toHaveText("team1");
- await expect(user2.nth(2)).toHaveText("");
+ await expect(user2.nth(2)).toHaveText("user-org1");
+ await expect(user2.nth(3)).toHaveText("");
const user3 = await cols.nth(2).locator("td");
await expect(user3.nth(0)).toHaveText("user3");
await expect(user3.nth(1)).toHaveText("team1");
- await expect(user3.nth(2)).toHaveText("");
+ await expect(user3.nth(2)).toHaveText("user-org1");
+ await expect(user3.nth(3)).toHaveText("");
const user4 = await cols.nth(3).locator("td");
await expect(user4.nth(0)).toHaveText("user4");
await expect(user4.nth(1)).toHaveText("team2");
- await expect(user4.nth(2)).toHaveText("自己紹介内容2");
+ await expect(user4.nth(2)).toHaveText("user-org2");
+ await expect(user4.nth(3)).toHaveText("自己紹介内容2");
const user5 = await cols.nth(4).locator("td");
await expect(user5.nth(0)).toHaveText("user5");
await expect(user5.nth(1)).toHaveText("team2");
- await expect(user5.nth(2)).toHaveText("");
+ await expect(user5.nth(2)).toHaveText("user-org2");
+ await expect(user5.nth(3)).toHaveText("");
const user6 = await cols.nth(5).locator("td");
await expect(user6.nth(0)).toHaveText("user6");
await expect(user6.nth(1)).toHaveText("team2");
- await expect(user6.nth(2)).toHaveText("");
+ await expect(user6.nth(2)).toHaveText("user-org2");
+ await expect(user6.nth(3)).toHaveText("");
const user7 = await cols.nth(6).locator("td");
await expect(user7.nth(0)).toHaveText("user7");
await expect(user7.nth(1)).toHaveText("team3");
- await expect(user7.nth(2)).toHaveText("自己紹介内容3");
+ await expect(user7.nth(2)).toHaveText("user-org3");
+ await expect(user7.nth(3)).toHaveText("自己紹介内容3");
const user8 = await cols.nth(7).locator("td");
await expect(user8.nth(0)).toHaveText("user8");
await expect(user8.nth(1)).toHaveText("team3");
- await expect(user8.nth(2)).toHaveText("");
+ await expect(user8.nth(2)).toHaveText("user-org3");
+ await expect(user8.nth(3)).toHaveText("");
const user9 = await cols.nth(8).locator("td");
await expect(user9.nth(0)).toHaveText("user9");
await expect(user9.nth(1)).toHaveText("team3");
- await expect(user9.nth(2)).toHaveText("");
+ await expect(user9.nth(2)).toHaveText("user-org3");
+ await expect(user9.nth(3)).toHaveText("");
});
diff --git a/frontend/octavio/__test__/pages/login.test.tsx b/frontend/octavio/__test__/pages/login.test.tsx
index b56e2549..5d22eb4b 100644
--- a/frontend/octavio/__test__/pages/login.test.tsx
+++ b/frontend/octavio/__test__/pages/login.test.tsx
@@ -63,7 +63,7 @@ describe("Login", () => {
expect(screen.queryByPlaceholderText("ユーザー名")).toBeInTheDocument();
expect(screen.queryByPlaceholderText("パスワード")).toBeInTheDocument();
expect(loginButton).toBeInTheDocument();
- expect(loginButton).not.toHaveAttribute("loading");
+ expect(loginButton).not.toHaveAttribute("btn-disabled");
// verify
expect(useAuth).toHaveBeenCalledTimes(1);
@@ -83,10 +83,10 @@ describe("Login", () => {
// then
expect(
- screen.queryByText("ユーザー名を入力してください")
+ screen.queryByText("ユーザー名を入力してください"),
).toBeInTheDocument();
expect(
- screen.queryByText("パスワードを入力して下さい")
+ screen.queryByText("パスワードを入力して下さい"),
).toBeInTheDocument();
// verify
@@ -109,10 +109,10 @@ describe("Login", () => {
// then
expect(
- screen.queryByText("ユーザー名を入力してください")
+ screen.queryByText("ユーザー名を入力してください"),
).toBeInTheDocument();
expect(
- screen.queryByText("パスワードを入力して下さい")
+ screen.queryByText("パスワードを入力して下さい"),
).not.toBeInTheDocument();
});
@@ -132,10 +132,10 @@ describe("Login", () => {
// then
expect(
- screen.queryByText("ユーザー名を入力してください")
+ screen.queryByText("ユーザー名を入力してください"),
).not.toBeInTheDocument();
expect(
- screen.queryByText("パスワードを入力して下さい")
+ screen.queryByText("パスワードを入力して下さい"),
).toBeInTheDocument();
// verify
@@ -214,7 +214,7 @@ describe("Login", () => {
setTimeout(() => {
resolve({ code: 200 });
}, 1000);
- })
+ }),
);
(useAuth as Mock).mockReturnValue({
user: null,
@@ -233,7 +233,7 @@ describe("Login", () => {
});
// then
- expect(loginButton).toHaveClass("loading");
+ expect(loginButton).toHaveClass("btn-disabled");
// verify
expect(useAuth).toHaveBeenCalledTimes(2);
diff --git a/frontend/octavio/__test__/pages/problems/index.test.tsx b/frontend/octavio/__test__/pages/problems/index.test.tsx
index 2958a93e..1f65df79 100644
--- a/frontend/octavio/__test__/pages/problems/index.test.tsx
+++ b/frontend/octavio/__test__/pages/problems/index.test.tsx
@@ -51,7 +51,7 @@ describe("Problems", () => {
expect(screen.queryByText("テスト通知タイトル")).toBeInTheDocument();
expect(screen.getAllByTestId("markdown-preview")[1]).toHaveAttribute(
"data-content",
- "テスト通知本文"
+ "テスト通知本文",
);
expect(screen.queryByText("XYZ")).toBeInTheDocument();
expect(screen.queryByText("テスト問題タイトル")).toBeInTheDocument();
@@ -203,6 +203,7 @@ describe("Problems", () => {
title: "title",
site: "site",
shortRule: "# ルール本文",
+ preRoundMode: false,
}));
(useRecoilState as Mock).mockReturnValue([[], vi.fn()]);
(useProblems as Mock).mockReturnValue({
@@ -218,7 +219,7 @@ describe("Problems", () => {
// then
expect(screen.getAllByTestId("markdown-preview")[0]).toHaveAttribute(
"data-content",
- "# ルール本文"
+ "# ルール本文",
);
// verify
diff --git a/frontend/octavio/__test__/pages/scoring/index.test.tsx b/frontend/octavio/__test__/pages/scoring/index.test.tsx
index d3f21100..12d8052a 100644
--- a/frontend/octavio/__test__/pages/scoring/index.test.tsx
+++ b/frontend/octavio/__test__/pages/scoring/index.test.tsx
@@ -130,7 +130,6 @@ describe("Scoring", () => {
expect(tds[6]).toHaveTextContent("100");
expect(tds[7]).toHaveTextContent("150");
expect(tds[8]).toHaveTextContent("");
- expect(tds[9]).toHaveTextContent("自分");
// then
expect(useAuth).toHaveBeenCalledTimes(1);
@@ -255,26 +254,6 @@ describe("Scoring", () => {
expect(useProblems).toHaveBeenCalledTimes(2);
});
- test("問題作成者id が自分でない場合空文字が表示される", () => {
- // setup
- (useAuth as Mock).mockReturnValue({
- user: testAdminUser,
- });
- (useProblems as Mock).mockReturnValue({
- problems: [{ ...testProblem, author_id: "other" }],
- isLoading: false,
- });
- render(