Update Jest configuration to include TypeScript support and add new code quality checks workflow; translate comments to Russian and adjust paths in test files.

This commit is contained in:
Primakov Alexandr Alexandrovich
2025-12-05 16:51:44 +03:00
parent d477a0a5f1
commit 7066252bcb
14 changed files with 646 additions and 294 deletions

View File

@@ -4,7 +4,6 @@ exports[`todo list app get list 1`] = `
{
"body": [
{
"_id": "670f69b5796ce7a9069da2f7",
"created": "2024-10-16T07:22:29.042Z",
"id": "670f69b5796ce7a9069da2f7",
"items": [],

View File

@@ -2,7 +2,7 @@ const { describe, it, expect } = require('@jest/globals')
const request = require('supertest')
const express = require('express')
const mockingoose = require('mockingoose')
const { ListModel } = require('../data/model/todo/list')
const { ListModel } = require('../routers/todo/model/todo/list')
const todo = require('../routers/todo/routes')

View File

@@ -48,6 +48,7 @@ exports.generate = async (req, res) => {
}
);
const content = chatResp.data.choices[0].message.content;
// eslint-disable-next-line no-useless-escape
const match = content.match(/<img src=\"(.*?)\"/);
if (!match) {
return res.status(500).json({ error: 'No image generated' });

View File

@@ -1,6 +1,7 @@
const express = require('express')
const mongoose = require('mongoose')
const request = require('supertest')
const { describe, it, beforeAll, expect } = require('@jest/globals')
// Mock auth middleware
const mockAuthMiddleware = (req, res, next) => {

View File

@@ -136,6 +136,7 @@ const waitForDatabaseConnection = async () => {
}
try {
// eslint-disable-next-line no-undef
const connection = await connectDB();
if (!connection) {
break;
@@ -218,6 +219,7 @@ const initializeTestUser = async () => {
console.error('Error initializing test data:', error.message);
if (error?.code === 13 || /auth/i.test(error?.message || '')) {
try {
// eslint-disable-next-line no-undef
await connectDB();
} catch (connectError) {
if (process.env.DEV === 'true') {

View File

@@ -202,6 +202,7 @@ router.get('/docs/:id/file', async (req, res) => {
}
const mimeType = mimeTypes[doc.type] || 'application/octet-stream'
// eslint-disable-next-line no-useless-escape
const sanitizedName = doc.name.replace(/[^\w\s\-\.]/g, '_')
res.setHeader('Content-Type', mimeType)

View File

@@ -37,6 +37,7 @@ const storage = multer.diskStorage({
const originalExtension = path.extname(fixedName) || '';
const baseName = path
.basename(fixedName, originalExtension)
// eslint-disable-next-line no-control-regex
.replace(/[<>:"/\\|?*\x00-\x1F]+/g, '_'); // Убираем только недопустимые символы Windows, оставляем кириллицу
cb(null, `${Date.now()}_${baseName}${originalExtension}`);
},

View File

@@ -187,6 +187,7 @@ function showConfirm(message, callback, title) {
function generateQRCode(data, size) {
const typeNumber = 0; // Автоматическое определение
const errorCorrectionLevel = 'L'; // Низкий уровень коррекции ошибок
// eslint-disable-next-line no-undef
const qr = qrcode(typeNumber, errorCorrectionLevel);
qr.addData(data);
qr.make();

View File

@@ -344,21 +344,21 @@ $(document).ready(function() {
// Инициализируем атрибуты required
updateRequiredAttributes();
});
// Обработчик удаления вопроса
$(document).on('click', '.remove-question', function() {
$(this).closest('.question-item').remove();
updateQuestionNumbers();
// Вызываем функцию обновления атрибутов required
updateRequiredAttributes();
});
// Обработчик удаления опции
$(document).on('click', '.remove-option', function() {
$(this).closest('.option-item').remove();
// Обработчик удаления вопроса
$(document).on('click', '.remove-question', function() {
$(this).closest('.question-item').remove();
updateQuestionNumbers();
// Вызываем функцию обновления атрибутов required
updateRequiredAttributes();
});
// Вызываем функцию обновления атрибутов required
updateRequiredAttributes();
// Обработчик удаления опции
$(document).on('click', '.remove-option', function() {
$(this).closest('.option-item').remove();
// Вызываем функцию обновления атрибутов required
updateRequiredAttributes();
});
});