Skip to content
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

選択式問題に対応 #101

Merged
merged 13 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/backend-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
workdir: backend
fail_on_error: true
filter_mode: nofilter
args: --timeout=10m
build:
name: Build
runs-on: ubuntu-latest
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Checkout zenn-editor repository
uses: actions/checkout@v3
with:
repository: ictsc/zenn-editor
ref: feature/add-checkbox-and-radio
path: frontend/octavio/local-modules/zenn-editor

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
Expand All @@ -63,6 +70,20 @@ jobs:
cache: 'pnpm'
cache-dependency-path: frontend/octavio/pnpm-lock.yaml

- name: Cache zenn-editor dependencies
uses: actions/cache@v3
with:
path: frontend/octavio/local-modules/zenn-editor/node_modules
key: zenn-editor-deps-${{ hashFiles('frontend/octavio/local-modules/zenn-editor/pnpm-lock.yaml') }}

- name: Install zenn-editor dependencies
working-directory: frontend/octavio/local-modules/zenn-editor
run: pnpm i --frozen-lockfile

- name: Build zenn-editor
working-directory: frontend/octavio/local-modules/zenn-editor
run: pnpm build --filter zenn-markdown-html

- name: Install dependencies
working-directory: frontend/octavio
run: pnpm i --frozen-lockfile
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "frontend/octavio/local-modules/zenn-editor"]
path = frontend/octavio/local-modules/zenn-editor
url = https://github.com/ictsc/zenn-editor.git
1 change: 1 addition & 0 deletions dev/cspell/cspell.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ ignorePaths:
- "**/.golangci.yaml"
- "**/go.mod"
- "**/go.sum"
- "**/local-modules"
2 changes: 2 additions & 0 deletions dev/cspell/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ daisyui
Duardo
exhaustruct
ictsc
ictscr
ictscc
ireturn
Kairi
Kaleb
Expand Down
21 changes: 7 additions & 14 deletions frontend/octavio/__test__/pages/problems/[problemId].test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import { testReCreateInfo } from "@/types/ReCreate";
import { testUser } from "@/types/User";

vi.mock("react");
vi.mock("next/error", () => ({
__esModule: true,
default: ({ statusCode }: { statusCode: number }) => (
<div data-testid="error" data-status-code={statusCode} />
),
vi.mock("next/navigation", () => ({
notFound: () => <div data-testid="error" />,
}));
vi.mock("@/components/_const", () => ({
title: "title",
Expand Down Expand Up @@ -80,7 +77,7 @@ describe("[problemId]", () => {

// then
expect(
screen.queryByRole("button", { name: "再展開を行う" })
screen.queryByRole("button", { name: "再展開を行う" }),
).not.toBeInTheDocument();
expect(screen.queryByTestId("answerForm")).not.toBeInTheDocument();
expect(screen.queryByTestId("answerListSection")).toBeInTheDocument();
Expand Down Expand Up @@ -131,10 +128,6 @@ describe("[problemId]", () => {

// then
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// verify
expect(useAuth).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -164,11 +157,11 @@ describe("[problemId]", () => {

// then
expect(
screen.queryByText("問題の再展開を行います。よろしいですか?")
screen.queryByText("問題の再展開を行います。よろしいですか?"),
).toBeInTheDocument();
expect(screen.getAllByTestId("markdown-preview")[0]).toHaveAttribute(
"data-content",
"テスト再展開ルール"
"テスト再展開ルール",
);

// verify
Expand Down Expand Up @@ -257,7 +250,7 @@ describe("[problemId]", () => {

// then
expect(
screen.queryByRole("button", { name: "再展開を行う" })
screen.queryByRole("button", { name: "再展開を行う" }),
).toBeInTheDocument();
expect(screen.queryByTestId("answerForm")).toBeInTheDocument();
expect(screen.queryByTestId("answerListSection")).toBeInTheDocument();
Expand Down Expand Up @@ -285,7 +278,7 @@ describe("[problemId]", () => {

// then
expect(
screen.queryByRole("button", { name: "再展開を行う" })
screen.queryByRole("button", { name: "再展開を行う" }),
).not.toBeInTheDocument();
expect(screen.queryByTestId("answerForm")).not.toBeInTheDocument();
expect(screen.queryByTestId("answerListSection")).toBeInTheDocument();
Expand Down
13 changes: 3 additions & 10 deletions frontend/octavio/__test__/pages/profile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@ import Profile from "@/app/profile/page";
import useAuth from "@/hooks/auth";
import { testUser } from "@/types/User";

vi.mock("next/error", () => ({
__esModule: true,
default: ({ statusCode }: { statusCode: number }) => (
<div data-testid="error" data-status-code={statusCode} />
),
vi.mock("next/navigation", () => ({
notFound: () => <div data-testid="error" />,
}));
vi.mock("@/hooks/auth");
vi.mock("@/components/Alerts", () => ({
Expand Down Expand Up @@ -109,10 +106,6 @@ describe("Profile", () => {

// then
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// verify
expect(useAuth).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -327,7 +320,7 @@ describe("Profile", () => {
expect(alert).toBeInTheDocument();
expect(alert).toHaveAttribute(
"data-message",
"プロフィールの更新に失敗しました"
"プロフィールの更新に失敗しました",
);
expect(alert).not.toHaveAttribute("data-sub-message");

Expand Down
26 changes: 2 additions & 24 deletions frontend/octavio/__test__/pages/scoring/[code].test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@ import { Answer, testAnswer } from "@/types/Answer";
import { testProblem } from "@/types/Problem";
import { testAdminUser, testUser } from "@/types/User";

vi.mock("next/error", () => ({
__esModule: true,
default: ({ statusCode }: { statusCode: number }) => (
<div data-testid="error" data-status-code={statusCode} />
),
}));
vi.mock("next/navigation", () => ({
...require("next-router-mock"),
useSearchParams: vi.fn().mockReturnValue({
get: vi.fn().mockReturnValue(null),
}),
notFound: () => <div data-testid="error" />,
}));

vi.mock("react-hook-form", () => ({
useForm: vi.fn(),
}));
Expand Down Expand Up @@ -82,10 +76,6 @@ describe("ScoringProblem", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand All @@ -109,10 +99,6 @@ describe("ScoringProblem", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand All @@ -136,10 +122,6 @@ describe("ScoringProblem", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand All @@ -163,10 +145,6 @@ describe("ScoringProblem", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -506,7 +484,7 @@ describe("ScoringProblem", () => {
// then
expect(screen.queryByTestId("scoring-answer-form")).toHaveAttribute(
"data-key",
"1"
"1",
);
});
});
23 changes: 3 additions & 20 deletions frontend/octavio/__test__/pages/scoring/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import "@testing-library/jest-dom";

import React from "react";

import { act, render, screen } from "@testing-library/react";
import { Mock, vi } from "vitest";

Expand All @@ -11,11 +9,8 @@ import useProblems from "@/hooks/problems";
import { testProblem } from "@/types/Problem";
import { testAdminUser, testUser } from "@/types/User";

vi.mock("next/error", () => ({
__esModule: true,
default: ({ statusCode }: { statusCode: number }) => (
<div data-testid="error" data-status-code={statusCode} />
),
vi.mock("next/navigation", () => ({
notFound: () => <div data-testid="error" />,
}));
vi.mock("next/router", () => require("next-router-mock"));
vi.mock("@/hooks/auth");
Expand Down Expand Up @@ -50,10 +45,6 @@ describe("Scoring", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand All @@ -73,10 +64,6 @@ describe("Scoring", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand All @@ -96,10 +83,6 @@ describe("Scoring", () => {

// when
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// then
expect(useAuth).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -312,7 +295,7 @@ describe("Scoring", () => {
// then
expect(screen.getByTestId("markdown-preview")).toHaveAttribute(
"data-content",
"# テスト本文"
"# テスト本文",
);

// verify
Expand Down
27 changes: 10 additions & 17 deletions frontend/octavio/__test__/pages/users.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ import useUserGroups from "@/hooks/userGroups";
import { testUser } from "@/types/User";
import { testUserGroup } from "@/types/UserGroup";

vi.mock("next/error", () => ({
__esModule: true,
default: ({ statusCode }: { statusCode: number }) => (
<div data-testid="error" data-status-code={statusCode} />
),
vi.mock("next/navigation", () => ({
notFound: () => <div data-testid="error" />,
}));
vi.mock("@/hooks/userGroups");
vi.mock("@/components/LoadingPage", () => ({
Expand Down Expand Up @@ -45,15 +42,15 @@ describe("Users", () => {
const links = screen.getAllByRole("link");
expect(links[0]).toHaveAttribute(
"href",
`https://github.com/${testUser.profile?.github_id}`
`https://github.com/${testUser.profile?.github_id}`,
);
expect(links[1]).toHaveAttribute(
"href",
`https://twitter.com/${testUser.profile?.twitter_id}`
`https://twitter.com/${testUser.profile?.twitter_id}`,
);
expect(links[2]).toHaveAttribute(
"href",
`https://www.facebook.com/${testUser.profile?.facebook_id}`
`https://www.facebook.com/${testUser.profile?.facebook_id}`,
);

// verify
Expand Down Expand Up @@ -89,10 +86,6 @@ describe("Users", () => {

// then
expect(screen.getByTestId("error")).toBeInTheDocument();
expect(screen.getByTestId("error")).toHaveAttribute(
"data-status-code",
"404"
);

// verify
expect(useUserGroups).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -147,11 +140,11 @@ describe("Users", () => {
const links = screen.getAllByRole("link");
expect(links[0]).toHaveAttribute(
"href",
`https://twitter.com/${testUser.profile?.twitter_id}`
`https://twitter.com/${testUser.profile?.twitter_id}`,
);
expect(links[1]).toHaveAttribute(
"href",
`https://www.facebook.com/${testUser.profile?.facebook_id}`
`https://www.facebook.com/${testUser.profile?.facebook_id}`,
);

// verify
Expand All @@ -176,7 +169,7 @@ describe("Users", () => {
const links = screen.getAllByRole("link");
expect(links[0]).toHaveAttribute(
"href",
`https://github.com/${testUser.profile?.github_id}`
`https://github.com/${testUser.profile?.github_id}`,
);

// verify
Expand All @@ -201,11 +194,11 @@ describe("Users", () => {
const links = screen.getAllByRole("link");
expect(links[0]).toHaveAttribute(
"href",
`https://github.com/${testUser.profile?.github_id}`
`https://github.com/${testUser.profile?.github_id}`,
);
expect(links[1]).toHaveAttribute(
"href",
`https://twitter.com/${testUser.profile?.twitter_id}`
`https://twitter.com/${testUser.profile?.twitter_id}`,
);

// verify
Expand Down
Loading
Loading