imlil 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +40 -0
- package/DOCS.md +63 -0
- package/README.md +160 -0
- package/agentTestSandbox/cli-test-zone/README.md +0 -0
- package/agentTestSandbox/cli-test-zone/imlil.blueprint.json +5 -0
- package/agentTestSandbox/cli-test-zone/notes-warning.md +3 -0
- package/agentTestSandbox/cli-test-zone/package.json +0 -0
- package/agentTestSandbox/cli-test-zone/public/index.html +0 -0
- package/agentTestSandbox/cli-test-zone/src/App.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/App.jsx +29 -0
- package/agentTestSandbox/cli-test-zone/src/__tests__/App.test.jsx +48 -0
- package/agentTestSandbox/cli-test-zone/src/components/AddTodo.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/components/Navigation/Navigation.jsx +48 -0
- package/agentTestSandbox/cli-test-zone/src/components/Navigation/__tests__/Navigation.module.test.js +45 -0
- package/agentTestSandbox/cli-test-zone/src/components/Navigation/__tests__/Navigation.test.jsx +47 -0
- package/agentTestSandbox/cli-test-zone/src/components/Navigation.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/components/TodoItem/TodoItem.jsx +41 -0
- package/agentTestSandbox/cli-test-zone/src/components/TodoItem/__tests__/TodoItem.test.jsx +65 -0
- package/agentTestSandbox/cli-test-zone/src/components/TodoItem.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/components/TodoList/TodoList.module.css +62 -0
- package/agentTestSandbox/cli-test-zone/src/components/TodoList.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/index.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/pages/About.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/pages/Home.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/store/TodoContext.js +0 -0
- package/agentTestSandbox/cli-test-zone/src/styles/Todo.css +0 -0
- package/agentTestSandbox/cli-test-zone/src/styles/index.css +0 -0
- package/agentTestSandbox/cli-test-zone/src/utils/__tests__/localStorage.test.js +48 -0
- package/agentTestSandbox/cli-test-zone/src/utils/localStorage.js +38 -0
- package/agentTestSandbox/parallel-test/.env.example +0 -0
- package/agentTestSandbox/parallel-test/.eslintrc.json +0 -0
- package/agentTestSandbox/parallel-test/.github/workflows/__tests__/workflows.test.ts +115 -0
- package/agentTestSandbox/parallel-test/.github/workflows/cd.yml +0 -0
- package/agentTestSandbox/parallel-test/.github/workflows/ci.yml +4 -0
- package/agentTestSandbox/parallel-test/.imlil/plan-2026-02-08.md +186 -0
- package/agentTestSandbox/parallel-test/.prettierrc +0 -0
- package/agentTestSandbox/parallel-test/Dockerfile +0 -0
- package/agentTestSandbox/parallel-test/README.md +3 -0
- package/agentTestSandbox/parallel-test/ast.json +74 -0
- package/agentTestSandbox/parallel-test/docker-compose.yml +4 -0
- package/agentTestSandbox/parallel-test/jest.config.js +61 -0
- package/agentTestSandbox/parallel-test/k8s/__tests__/deployment.test.ts +168 -0
- package/agentTestSandbox/parallel-test/k8s/frontend-deployment.yaml +4 -0
- package/agentTestSandbox/parallel-test/nginx/nginx.conf +0 -0
- package/agentTestSandbox/parallel-test/package.json +50 -0
- package/agentTestSandbox/parallel-test/prisma/__tests__/schema.test.ts +176 -0
- package/agentTestSandbox/parallel-test/prisma/schema.prisma +109 -0
- package/agentTestSandbox/parallel-test/server/__tests__/controllers/dashboard.controller.test.ts +127 -0
- package/agentTestSandbox/parallel-test/server/__tests__/index.test.ts +60 -0
- package/agentTestSandbox/parallel-test/server/__tests__/models/user.model.test.ts +111 -0
- package/agentTestSandbox/parallel-test/server/config/__tests__/swagger.test.ts +128 -0
- package/agentTestSandbox/parallel-test/server/config/database.ts +0 -0
- package/agentTestSandbox/parallel-test/server/config/redis.ts +0 -0
- package/agentTestSandbox/parallel-test/server/config/swagger.ts +0 -0
- package/agentTestSandbox/parallel-test/server/controllers/__tests__/auth.controller.test.ts +178 -0
- package/agentTestSandbox/parallel-test/server/controllers/__tests__/user.controller.test.ts +105 -0
- package/agentTestSandbox/parallel-test/server/controllers/auth.controller.ts +148 -0
- package/agentTestSandbox/parallel-test/server/controllers/dashboard.controller.ts +137 -0
- package/agentTestSandbox/parallel-test/server/controllers/user.controller.ts +161 -0
- package/agentTestSandbox/parallel-test/server/index.ts +62 -0
- package/agentTestSandbox/parallel-test/server/middleware/__tests__/auth.middleware.test.ts +74 -0
- package/agentTestSandbox/parallel-test/server/middleware/auth.middleware.ts +55 -0
- package/agentTestSandbox/parallel-test/server/middleware/error.middleware.ts +0 -0
- package/agentTestSandbox/parallel-test/server/middleware/validation.middleware.ts +0 -0
- package/agentTestSandbox/parallel-test/server/models/analytics.model.ts +0 -0
- package/agentTestSandbox/parallel-test/server/models/profile.model.ts +0 -0
- package/agentTestSandbox/parallel-test/server/models/user.model.ts +78 -0
- package/agentTestSandbox/parallel-test/server/routes/auth.routes.ts +0 -0
- package/agentTestSandbox/parallel-test/server/routes/dashboard.routes.ts +0 -0
- package/agentTestSandbox/parallel-test/server/routes/user.routes.ts +0 -0
- package/agentTestSandbox/parallel-test/src/App.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/__tests__/config.test.ts +127 -0
- package/agentTestSandbox/parallel-test/src/__tests__/index.test.tsx +36 -0
- package/agentTestSandbox/parallel-test/src/__tests__/setup.test.ts +34 -0
- package/agentTestSandbox/parallel-test/src/__tests__/setupTest.test.ts +44 -0
- package/agentTestSandbox/parallel-test/src/components/common/Button/Button.tsx +80 -0
- package/agentTestSandbox/parallel-test/src/components/common/Button/__tests__/Button.test.tsx +75 -0
- package/agentTestSandbox/parallel-test/src/components/common/Card/Card.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/common/Input/Input.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/common/Table/Table.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/features/Authentication/LoginForm.tsx +75 -0
- package/agentTestSandbox/parallel-test/src/components/features/Authentication/RegisterForm.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/features/Authentication/__tests__/LoginForm.test.tsx +101 -0
- package/agentTestSandbox/parallel-test/src/components/features/Dashboard/AnalyticsChart.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/features/Dashboard/DashboardStats.tsx +81 -0
- package/agentTestSandbox/parallel-test/src/components/features/Dashboard/__tests__/DashboardStats.test.tsx +122 -0
- package/agentTestSandbox/parallel-test/src/components/layouts/Header.tsx +70 -0
- package/agentTestSandbox/parallel-test/src/components/layouts/MainLayout.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/layouts/Sidebar.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/components/layouts/__tests__/MainLayout.test.tsx +65 -0
- package/agentTestSandbox/parallel-test/src/hooks/__tests__/useAuth.test.ts +75 -0
- package/agentTestSandbox/parallel-test/src/hooks/useApi.ts +0 -0
- package/agentTestSandbox/parallel-test/src/hooks/useAuth.ts +54 -0
- package/agentTestSandbox/parallel-test/src/hooks/useTheme.ts +0 -0
- package/agentTestSandbox/parallel-test/src/index.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/services/__tests__/api.service.test.ts +48 -0
- package/agentTestSandbox/parallel-test/src/services/analytics.service.ts +0 -0
- package/agentTestSandbox/parallel-test/src/services/api.service.ts +59 -0
- package/agentTestSandbox/parallel-test/src/services/api.ts +0 -0
- package/agentTestSandbox/parallel-test/src/services/auth.service.ts +0 -0
- package/agentTestSandbox/parallel-test/src/services/user.service.ts +0 -0
- package/agentTestSandbox/parallel-test/src/store/__tests__/store.test.ts +60 -0
- package/agentTestSandbox/parallel-test/src/store/index.ts +23 -0
- package/agentTestSandbox/parallel-test/src/store/slices/authSlice.ts +0 -0
- package/agentTestSandbox/parallel-test/src/store/slices/dashboardSlice.ts +0 -0
- package/agentTestSandbox/parallel-test/src/store/slices/userSlice.ts +0 -0
- package/agentTestSandbox/parallel-test/src/types/auth.types.ts +0 -0
- package/agentTestSandbox/parallel-test/src/types/dashboard.types.ts +0 -0
- package/agentTestSandbox/parallel-test/src/types/user.types.ts +0 -0
- package/agentTestSandbox/parallel-test/src/utils/constants.ts +0 -0
- package/agentTestSandbox/parallel-test/src/utils/formatters.ts +0 -0
- package/agentTestSandbox/parallel-test/src/utils/validation.ts +0 -0
- package/agentTestSandbox/parallel-test/src/views/Dashboard.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/views/Login.tsx +31 -0
- package/agentTestSandbox/parallel-test/src/views/Profile.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/views/Register.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/views/Settings.tsx +0 -0
- package/agentTestSandbox/parallel-test/src/views/__tests__/Login.test.tsx +62 -0
- package/agentTestSandbox/parallel-test/src/vite-env.d.ts +1 -0
- package/agentTestSandbox/parallel-test/tailwind.config.js +0 -0
- package/agentTestSandbox/parallel-test/tests/integration/api/auth.test.ts +120 -0
- package/agentTestSandbox/parallel-test/tests/unit/components/Button.test.tsx +35 -0
- package/agentTestSandbox/parallel-test/tests/unit/config/jest.config.test.js +62 -0
- package/agentTestSandbox/parallel-test/tests/unit/config/jest.setup.test.js +52 -0
- package/agentTestSandbox/parallel-test/tests/unit/infrastructure/__tests__/docker-config.test.ts +107 -0
- package/agentTestSandbox/parallel-test/tsconfig.json +0 -0
- package/agentTestSandbox/zone2/Makefile +58 -0
- package/agentTestSandbox/zone2/README.md +0 -0
- package/agentTestSandbox/zone2/docs/API.md +0 -0
- package/agentTestSandbox/zone2/docs/CONTRIBUTING.md +0 -0
- package/agentTestSandbox/zone2/imlil.blueprint.json +5 -0
- package/agentTestSandbox/zone2/notes-warning.md +3 -0
- package/agentTestSandbox/zone2/src/calculator.c +0 -0
- package/agentTestSandbox/zone2/src/calculator.h +0 -0
- package/agentTestSandbox/zone2/src/core/__tests__/test_memory.c +89 -0
- package/agentTestSandbox/zone2/src/core/memory.c +60 -0
- package/agentTestSandbox/zone2/src/display.c +0 -0
- package/agentTestSandbox/zone2/src/display.h +0 -0
- package/agentTestSandbox/zone2/src/input_handler.c +0 -0
- package/agentTestSandbox/zone2/src/input_handler.h +0 -0
- package/agentTestSandbox/zone2/src/main.c +0 -0
- package/agentTestSandbox/zone2/src/utils/error_handling.c +0 -0
- package/agentTestSandbox/zone2/src/utils/error_handling.h +0 -0
- package/agentTestSandbox/zone2/src/utils/input.c +0 -0
- package/agentTestSandbox/zone2/src/utils/input.h +0 -0
- package/agentTestSandbox/zone2/src/utils/math_utils.c +0 -0
- package/agentTestSandbox/zone2/src/utils/math_utils.h +0 -0
- package/agentTestSandbox/zone2/src/utils/stack.c +0 -0
- package/agentTestSandbox/zone2/src/utils/stack.h +0 -0
- package/agentTestSandbox/zone2/src/utils.c +34 -0
- package/agentTestSandbox/zone2/tests/__tests__/test_makefile.c +58 -0
- package/agentTestSandbox/zone2/tests/calculator_tests.c +0 -0
- package/agentTestSandbox/zone2/tests/input_handler_tests.c +0 -0
- package/agentTestSandbox/zone2/tests/math_utils_tests.c +0 -0
- package/agentTestSandbox/zone2/tests/test_calculator.c +0 -0
- package/agentTestSandbox/zone2/tests/test_input.c +0 -0
- package/agentTestSandbox/zone2/tests/test_stack.c +0 -0
- package/agentTestSandbox/zone2/tests/test_utils.c +8 -0
- package/bin/cli.js +369 -0
- package/imlil.config.js +22 -0
- package/index.js +0 -0
- package/jest.config.js +5 -0
- package/package.json +45 -0
- package/src/__tests__/cli.test.js +5 -0
- package/src/actions/Action.js +125 -0
- package/src/agents/Agent.js +64 -0
- package/src/agents/Operator.js +147 -0
- package/src/agents/ScrumAgent.js +74 -0
- package/src/agents/SupervisorAgent.js +198 -0
- package/src/agents/ValidatorAgent.js +48 -0
- package/src/agents/coder.js +208 -0
- package/src/agents/worker.js +52 -0
- package/src/utils/db.js +40 -0
- package/src/utils/embedapi.js +19 -0
- package/test-api.js +24 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-redux';
|
|
4
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
5
|
+
import Login from '../Login';
|
|
6
|
+
import { store } from '../../store';
|
|
7
|
+
|
|
8
|
+
// Mock the auth service
|
|
9
|
+
jest.mock('../../services/auth.service', () => ({
|
|
10
|
+
login: jest.fn(() => Promise.resolve({ token: 'fake-token' })),
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('Login View', () => {
|
|
14
|
+
const renderLogin = () => {
|
|
15
|
+
render(
|
|
16
|
+
<Provider store={store}>
|
|
17
|
+
<BrowserRouter>
|
|
18
|
+
<Login />
|
|
19
|
+
</BrowserRouter>
|
|
20
|
+
</Provider>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
beforeEach(() => {
|
|
25
|
+
jest.clearAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('renders login form elements', () => {
|
|
29
|
+
renderLogin();
|
|
30
|
+
expect(screen.getByTestId('login-view')).toBeInTheDocument();
|
|
31
|
+
expect(screen.getByLabelText(/email/i)).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByLabelText(/password/i)).toBeInTheDocument();
|
|
33
|
+
expect(screen.getByRole('button', { name: /login/i })).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('handles form submission correctly', async () => {
|
|
37
|
+
renderLogin();
|
|
38
|
+
const emailInput = screen.getByLabelText(/email/i);
|
|
39
|
+
const passwordInput = screen.getByLabelText(/password/i);
|
|
40
|
+
const submitButton = screen.getByRole('button', { name: /login/i });
|
|
41
|
+
|
|
42
|
+
fireEvent.change(emailInput, { target: { value: 'test@example.com' } });
|
|
43
|
+
fireEvent.change(passwordInput, { target: { value: 'password123' } });
|
|
44
|
+
fireEvent.click(submitButton);
|
|
45
|
+
|
|
46
|
+
await waitFor(() => {
|
|
47
|
+
expect(screen.queryByText(/invalid credentials/i)).not.toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('displays validation errors for empty fields', async () => {
|
|
52
|
+
renderLogin();
|
|
53
|
+
const submitButton = screen.getByRole('button', { name: /login/i });
|
|
54
|
+
|
|
55
|
+
fireEvent.click(submitButton);
|
|
56
|
+
|
|
57
|
+
await waitFor(() => {
|
|
58
|
+
expect(screen.getByText(/email is required/i)).toBeInTheDocument();
|
|
59
|
+
expect(screen.getByText(/password is required/i)).toBeInTheDocument();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
File without changes
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import request from 'supertest';
|
|
2
|
+
import { app } from '../../../server';
|
|
3
|
+
import { prisma } from '../../../server/config/database';
|
|
4
|
+
import { createToken } from '../../../server/utils/jwt';
|
|
5
|
+
|
|
6
|
+
describe('Authentication API Integration Tests', () => {
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
// Clear test database
|
|
9
|
+
await prisma.user.deleteMany();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterAll(async () => {
|
|
13
|
+
await prisma.$disconnect();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe('POST /api/auth/register', () => {
|
|
17
|
+
const validUser = {
|
|
18
|
+
email: 'test@example.com',
|
|
19
|
+
password: 'Password123!',
|
|
20
|
+
username: 'testuser',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
it('should register a new user successfully', async () => {
|
|
24
|
+
const response = await request(app)
|
|
25
|
+
.post('/api/auth/register')
|
|
26
|
+
.send(validUser)
|
|
27
|
+
.expect(201);
|
|
28
|
+
|
|
29
|
+
expect(response.body).toHaveProperty('user');
|
|
30
|
+
expect(response.body).toHaveProperty('token');
|
|
31
|
+
expect(response.body.user.email).toBe(validUser.email);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return 400 for duplicate email', async () => {
|
|
35
|
+
await request(app)
|
|
36
|
+
.post('/api/auth/register')
|
|
37
|
+
.send(validUser)
|
|
38
|
+
.expect(400);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('should return 400 for invalid input', async () => {
|
|
42
|
+
const invalidUser = {
|
|
43
|
+
email: 'invalid-email',
|
|
44
|
+
password: '123', // Too short
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const response = await request(app)
|
|
48
|
+
.post('/api/auth/register')
|
|
49
|
+
.send(invalidUser)
|
|
50
|
+
.expect(400);
|
|
51
|
+
|
|
52
|
+
expect(response.body).toHaveProperty('errors');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('POST /api/auth/login', () => {
|
|
57
|
+
const credentials = {
|
|
58
|
+
email: 'test@example.com',
|
|
59
|
+
password: 'Password123!',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
it('should login successfully with valid credentials', async () => {
|
|
63
|
+
const response = await request(app)
|
|
64
|
+
.post('/api/auth/login')
|
|
65
|
+
.send(credentials)
|
|
66
|
+
.expect(200);
|
|
67
|
+
|
|
68
|
+
expect(response.body).toHaveProperty('token');
|
|
69
|
+
expect(response.body).toHaveProperty('user');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('should return 401 for invalid credentials', async () => {
|
|
73
|
+
const invalidCredentials = {
|
|
74
|
+
email: credentials.email,
|
|
75
|
+
password: 'wrongpassword',
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
await request(app)
|
|
79
|
+
.post('/api/auth/login')
|
|
80
|
+
.send(invalidCredentials)
|
|
81
|
+
.expect(401);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
describe('POST /api/auth/forgot-password', () => {
|
|
86
|
+
it('should send reset password email', async () => {
|
|
87
|
+
const response = await request(app)
|
|
88
|
+
.post('/api/auth/forgot-password')
|
|
89
|
+
.send({ email: 'test@example.com' })
|
|
90
|
+
.expect(200);
|
|
91
|
+
|
|
92
|
+
expect(response.body).toHaveProperty('message');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('GET /api/auth/verify-token', () => {
|
|
97
|
+
let validToken: string;
|
|
98
|
+
|
|
99
|
+
beforeAll(async () => {
|
|
100
|
+
const user = await prisma.user.findFirst({
|
|
101
|
+
where: { email: 'test@example.com' },
|
|
102
|
+
});
|
|
103
|
+
validToken = createToken(user!);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('should verify valid token', async () => {
|
|
107
|
+
await request(app)
|
|
108
|
+
.get('/api/auth/verify-token')
|
|
109
|
+
.set('Authorization', `Bearer ${validToken}`)
|
|
110
|
+
.expect(200);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('should reject invalid token', async () => {
|
|
114
|
+
await request(app)
|
|
115
|
+
.get('/api/auth/verify-token')
|
|
116
|
+
.set('Authorization', 'Bearer invalid-token')
|
|
117
|
+
.expect(401);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, fireEvent, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import Button from '../../../src/components/common/Button/Button';
|
|
5
|
+
|
|
6
|
+
describe('Button Component', () => {
|
|
7
|
+
it('renders button with correct text', () => {
|
|
8
|
+
render(<Button>Click me</Button>);
|
|
9
|
+
expect(screen.getByText('Click me')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('handles click events', () => {
|
|
13
|
+
const handleClick = jest.fn();
|
|
14
|
+
render(<Button onClick={handleClick}>Click me</Button>);
|
|
15
|
+
|
|
16
|
+
fireEvent.click(screen.getByText('Click me'));
|
|
17
|
+
expect(handleClick).toHaveBeenCalledTimes(1);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('applies variant classes correctly', () => {
|
|
21
|
+
render(<Button variant="primary">Primary Button</Button>);
|
|
22
|
+
const button = screen.getByText('Primary Button');
|
|
23
|
+
expect(button).toHaveClass('btn-primary');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('disables button when disabled prop is true', () => {
|
|
27
|
+
render(<Button disabled>Disabled Button</Button>);
|
|
28
|
+
expect(screen.getByText('Disabled Button')).toBeDisabled();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders button with custom className', () => {
|
|
32
|
+
render(<Button className="custom-class">Custom Button</Button>);
|
|
33
|
+
expect(screen.getByText('Custom Button')).toHaveClass('custom-class');
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
describe('Jest Configuration', () => {
|
|
2
|
+
let jestConfig;
|
|
3
|
+
|
|
4
|
+
beforeAll(() => {
|
|
5
|
+
// Import the jest config
|
|
6
|
+
jestConfig = require('../../../jest.config.js');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('should have correct root directory configuration', () => {
|
|
10
|
+
expect(jestConfig.rootDir).toBe('../..');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('should have TypeScript configuration', () => {
|
|
14
|
+
expect(jestConfig.preset).toBe('ts-jest');
|
|
15
|
+
expect(jestConfig.testEnvironment).toBe('jsdom');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should have correct test match patterns', () => {
|
|
19
|
+
expect(jestConfig.testMatch).toEqual([
|
|
20
|
+
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
|
|
21
|
+
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
|
|
22
|
+
'<rootDir>/tests/**/*.{spec,test}.{js,jsx,ts,tsx}'
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('should have appropriate module name mapper for assets', () => {
|
|
27
|
+
expect(jestConfig.moduleNameMapper).toEqual(expect.objectContaining({
|
|
28
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
29
|
+
'\\.(jpg|jpeg|png|gif|webp|svg)$': '<rootDir>/tests/__mocks__/fileMock.js'
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('should have correct coverage configuration', () => {
|
|
34
|
+
expect(jestConfig.collectCoverageFrom).toEqual([
|
|
35
|
+
'src/**/*.{js,jsx,ts,tsx}',
|
|
36
|
+
'!src/**/*.d.ts',
|
|
37
|
+
'!src/vite-env.d.ts'
|
|
38
|
+
]);
|
|
39
|
+
expect(jestConfig.coverageDirectory).toBe('coverage');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('should have setup files configured', () => {
|
|
43
|
+
expect(jestConfig.setupFilesAfterEnv).toContain('<rootDir>/tests/setupTests.ts');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('should have transform configuration for TypeScript', () => {
|
|
47
|
+
expect(jestConfig.transform).toEqual(expect.objectContaining({
|
|
48
|
+
'^.+\\.(ts|tsx)$': 'ts-jest'
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('should have module file extensions defined', () => {
|
|
53
|
+
expect(jestConfig.moduleFileExtensions).toEqual([
|
|
54
|
+
'js',
|
|
55
|
+
'jsx',
|
|
56
|
+
'ts',
|
|
57
|
+
'tsx',
|
|
58
|
+
'json',
|
|
59
|
+
'node'
|
|
60
|
+
]);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
describe('Jest Configuration Tests', () => {
|
|
5
|
+
let packageJson;
|
|
6
|
+
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
// Read the package.json file
|
|
9
|
+
const packageJsonPath = path.resolve(process.cwd(), 'package.json');
|
|
10
|
+
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('package.json should exist', () => {
|
|
14
|
+
expect(packageJson).toBeDefined();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('should have jest as a dev dependency', () => {
|
|
18
|
+
expect(packageJson.devDependencies).toBeDefined();
|
|
19
|
+
expect(packageJson.devDependencies.jest).toBeDefined();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('should have proper test script configuration', () => {
|
|
23
|
+
expect(packageJson.scripts).toBeDefined();
|
|
24
|
+
expect(packageJson.scripts.test).toBeDefined();
|
|
25
|
+
expect(packageJson.scripts.test).toMatch(/jest/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('jest.config.js should exist', () => {
|
|
29
|
+
const jestConfigPath = path.resolve(process.cwd(), 'jest.config.js');
|
|
30
|
+
expect(fs.existsSync(jestConfigPath)).toBeTruthy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('jest.config.js should have basic required configuration', () => {
|
|
34
|
+
const jestConfigPath = path.resolve(process.cwd(), 'jest.config.js');
|
|
35
|
+
const jestConfig = require(jestConfigPath);
|
|
36
|
+
|
|
37
|
+
expect(jestConfig).toEqual(expect.objectContaining({
|
|
38
|
+
testEnvironment: expect.any(String),
|
|
39
|
+
setupFilesAfterEnv: expect.any(Array),
|
|
40
|
+
moduleNameMapper: expect.any(Object),
|
|
41
|
+
transform: expect.any(Object)
|
|
42
|
+
}));
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('typescript configuration should include jest types', () => {
|
|
46
|
+
const tsConfigPath = path.resolve(process.cwd(), 'tsconfig.json');
|
|
47
|
+
const tsConfig = JSON.parse(fs.readFileSync(tsConfigPath, 'utf8'));
|
|
48
|
+
|
|
49
|
+
expect(tsConfig.compilerOptions.types).toBeDefined();
|
|
50
|
+
expect(tsConfig.compilerOptions.types).toContain('jest');
|
|
51
|
+
});
|
|
52
|
+
});
|
package/agentTestSandbox/parallel-test/tests/unit/infrastructure/__tests__/docker-config.test.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import YAML from 'yaml';
|
|
4
|
+
|
|
5
|
+
describe('Docker and Nginx Configuration Tests', () => {
|
|
6
|
+
const rootDir = path.resolve(__dirname, '../../../..');
|
|
7
|
+
|
|
8
|
+
describe('docker-compose.yml', () => {
|
|
9
|
+
let dockerComposeContent: any;
|
|
10
|
+
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
const filePath = path.join(rootDir, 'docker-compose.yml');
|
|
13
|
+
const fileContent = fs.readFileSync(filePath, 'utf8');
|
|
14
|
+
dockerComposeContent = YAML.parse(fileContent);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('docker-compose.yml file exists', () => {
|
|
18
|
+
const exists = fs.existsSync(path.join(rootDir, 'docker-compose.yml'));
|
|
19
|
+
expect(exists).toBeTruthy();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('contains required services', () => {
|
|
23
|
+
expect(dockerComposeContent.services).toBeDefined();
|
|
24
|
+
expect(dockerComposeContent.services.app).toBeDefined();
|
|
25
|
+
expect(dockerComposeContent.services.nginx).toBeDefined();
|
|
26
|
+
expect(dockerComposeContent.services.postgres).toBeDefined();
|
|
27
|
+
expect(dockerComposeContent.services.redis).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('app service configuration is correct', () => {
|
|
31
|
+
const appService = dockerComposeContent.services.app;
|
|
32
|
+
expect(appService.build).toBeDefined();
|
|
33
|
+
expect(appService.ports).toBeDefined();
|
|
34
|
+
expect(appService.environment).toBeDefined();
|
|
35
|
+
expect(appService.depends_on).toContain('postgres');
|
|
36
|
+
expect(appService.depends_on).toContain('redis');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('nginx service configuration is correct', () => {
|
|
40
|
+
const nginxService = dockerComposeContent.services.nginx;
|
|
41
|
+
expect(nginxService.image).toMatch(/nginx/);
|
|
42
|
+
expect(nginxService.ports).toContainEqual('80:80');
|
|
43
|
+
expect(nginxService.volumes).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('Dockerfile', () => {
|
|
48
|
+
let dockerfileContent: string;
|
|
49
|
+
|
|
50
|
+
beforeAll(() => {
|
|
51
|
+
const filePath = path.join(rootDir, 'Dockerfile');
|
|
52
|
+
dockerfileContent = fs.readFileSync(filePath, 'utf8');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('Dockerfile exists', () => {
|
|
56
|
+
const exists = fs.existsSync(path.join(rootDir, 'Dockerfile'));
|
|
57
|
+
expect(exists).toBeTruthy();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('contains required build stages', () => {
|
|
61
|
+
expect(dockerfileContent).toMatch(/FROM node:/);
|
|
62
|
+
expect(dockerfileContent).toMatch(/WORKDIR \/app/);
|
|
63
|
+
expect(dockerfileContent).toMatch(/COPY package\*.json/);
|
|
64
|
+
expect(dockerfileContent).toMatch(/RUN npm (ci|install)/);
|
|
65
|
+
expect(dockerfileContent).toMatch(/COPY \. \./);
|
|
66
|
+
expect(dockerfileContent).toMatch(/CMD/);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('includes necessary environment setup', () => {
|
|
70
|
+
expect(dockerfileContent).toMatch(/ENV NODE_ENV=production/);
|
|
71
|
+
expect(dockerfileContent).toMatch(/EXPOSE/);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('nginx.conf', () => {
|
|
76
|
+
let nginxContent: string;
|
|
77
|
+
|
|
78
|
+
beforeAll(() => {
|
|
79
|
+
const filePath = path.join(rootDir, 'nginx/nginx.conf');
|
|
80
|
+
nginxContent = fs.readFileSync(filePath, 'utf8');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('nginx.conf file exists', () => {
|
|
84
|
+
const exists = fs.existsSync(path.join(rootDir, 'nginx/nginx.conf'));
|
|
85
|
+
expect(exists).toBeTruthy();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('contains required nginx configurations', () => {
|
|
89
|
+
expect(nginxContent).toMatch(/http {/);
|
|
90
|
+
expect(nginxContent).toMatch(/server {/);
|
|
91
|
+
expect(nginxContent).toMatch(/listen 80;/);
|
|
92
|
+
expect(nginxContent).toMatch(/location \/ {/);
|
|
93
|
+
expect(nginxContent).toMatch(/proxy_pass/);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('includes security headers', () => {
|
|
97
|
+
expect(nginxContent).toMatch(/X-Frame-Options/);
|
|
98
|
+
expect(nginxContent).toMatch(/X-Content-Type-Options/);
|
|
99
|
+
expect(nginxContent).toMatch(/X-XSS-Protection/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('configures gzip compression', () => {
|
|
103
|
+
expect(nginxContent).toMatch(/gzip on;/);
|
|
104
|
+
expect(nginxContent).toMatch(/gzip_types/);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Compiler and flags
|
|
2
|
+
CC = gcc
|
|
3
|
+
CFLAGS = -Wall -Wextra -Werror -std=c99 -Iinclude
|
|
4
|
+
|
|
5
|
+
# Directories
|
|
6
|
+
SRC_DIR = src
|
|
7
|
+
TEST_DIR = tests
|
|
8
|
+
BIN_DIR = bin
|
|
9
|
+
OBJ_DIR = obj
|
|
10
|
+
INCLUDE_DIR = include
|
|
11
|
+
|
|
12
|
+
# Source files
|
|
13
|
+
SRC_FILES = $(SRC_DIR)/main.c $(SRC_DIR)/parser.c $(SRC_DIR)/operations.c $(SRC_DIR)/utils.c
|
|
14
|
+
OBJ_FILES = $(patsubst $(SRC_DIR)/,$(OBJ_DIR)/,$(SRC_FILES:.c=.o))
|
|
15
|
+
|
|
16
|
+
# Test files
|
|
17
|
+
TEST_SRC = $(TEST_DIR)/test_parser.c $(TEST_DIR)/test_operations.c $(TEST_DIR)/test_utils.c
|
|
18
|
+
TEST_OBJ = $(patsubst $(TEST_DIR)/,$(OBJ_DIR)/,$(TEST_SRC:.c=.o))
|
|
19
|
+
TEST_BIN = $(BIN_DIR)/test_runner
|
|
20
|
+
|
|
21
|
+
# Main executable
|
|
22
|
+
MAIN_BIN = $(BIN_DIR)/program
|
|
23
|
+
|
|
24
|
+
# Create required directories
|
|
25
|
+
DIRS = $(BIN_DIR) $(OBJ_DIR)
|
|
26
|
+
|
|
27
|
+
# Default target
|
|
28
|
+
all: dirs $(MAIN_BIN)
|
|
29
|
+
|
|
30
|
+
# Create directories
|
|
31
|
+
dirs:
|
|
32
|
+
mkdir -p $(DIRS)
|
|
33
|
+
|
|
34
|
+
# Build main program
|
|
35
|
+
$(MAIN_BIN): $(OBJ_FILES)
|
|
36
|
+
$(CC) $(CFLAGS) -o $@ $^
|
|
37
|
+
|
|
38
|
+
# Build object files
|
|
39
|
+
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
40
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
|
41
|
+
|
|
42
|
+
# Build tests
|
|
43
|
+
$(TEST_BIN): $(TEST_OBJ) $(OBJ_FILES:%$(MAIN_BIN).o=)
|
|
44
|
+
$(CC) $(CFLAGS) -o $@ $^ -lunity
|
|
45
|
+
|
|
46
|
+
$(OBJ_DIR)/%.o: $(TEST_DIR)/%.c
|
|
47
|
+
$(CC) $(CFLAGS) -c $< -o $@
|
|
48
|
+
|
|
49
|
+
# Run tests
|
|
50
|
+
test: $(TEST_BIN)
|
|
51
|
+
$(TEST_BIN)
|
|
52
|
+
|
|
53
|
+
# Clean build files
|
|
54
|
+
clean:
|
|
55
|
+
rm -f $(BIN_DIR)/* $(OBJ_DIR)/*
|
|
56
|
+
rmdir -p $(DIRS)
|
|
57
|
+
|
|
58
|
+
.PHONY: all dirs test clean
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fileStructure": "src/main.c, src/parser.c, src/operations.c, src/utils.c, include/parser.h, include/operations.h, include/utils.h, tests/test_parser.c, tests/test_operations.c, tests/test_utils.c, Makefile",
|
|
3
|
+
"conventions": "snake_case for functions and variables, UPPER_CASE for constants, function documentation using standard C-style comments, unit tests prefix: test_, header guards using __FILENAME_H__",
|
|
4
|
+
"techStack": "C99, Make, Unity (for unit testing), GCC compiler"
|
|
5
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @test file for memory.c
|
|
3
|
+
* Tests memory management functions for calculator
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
#include "unity.h"
|
|
7
|
+
#include "../../include/memory.h"
|
|
8
|
+
|
|
9
|
+
/* Global setup and teardown */
|
|
10
|
+
void setUp(void) {
|
|
11
|
+
memory_clear(); // Reset memory before each test
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void tearDown(void) {
|
|
15
|
+
// Cleanup after each test
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Test cases */
|
|
19
|
+
void test_memory_clear(void) {
|
|
20
|
+
// Arrange
|
|
21
|
+
memory_add(10.0);
|
|
22
|
+
|
|
23
|
+
// Act
|
|
24
|
+
memory_clear();
|
|
25
|
+
|
|
26
|
+
// Assert
|
|
27
|
+
TEST_ASSERT_EQUAL_FLOAT(0.0, memory_recall(), 0.00001);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void test_memory_add(void) {
|
|
31
|
+
// Arrange
|
|
32
|
+
memory_clear();
|
|
33
|
+
|
|
34
|
+
// Act
|
|
35
|
+
memory_add(5.0);
|
|
36
|
+
memory_add(3.0);
|
|
37
|
+
|
|
38
|
+
// Assert
|
|
39
|
+
TEST_ASSERT_EQUAL_FLOAT(8.0, memory_recall(), 0.00001);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void test_memory_subtract(void) {
|
|
43
|
+
// Arrange
|
|
44
|
+
memory_clear();
|
|
45
|
+
memory_add(10.0);
|
|
46
|
+
|
|
47
|
+
// Act
|
|
48
|
+
memory_subtract(3.0);
|
|
49
|
+
|
|
50
|
+
// Assert
|
|
51
|
+
TEST_ASSERT_EQUAL_FLOAT(7.0, memory_recall(), 0.00001);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
void test_memory_recall(void) {
|
|
55
|
+
// Arrange
|
|
56
|
+
memory_clear();
|
|
57
|
+
memory_add(15.0);
|
|
58
|
+
|
|
59
|
+
// Act & Assert
|
|
60
|
+
TEST_ASSERT_EQUAL_FLOAT(15.0, memory_recall(), 0.00001);
|
|
61
|
+
|
|
62
|
+
// Verify memory is unchanged after recall
|
|
63
|
+
TEST_ASSERT_EQUAL_FLOAT(15.0, memory_recall(), 0.00001);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void test_memory_chain_operations(void) {
|
|
67
|
+
// Arrange
|
|
68
|
+
memory_clear();
|
|
69
|
+
|
|
70
|
+
// Act
|
|
71
|
+
memory_add(10.0);
|
|
72
|
+
memory_subtract(5.0);
|
|
73
|
+
memory_add(3.0);
|
|
74
|
+
|
|
75
|
+
// Assert
|
|
76
|
+
TEST_ASSERT_EQUAL_FLOAT(8.0, memory_recall(), 0.00001);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
int main(void) {
|
|
80
|
+
UNITY_BEGIN();
|
|
81
|
+
|
|
82
|
+
RUN_TEST(test_memory_clear);
|
|
83
|
+
RUN_TEST(test_memory_add);
|
|
84
|
+
RUN_TEST(test_memory_subtract);
|
|
85
|
+
RUN_TEST(test_memory_recall);
|
|
86
|
+
RUN_TEST(test_memory_chain_operations);
|
|
87
|
+
|
|
88
|
+
return UNITY_END();
|
|
89
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file memory.c
|
|
3
|
+
* @brief Implements calculator memory functions (M+, M-, MR, MC)
|
|
4
|
+
* @author AutoGenerated
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
#include <stdio.h>
|
|
8
|
+
#include <stdlib.h>
|
|
9
|
+
#include "memory.h"
|
|
10
|
+
|
|
11
|
+
/** Global memory register variable */
|
|
12
|
+
static double g_memory_register = 0.0;
|
|
13
|
+
|
|
14
|
+
void memory_add(double value) {
|
|
15
|
+
g_memory_register += value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
void memory_subtract(double value) {
|
|
19
|
+
g_memory_register -= value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
double memory_recall() {
|
|
23
|
+
return g_memory_register;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void memory_clear() {
|
|
27
|
+
g_memory_register = 0.0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Initializes the calculator memory
|
|
32
|
+
* @return 0 on success, non-zero on failure
|
|
33
|
+
*/
|
|
34
|
+
int memory_init() {
|
|
35
|
+
memory_clear();
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Cleans up any memory resources
|
|
41
|
+
*/
|
|
42
|
+
void memory_destroy() {
|
|
43
|
+
memory_clear();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Checks if the memory register has a non-zero value
|
|
48
|
+
* @return 1 if memory is non-zero, 0 otherwise
|
|
49
|
+
*/
|
|
50
|
+
int memory_has_value() {
|
|
51
|
+
return (g_memory_register != 0.0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Sets the memory register to a specific value
|
|
56
|
+
* @param value The value to set
|
|
57
|
+
*/
|
|
58
|
+
void memory_set(double value) {
|
|
59
|
+
g_memory_register = value;
|
|
60
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|