-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from kitcc-org/87-test-login-page
ログインページのテストを実装した
- Loading branch information
Showing
69 changed files
with
3,517 additions
and
511 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/vitest.yml → .github/workflows/backend_vitest.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Vitest | ||
name: Backend Vitest | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Frontend Vitest | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
vitest: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: frontend | ||
steps: | ||
- name: Checkout latest repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: 9 | ||
run_install: true | ||
|
||
- name: Run Vitest | ||
run: pnpm run test |
54 changes: 32 additions & 22 deletions
54
frontend/app/components/book-detail/BookDetailBorrower.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,49 @@ | ||
import { Badge, Blockquote, Group, Loader, rem, Stack, Text } from '@mantine/core' | ||
import { useGetLoans } from 'orval/client' | ||
import { | ||
Badge, | ||
Blockquote, | ||
Group, | ||
Loader, | ||
rem, | ||
Stack, | ||
Text, | ||
} from "@mantine/core"; | ||
import { useGetLoans } from "client/client"; | ||
import { MdError } from "react-icons/md"; | ||
|
||
const BookDetailBorrower = () => { | ||
const loans = useGetLoans() | ||
const loans = useGetLoans(); | ||
|
||
if (loans.isError) { | ||
return ( | ||
<Blockquote color="red" icon={<MdError />} mt="xl"> | ||
データの取得に失敗しました | ||
</Blockquote> | ||
) | ||
); | ||
} | ||
return ( | ||
<Stack | ||
gap='sm' | ||
align='stretch' | ||
justify='flex-start' | ||
> | ||
<Stack gap="sm" align="stretch" justify="flex-start"> | ||
<Text fz={rem(18)}>借りている人</Text> | ||
{loans.isPending ? <Loader color='blue' type='dots' /> : | ||
{loans.isPending ? ( | ||
<Loader color="blue" type="dots" /> | ||
) : ( | ||
<Group gap={rem(7)}> | ||
{loans.data.data.loans.map((loan) => loan.users && | ||
<Badge key={`${loan.loans?.userId}-${loan.loans?.bookId}`} | ||
variant="light" | ||
color="rgba(0, 0, 0, 1)" | ||
size='lg' | ||
> | ||
{loan.users.name} | ||
</Badge> | ||
{loans.data.data.loans.map( | ||
(loan) => | ||
loan.users && ( | ||
<Badge | ||
key={`${loan.loans?.userId}-${loan.loans?.bookId}`} | ||
variant="light" | ||
color="rgba(0, 0, 0, 1)" | ||
size="lg" | ||
> | ||
{loan.users.name} | ||
</Badge> | ||
) | ||
)} | ||
</Group> | ||
} | ||
)} | ||
</Stack> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default BookDetailBorrower | ||
export default BookDetailBorrower; |
35 changes: 17 additions & 18 deletions
35
frontend/app/components/book-detail/BookDetailComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
import { Stack, Grid, rem } from '@mantine/core' | ||
import ErrorComponent from '~/components/common/ErrorComponent' | ||
import { Grid, rem, Stack } from "@mantine/core"; | ||
import ErrorComponent from "~/components/common/ErrorComponent"; | ||
|
||
import BookDetailContent from './BookDetailContent' | ||
import { getBookResponse } from 'orval/client' | ||
import BookDetailControlPanel from './BookDetailControlPanel' | ||
import { getBookResponse } from "client/client"; | ||
import BookDetailContent from "./BookDetailContent"; | ||
import BookDetailControlPanel from "./BookDetailControlPanel"; | ||
|
||
interface BookDetailComponentProps { | ||
bookResponse: getBookResponse | ||
bookResponse: getBookResponse; | ||
} | ||
|
||
const BookDetailComponent = ({ bookResponse }: BookDetailComponentProps) => { | ||
switch (bookResponse.status) { | ||
case 400: | ||
return <ErrorComponent message='リクエストが不正です' /> | ||
return <ErrorComponent message="リクエストが不正です" />; | ||
case 404: | ||
return <ErrorComponent message='書籍が見つかりませんでした' /> | ||
return <ErrorComponent message="書籍が見つかりませんでした" />; | ||
case 500: | ||
return <ErrorComponent message='サーバーエラーが発生しました' /> | ||
return <ErrorComponent message="サーバーエラーが発生しました" />; | ||
} | ||
|
||
return ( | ||
<Stack | ||
bg="var(--mantine-color-body)" | ||
align="stretch" | ||
justify='flex-start' | ||
> | ||
<Stack bg="var(--mantine-color-body)" align="stretch" justify="flex-start"> | ||
<Grid gutter={rem(50)}> | ||
<Grid.Col span={3}> | ||
<BookDetailControlPanel id={bookResponse.data.id} thumbnail={bookResponse.data.thumbnail} /> | ||
<BookDetailControlPanel | ||
id={bookResponse.data.id} | ||
thumbnail={bookResponse.data.thumbnail} | ||
/> | ||
</Grid.Col> | ||
<Grid.Col span={9}> | ||
<BookDetailContent book={bookResponse.data} /> | ||
</Grid.Col> | ||
</Grid> | ||
</Stack> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default BookDetailComponent | ||
export default BookDetailComponent; |
30 changes: 15 additions & 15 deletions
30
frontend/app/components/book-detail/BookDetailContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
import { Stack } from '@mantine/core' | ||
import { Book } from 'orval/client.schemas' | ||
import BookDetailTitle from './BookDetailTitle' | ||
import BookDetailContentTable from './BookDetailContentTable' | ||
import BookDetailDescription from './BookDetailDescription' | ||
import { useAtom } from 'jotai' | ||
import { userAtom } from '~/stores/userAtom' | ||
import BookDetailBorrower from './BookDetailBorrower' | ||
import { Stack } from "@mantine/core"; | ||
import { Book } from "client/client.schemas"; | ||
import { useAtom } from "jotai"; | ||
import { userAtom } from "~/stores/userAtom"; | ||
import BookDetailBorrower from "./BookDetailBorrower"; | ||
import BookDetailContentTable from "./BookDetailContentTable"; | ||
import BookDetailDescription from "./BookDetailDescription"; | ||
import BookDetailTitle from "./BookDetailTitle"; | ||
|
||
interface BookDetailComponentProps { | ||
book: Book | ||
book: Book; | ||
} | ||
|
||
const BookDetailContent = ({ book }: BookDetailComponentProps) => { | ||
const [user] = useAtom(userAtom) | ||
const [user] = useAtom(userAtom); | ||
return ( | ||
<Stack | ||
bg="var(--mantine-color-body)" | ||
align="stretch" | ||
justify='flex-start' | ||
gap='xl' | ||
justify="flex-start" | ||
gap="xl" | ||
> | ||
<BookDetailTitle title={book.title} /> | ||
<BookDetailContentTable book={book} /> | ||
<BookDetailDescription description={book.description} /> | ||
{!!user && <BookDetailBorrower />} | ||
</Stack> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default BookDetailContent | ||
export default BookDetailContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 12 additions & 9 deletions
21
frontend/app/components/book-search/BookSearchAuthorForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import { TextInput } from '@mantine/core' | ||
import type { UseFormReturnType } from '@mantine/form' | ||
import type { GetBooksParams } from 'orval/client.schemas' | ||
import { TextInput } from "@mantine/core"; | ||
import type { UseFormReturnType } from "@mantine/form"; | ||
import type { GetBooksParams } from "client/client.schemas"; | ||
|
||
interface BookSearchAuthorFormProps { | ||
form: UseFormReturnType<GetBooksParams, (values: GetBooksParams) => GetBooksParams> | ||
form: UseFormReturnType< | ||
GetBooksParams, | ||
(values: GetBooksParams) => GetBooksParams | ||
>; | ||
} | ||
|
||
const BookSearchAuthorForm = ({ form }: BookSearchAuthorFormProps) => { | ||
return ( | ||
<TextInput | ||
label="筆者" | ||
placeholder="竹岡尚三" | ||
key={form.key('author')} | ||
{...form.getInputProps('author')} | ||
key={form.key("author")} | ||
{...form.getInputProps("author")} | ||
/> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default BookSearchAuthorForm | ||
export default BookSearchAuthorForm; |
29 changes: 16 additions & 13 deletions
29
frontend/app/components/book-search/BookSearchComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
import BookSearchModeButton from './BookSearchModeButton' | ||
import type { UseFormReturnType } from '@mantine/form' | ||
import type { GetBooksParams } from 'orval/client.schemas' | ||
import BookSearchForm from './BookSearchForm' | ||
import type { UseFormReturnType } from "@mantine/form"; | ||
import type { GetBooksParams } from "client/client.schemas"; | ||
import BookSearchForm from "./BookSearchForm"; | ||
import BookSearchModeButton from "./BookSearchModeButton"; | ||
|
||
interface BookSearchComponentProps { | ||
isOpen: boolean | ||
open: () => void | ||
close: () => void | ||
form: UseFormReturnType<GetBooksParams, (values: GetBooksParams) => GetBooksParams> | ||
handleSubmit: (props: GetBooksParams) => void | ||
isOpen: boolean; | ||
open: () => void; | ||
close: () => void; | ||
form: UseFormReturnType< | ||
GetBooksParams, | ||
(values: GetBooksParams) => GetBooksParams | ||
>; | ||
handleSubmit: (props: GetBooksParams) => void; | ||
} | ||
|
||
const BookSearchComponent = ({ | ||
isOpen, | ||
open, | ||
close, | ||
form, | ||
handleSubmit | ||
handleSubmit, | ||
}: BookSearchComponentProps) => { | ||
return ( | ||
<> | ||
<BookSearchModeButton isOpen={isOpen} open={open} close={close} /> | ||
<BookSearchForm isOpen={isOpen} form={form} handleSubmit={handleSubmit} /> | ||
</> | ||
) | ||
} | ||
); | ||
}; | ||
|
||
export default BookSearchComponent | ||
export default BookSearchComponent; |
Oops, something went wrong.