mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-02-07 11:42:55 +00:00
Fixed a Small Error and Updated/Added Tests
This commit is contained in:
parent
4f205d7584
commit
3a095e2096
9 changed files with 105 additions and 14 deletions
9
.github/workflows/tests.yml
vendored
9
.github/workflows/tests.yml
vendored
|
@ -28,7 +28,16 @@ jobs:
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: yarn coverage
|
run: yarn coverage
|
||||||
|
|
||||||
|
- name: Generate junit.xml
|
||||||
|
run: JEST_JUNIT_CLASSNAME=\"{filepath}\" jest --reporters=jest-junit
|
||||||
|
|
||||||
- name: Upload results to Codecov
|
- name: Upload results to Codecov
|
||||||
uses: codecov/codecov-action@v5
|
uses: codecov/codecov-action@v5
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
|
- name: Upload junit.xml to Codecov
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
uses: codecov/test-results-action@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
49
__tests__/board-title-form.test.tsx
Normal file
49
__tests__/board-title-form.test.tsx
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import '@testing-library/jest-dom';
|
||||||
|
import { render, screen, fireEvent, act } from '@testing-library/react';
|
||||||
|
|
||||||
|
import { BoardTitleForm } from '@/app/(platform)/(dashboard)/board/[boardId]/_components/board-title-form';
|
||||||
|
import { Board } from '@prisma/client';
|
||||||
|
|
||||||
|
jest.mock('sonner', () => ({
|
||||||
|
toast: {
|
||||||
|
success: jest.fn(),
|
||||||
|
error: jest.fn(),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
jest.mock('@/actions/update-board', () => ({
|
||||||
|
updateBoard: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('BoardTitleForm', () => {
|
||||||
|
const mockBoard: Board = {
|
||||||
|
id: '1',
|
||||||
|
title: 'Test Board',
|
||||||
|
imageId: 'image1',
|
||||||
|
imageThumbUrl: 'thumb-url',
|
||||||
|
imageFullUrl: 'full-url',
|
||||||
|
imageUserName: 'user1',
|
||||||
|
imageLinkHTML: 'link-html',
|
||||||
|
imageDownloadUrl: 'download-url',
|
||||||
|
createdAt: new Date(),
|
||||||
|
updatedAt: new Date(),
|
||||||
|
orgId: 'org1',
|
||||||
|
};
|
||||||
|
|
||||||
|
it('should render correctly in browser environment', () => {
|
||||||
|
render(<BoardTitleForm data={mockBoard} />);
|
||||||
|
|
||||||
|
const titleButton = screen.getByText('Test Board');
|
||||||
|
expect(titleButton).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should switch to edit mode when clicked', async () => {
|
||||||
|
render(<BoardTitleForm data={mockBoard} />);
|
||||||
|
|
||||||
|
const titleButton = screen.getByText('Test Board');
|
||||||
|
fireEvent.click(titleButton);
|
||||||
|
|
||||||
|
const input = await screen.findByDisplayValue('Test Board');
|
||||||
|
expect(input).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
|
@ -8,6 +8,7 @@ describe('Home', () => {
|
||||||
const { container } = render(<Page />);
|
const { container } = render(<Page />);
|
||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a heading', () => {
|
it('renders a heading', () => {
|
||||||
render(<Page />);
|
render(<Page />);
|
||||||
|
|
||||||
|
@ -15,4 +16,12 @@ describe('Home', () => {
|
||||||
|
|
||||||
expect(heading).toBeInTheDocument();
|
expect(heading).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders a get started button', () => {
|
||||||
|
render(<Page />);
|
||||||
|
|
||||||
|
const link = screen.getByRole('link', { name: /get tasko for free/i });
|
||||||
|
|
||||||
|
expect(link).toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import { Board } from '@prisma/client';
|
import { Board } from '@prisma/client';
|
||||||
|
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
@ -25,7 +25,11 @@ export const BoardTitleForm = ({ data }: BoardTitleFormProps) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const formRef = useRef<HTMLFormElement>(document.createElement('form'));
|
const formRef = useRef<HTMLFormElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
formRef.current = document.createElement('form');
|
||||||
|
}, []);
|
||||||
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
const [title, setTitle] = useState(data.title);
|
const [title, setTitle] = useState(data.title);
|
||||||
|
|
|
@ -35,6 +35,7 @@ const BoardIdPage = async (props: BoardIdPageProps) => {
|
||||||
orderBy: {
|
orderBy: {
|
||||||
order: 'asc',
|
order: 'asc',
|
||||||
},
|
},
|
||||||
|
cacheStrategy: { ttl: 30, swr: 60 },
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1,11 +1 @@
|
||||||
import '@testing-library/jest-dom';
|
import '@testing-library/jest-dom';
|
||||||
|
|
||||||
jest.mock('@clerk/nextjs/server', () => {
|
|
||||||
return {
|
|
||||||
auth: jest.fn().mockImplementation(() => {
|
|
||||||
return {
|
|
||||||
run: () => Promise.resolve({ id: '' }),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
"fluid-tailwind": "^1.0.4",
|
"fluid-tailwind": "^1.0.4",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
|
"jest-junit": "^16.0.0",
|
||||||
"mintlify": "^4.0.300",
|
"mintlify": "^4.0.300",
|
||||||
"postcss": "^8.4.49",
|
"postcss": "^8.4.49",
|
||||||
"prettier": "^3.4.2",
|
"prettier": "^3.4.2",
|
||||||
|
|
|
@ -6,7 +6,6 @@ import * as Sentry from '@sentry/nextjs';
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: 'https://bb697105eaabbc6f70af12e84e936ded@o4508368569368576.ingest.us.sentry.io/4508368582017024',
|
dsn: 'https://bb697105eaabbc6f70af12e84e936ded@o4508368569368576.ingest.us.sentry.io/4508368582017024',
|
||||||
// integrations: [Sentry.prismaIntegration()],
|
|
||||||
|
|
||||||
// Set tracesSampleRate to 1.0 to capture 100%
|
// Set tracesSampleRate to 1.0 to capture 100%
|
||||||
// of transactions for tracing.
|
// of transactions for tracing.
|
||||||
|
|
31
yarn.lock
31
yarn.lock
|
@ -10264,6 +10264,18 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"jest-junit@npm:^16.0.0":
|
||||||
|
version: 16.0.0
|
||||||
|
resolution: "jest-junit@npm:16.0.0"
|
||||||
|
dependencies:
|
||||||
|
mkdirp: "npm:^1.0.4"
|
||||||
|
strip-ansi: "npm:^6.0.1"
|
||||||
|
uuid: "npm:^8.3.2"
|
||||||
|
xml: "npm:^1.0.1"
|
||||||
|
checksum: 10c0/d813d4d142341c2b51b634db7ad6ceb9849514cb58f96ec5e7e4cf4031a557133490452710c2d9dec9b1dd546334d9ca663e042d3070c3e8f102ce6217bd8e2e
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"jest-leak-detector@npm:^29.7.0":
|
"jest-leak-detector@npm:^29.7.0":
|
||||||
version: 29.7.0
|
version: 29.7.0
|
||||||
resolution: "jest-leak-detector@npm:29.7.0"
|
resolution: "jest-leak-detector@npm:29.7.0"
|
||||||
|
@ -12051,7 +12063,7 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"mkdirp@npm:^1.0.3":
|
"mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4":
|
||||||
version: 1.0.4
|
version: 1.0.4
|
||||||
resolution: "mkdirp@npm:1.0.4"
|
resolution: "mkdirp@npm:1.0.4"
|
||||||
bin:
|
bin:
|
||||||
|
@ -15277,6 +15289,7 @@ __metadata:
|
||||||
fluid-tailwind: "npm:^1.0.4"
|
fluid-tailwind: "npm:^1.0.4"
|
||||||
jest: "npm:^29.7.0"
|
jest: "npm:^29.7.0"
|
||||||
jest-environment-jsdom: "npm:^29.7.0"
|
jest-environment-jsdom: "npm:^29.7.0"
|
||||||
|
jest-junit: "npm:^16.0.0"
|
||||||
lodash: "npm:^4.17.21"
|
lodash: "npm:^4.17.21"
|
||||||
lucide-react: "npm:^0.469.0"
|
lucide-react: "npm:^0.469.0"
|
||||||
mintlify: "npm:^4.0.300"
|
mintlify: "npm:^4.0.300"
|
||||||
|
@ -16163,6 +16176,15 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"uuid@npm:^8.3.2":
|
||||||
|
version: 8.3.2
|
||||||
|
resolution: "uuid@npm:8.3.2"
|
||||||
|
bin:
|
||||||
|
uuid: dist/bin/uuid
|
||||||
|
checksum: 10c0/bcbb807a917d374a49f475fae2e87fdca7da5e5530820ef53f65ba1d12131bd81a92ecf259cc7ce317cbe0f289e7d79fdfebcef9bfa3087c8c8a2fa304c9be54
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"uuid@npm:^9.0.0, uuid@npm:^9.0.1":
|
"uuid@npm:^9.0.0, uuid@npm:^9.0.1":
|
||||||
version: 9.0.1
|
version: 9.0.1
|
||||||
resolution: "uuid@npm:9.0.1"
|
resolution: "uuid@npm:9.0.1"
|
||||||
|
@ -16653,6 +16675,13 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"xml@npm:^1.0.1":
|
||||||
|
version: 1.0.1
|
||||||
|
resolution: "xml@npm:1.0.1"
|
||||||
|
checksum: 10c0/04bcc9b8b5e7b49392072fbd9c6b0f0958bd8e8f8606fee460318e43991349a68cbc5384038d179ff15aef7d222285f69ca0f067f53d071084eb14c7fdb30411
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"xmlbuilder@npm:~11.0.0":
|
"xmlbuilder@npm:~11.0.0":
|
||||||
version: 11.0.1
|
version: 11.0.1
|
||||||
resolution: "xmlbuilder@npm:11.0.1"
|
resolution: "xmlbuilder@npm:11.0.1"
|
||||||
|
|
Loading…
Reference in a new issue