Skip to content

Commit

Permalink
Merge pull request #375 from eatski/main
Browse files Browse the repository at this point in the history
Release to Production
  • Loading branch information
eatski authored Aug 13, 2024
2 parents 7c5b0f5 + eb3b431 commit fda4a11
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 230 deletions.
7 changes: 0 additions & 7 deletions __test__/story.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { test, expect } from '@playwright/test';
import { PrismaClient } from '@prisma/client';
import { resolveFixturePath } from '../fixtures';
import { generateId } from '@/common/util/id';
import { RECAPTCHA_COOKIE_KEY } from '@/common/util/grecaptcha';

const BASE_URL = 'http://localhost:3000';

Expand Down Expand Up @@ -58,12 +57,6 @@ test('質問の送信', async ({ page }) => {
})

await page.goto(BASE_URL + "/stories/" + storyId);
process.env.MACHINE_TOKEN && await page.context().addCookies([{
name: RECAPTCHA_COOKIE_KEY,
value: process.env.MACHINE_TOKEN,
url: BASE_URL,
httpOnly: true
}]);
await page.waitForLoadState("networkidle")
const input = await page.getByRole('textbox', { name: "AIへの質問" });
await input.fill("あなたはAIですか?");
Expand Down
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build-storybook": "storybook build"
},
"dependencies": {
"@anthropic-ai/sdk": "0.25.1",
"@anthropic-ai/sdk": "0.25.2",
"@hookform/resolvers": "3.1.0",
"@prisma/client": "5.18.0",
"@szhsin/react-menu": "4.2.2",
Expand All @@ -32,7 +32,7 @@
"mustache": "4.2.0",
"next": "14.2.5",
"next-auth": "4.24.7",
"openai": "4.55.4",
"openai": "4.55.5",
"randomstring": "1.3.0",
"react": "18.3.1",
"react-copy-to-clipboard": "5.1.0",
Expand All @@ -54,7 +54,7 @@
"devDependencies": {
"@axe-core/playwright": "4.9.1",
"@biomejs/biome": "1.8.3",
"@eslint/config-array": "0.17.1",
"@eslint/config-array": "0.18.0",
"@eslint/object-schema": "2.1.4",
"@next/bundle-analyzer": "14.2.5",
"@playwright/test": "1.46.0",
Expand Down
3 changes: 0 additions & 3 deletions src/app/stories/[storyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { getUserSession } from "@/server/serverComponent/getUserSession";
import { setupABTestValue } from "@/server/serverComponent/setupABTestingVariant";
import { checkAnswer } from "@/server/services/answer";
import { askQuestion } from "@/server/services/question";
import { verifyRecaptcha } from "@/server/services/recaptcha";
import { getStories, getStory } from "@/server/services/story";
import { deleteStory } from "@/server/services/story/deleteStory";
import {
Expand Down Expand Up @@ -187,12 +186,10 @@ export default async function StoryPage({ params: { storyId } }: StoryProps) {
}}
sendQuestion={async (input) => {
"use server";
await verifyRecaptcha(input.recaptchaToken);
return askQuestion(input.text, story, setupABTestValue());
}}
checkAnswer={async (input) => {
"use server";
await verifyRecaptcha(input.recaptchaToken);
return checkAnswer(input.text, story);
}}
postStoryEvalution={async () => {
Expand Down
1 change: 1 addition & 0 deletions src/app/verification/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default async function Verification() {}
21 changes: 0 additions & 21 deletions src/common/util/grecaptcha.ts

This file was deleted.

11 changes: 1 addition & 10 deletions src/components/play/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import { CLIENT_KEY, getRecaptchaToken } from "@/common/util/grecaptcha";
import { gtagEvent } from "@/common/util/gtag";
import { Button } from "@/designSystem/components/button";
import type {
Expand All @@ -8,7 +7,6 @@ import type {
answer as answerSchema,
} from "@/server/model/story";
import { useMutation, useQuery } from "@tanstack/react-query";
import Script from "next/script";
import { useCallback, useState } from "react";
import { z } from "zod";
import { useConfirmModal } from "../confirmModal";
Expand All @@ -35,14 +33,12 @@ type Props = {
>;
sendQuestion: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
answer: z.infer<typeof answerSchema>;
hitQuestionExample: QuestionExampleWithCustomMessage | null;
}>;
checkAnswer: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
isCorrect: boolean;
distance: number;
Expand All @@ -55,7 +51,6 @@ const AnswerFormContainer: React.FC<{
changeMode: (mode: Mode) => void;
checkAnswer: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
isCorrect: boolean;
distance: number;
Expand All @@ -66,7 +61,6 @@ const AnswerFormContainer: React.FC<{
async (text: string) => {
const response = await checkAnswer({
text: text,
recaptchaToken: await getRecaptchaToken(),
});
return {
...response,
Expand Down Expand Up @@ -159,12 +153,9 @@ export function Play({
return <MobileLimitation />;
}
}

return (
<>
<Script
strategy="lazyOnload"
src={`https://www.google.com/recaptcha/api.js?render=${CLIENT_KEY}`}
/>
{mode === "question" && (
<div className={styles.sectionWrapper}>
<QuestionForm
Expand Down
7 changes: 0 additions & 7 deletions src/components/play/useQuestion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
vitest,
} from "vitest";

import * as recapcha from "../../common/util/grecaptcha";

const Provider: React.FC<PropsWithChildren> = ({ children }) => {
const queryClient = useMemo(() => new QueryClient(), []);
return (
Expand All @@ -30,9 +28,6 @@ describe("useQuestion", () => {

beforeEach(() => {
server.listen();
vi.spyOn(recapcha, "getRecaptchaToken").mockReturnValue(
Promise.resolve("test"),
);
});

afterEach(() => {
Expand Down Expand Up @@ -115,13 +110,11 @@ describe("useQuestion", () => {
[
[
{
"recaptchaToken": "test",
"text": "太郎は犬ですか?",
},
],
[
{
"recaptchaToken": "test",
"text": "太郎は猫ですか?",
},
],
Expand Down
3 changes: 0 additions & 3 deletions src/components/play/useQuestion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMutation } from "@tanstack/react-query";
import { useRef, useState } from "react";
import { z } from "zod";
import { getRecaptchaToken } from "../../common/util/grecaptcha";
import type {
Answer,
QuestionExampleWithCustomMessage,
Expand Down Expand Up @@ -48,7 +47,6 @@ const useMutableHistory = () => {
export const useQuestion = (
sendQuestion: (args: {
text: string;
recaptchaToken: string;
}) => Promise<{
answer: z.infer<typeof answer>;
hitQuestionExample: QuestionExampleWithCustomMessage | null;
Expand All @@ -69,7 +67,6 @@ export const useQuestion = (
const id = pushHistory({ input: text, result: null });
const result = await mutateAsync({
text,
recaptchaToken: await getRecaptchaToken(),
});
const simpleMessage = (
{
Expand Down
45 changes: 0 additions & 45 deletions src/libs/proura/index.test.ts

This file was deleted.

Loading

0 comments on commit fda4a11

Please sign in to comment.