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

Docs/rotas dinamicas #64

Closed
Closed
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
12 changes: 12 additions & 0 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@faker-js/faker": "^9.0.0",
"@hookform/error-message": "^2.0.1",
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-slot": "^1.1.0",
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/app/(users)/register/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use client'
import { useFormState, useFormStatus } from 'react-dom'

import { AlertBox } from '@/components/form/alert-box'
import { ErrorMessage } from '@/components/form/error-message'
import { AlertBox } from '@/components/ui/alert-box'
import { Button } from '@/components/ui/button'
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '@/components/ui/card'
import { ErrorMessage } from '@/components/ui/error-message'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { createUser } from '@/services/user-actions'
import { createUser } from '@/services/user-service'


const initialState = {
status: null,
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/ui/alert-box/alert-boc.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { Status } from '@/app/(mentoring)/mentoring.type'

import { AlertBox } from './'

describe('AlertBox Component', () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/ui/button/button.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen, fireEvent } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { Button } from '.'

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/ui/card/card.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Card.test.tsx
import React from 'react'
import { render, screen } from '@testing-library/react'
import React from 'react'
import { describe, it, expect, vi } from 'vitest'

import { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } from '.'

describe('Card Components', () => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/ui/card/card.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
import Image from 'next/image'

import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './index'

Expand Down Expand Up @@ -57,7 +58,7 @@ export const WithImage: Story = {
render: () => (
<Card>
<CardHeader>
<img src="https://via.placeholder.com/150" alt="Placeholder Image" />
<Image src="https://via.placeholder.com/150" alt="Placeholder Image" />
<CardTitle>Card with Image</CardTitle>
<CardDescription>This card has an image in the header.</CardDescription>
</CardHeader>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { render, screen } from '@testing-library/react'
import { describe, it, expect } from 'vitest'

import { ErrorMessage } from './'

Expand Down
5 changes: 4 additions & 1 deletion frontend/src/components/ui/input/input.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { fireEvent, render } from '@testing-library/react'
import React from 'react'
import { describe, expect } from 'vitest'

import { Input } from '.'

import React from 'react'


describe('<Input />', () => {
test('applies custom class', () => {
Expand Down
17 changes: 11 additions & 6 deletions frontend/src/infra/http/HttpClient.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { describe, it, expect, beforeEach } from 'vitest'
import axios, { AxiosInstance, AxiosResponse, AxiosError } from 'axios'
import { HttpMethod, HttpRequest } from './HttpClient.types'
import { describe, it, expect, beforeEach, vi } from 'vitest'

import { HttpAxiosAdapter } from './HttpClient'
import { HttpMethod, HttpRequest } from './HttpClient.types'


// Mock do axios
vi.mock('axios', () => ({
Expand All @@ -11,10 +13,12 @@ vi.mock('axios', () => ({
}))

describe('HttpAxiosAdapter', () => {
// @ts-expect-error
let mockAxios: { request: vi.Mock }
let httpClient: HttpAxiosAdapter

beforeEach(() => {
// @ts-expect-error
mockAxios = axios as unknown as { request: vi.Mock }
httpClient = new HttpAxiosAdapter(mockAxios as unknown as AxiosInstance)
})
Expand All @@ -25,7 +29,7 @@ describe('HttpAxiosAdapter', () => {
endpoint: '/test',
method: HttpMethod.GET,
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand All @@ -49,7 +53,7 @@ describe('HttpAxiosAdapter', () => {
body: { key: 'value' },
headers: { 'Content-Type': 'application/json' },
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand Down Expand Up @@ -78,7 +82,7 @@ describe('HttpAxiosAdapter', () => {
data: errorMessage,
},
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockRejectedValueOnce(errorResponse as AxiosError)

await expect(httpClient.request(request)).rejects.toThrow(
Expand All @@ -100,6 +104,7 @@ describe('HttpAxiosAdapter', () => {
}

const networkError = new Error('Network Error')
// @ts-expect-error
;(mockAxios.request as vi.Mock).mockRejectedValueOnce(networkError)

await expect(httpClient.request(request)).rejects.toThrow(
Expand All @@ -120,7 +125,7 @@ describe('HttpAxiosAdapter', () => {
endpoint: '/no-header-no-body',
method: HttpMethod.DELETE,
}

// @ts-expect-error
;(mockAxios.request as vi.Mock).mockResolvedValueOnce({
data: responseData,
} as AxiosResponse<typeof responseData>)
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'vitest'

import { cn } from './utils' // Ajuste o caminho conforme necessário

describe('cn', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { describe, test, expect } from 'vitest'

import { MentoringAgendaService } from './MentoringAgenda.service'

import { SchemaMentoringType } from '@/app/(mentoring)/mentoring.type'
import {
httpClientMockFail,
httpClientMockSuccess,
mockResponse,
} from '@/tests/mock/httpClientMock'

import { MentoringAgendaService } from './MentoringAgenda.service'

const mockUserData: SchemaMentoringType = {
name: 'John Doe',
email: '[email protected]',
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/services/user-service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import axios from 'axios'

const createUser = async (data: any) => {
try {
const response = await axios.post('/api/users', data)
return response.data
} catch (error) {
console.error(error)
throw error
}
}

export { createUser }
1 change: 1 addition & 0 deletions frontend/src/tests/changeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { fireEvent } from '@testing-library/react'
import { expect } from 'vitest'

type ChangeInputProps = {
input: HTMLInputElement
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/mock/mockSchemaMentoringTypeData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaMentoringType } from '../../app/(mentoring)/mentoring.type'
import { SchemaMentoringType } from '@/app/(mentoring)/mentoring.type'

export const mockSchemaMentoringTypeData: SchemaMentoringType = {
name: 'John Doe',
Expand Down
1 change: 1 addition & 0 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { resolve } from 'path'

import react from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config'

Expand Down
Loading