Skip to content

Commit

Permalink
update: 予選用カスタムを追加 (#114)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
K-shir0 authored Dec 18, 2023
1 parent 72e8b2c commit c8421f1
Show file tree
Hide file tree
Showing 24 changed files with 222 additions and 122 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions frontend/octavio/.env
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ NEXT_PUBLIC_RULE=
NEXT_PUBLIC_SHORT_RULE=
# 再展開時のモーダルに表示される再展開時の注意事項
NEXT_PUBLIC_RECREATE_RULE=
# 予選モードを有効化
NEXT_PUBLIC_PRE_ROUND_MODE=
13 changes: 5 additions & 8 deletions frontend/octavio/__e2e__/scoring/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,38 @@ 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");
await expect(problem1.nth(5)).toHaveText("--- code: abc title:...");
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");
await expect(problem2.nth(5)).toHaveText("問題内容2...");
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");
await expect(problem3.nth(5)).toHaveText("問題内容3...");
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 }) => {
Expand Down Expand Up @@ -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",
);
});

Expand Down
27 changes: 18 additions & 9 deletions frontend/octavio/__e2e__/users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
});
18 changes: 9 additions & 9 deletions frontend/octavio/__test__/pages/login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -83,10 +83,10 @@ describe("Login", () => {

// then
expect(
screen.queryByText("ユーザー名を入力してください")
screen.queryByText("ユーザー名を入力してください"),
).toBeInTheDocument();
expect(
screen.queryByText("パスワードを入力して下さい")
screen.queryByText("パスワードを入力して下さい"),
).toBeInTheDocument();

// verify
Expand All @@ -109,10 +109,10 @@ describe("Login", () => {

// then
expect(
screen.queryByText("ユーザー名を入力してください")
screen.queryByText("ユーザー名を入力してください"),
).toBeInTheDocument();
expect(
screen.queryByText("パスワードを入力して下さい")
screen.queryByText("パスワードを入力して下さい"),
).not.toBeInTheDocument();
});

Expand All @@ -132,10 +132,10 @@ describe("Login", () => {

// then
expect(
screen.queryByText("ユーザー名を入力してください")
screen.queryByText("ユーザー名を入力してください"),
).not.toBeInTheDocument();
expect(
screen.queryByText("パスワードを入力して下さい")
screen.queryByText("パスワードを入力して下さい"),
).toBeInTheDocument();

// verify
Expand Down Expand Up @@ -214,7 +214,7 @@ describe("Login", () => {
setTimeout(() => {
resolve({ code: 200 });
}, 1000);
})
}),
);
(useAuth as Mock).mockReturnValue({
user: null,
Expand All @@ -233,7 +233,7 @@ describe("Login", () => {
});

// then
expect(loginButton).toHaveClass("loading");
expect(loginButton).toHaveClass("btn-disabled");

// verify
expect(useAuth).toHaveBeenCalledTimes(2);
Expand Down
5 changes: 3 additions & 2 deletions frontend/octavio/__test__/pages/problems/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -203,6 +203,7 @@ describe("Problems", () => {
title: "title",
site: "site",
shortRule: "# ルール本文",
preRoundMode: false,
}));
(useRecoilState as Mock).mockReturnValue([[], vi.fn()]);
(useProblems as Mock).mockReturnValue({
Expand All @@ -218,7 +219,7 @@ describe("Problems", () => {
// then
expect(screen.getAllByTestId("markdown-preview")[0]).toHaveAttribute(
"data-content",
"# ルール本文"
"# ルール本文",
);

// verify
Expand Down
21 changes: 0 additions & 21 deletions frontend/octavio/__test__/pages/scoring/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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(<Index />);
const tds = screen.queryAllByRole("cell");

// when
expect(tds[9]).toHaveTextContent("");

// then
expect(useAuth).toHaveBeenCalledTimes(1);
expect(useProblems).toHaveBeenCalledTimes(2);
});

test("問題をクリックした場合、問題文が表示される", async () => {
// setup
(useAuth as Mock).mockReturnValue({
Expand Down
Loading

0 comments on commit c8421f1

Please sign in to comment.