fix: oprava zobrazení statistik pro aktuální týden
CI / Generate TypeScript types (push) Successful in 16s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 28s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m46s
CI / Build and push Docker image (push) Successful in 48s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 16s
CI / Server unit tests (push) Successful in 25s
CI / Build server (push) Successful in 28s
CI / Build client (push) Successful in 41s
CI / Playwright E2E tests (push) Successful in 1m46s
CI / Build and push Docker image (push) Successful in 48s
CI / Notify (push) Successful in 2s
This commit is contained in:
4 files changed
+40
-6
No files matched your search
@@ -4,6 +4,7 @@ import bodyParser from 'body-parser';
|
||||
import { generateToken } from '../auth';
|
||||
import { resetMemoryStorage } from '../storage/memory';
|
||||
import statsRouter from '../routes/statsRoutes';
|
||||
import { formatDate } from '../utils';
|
||||
|
||||
function buildApp() {
|
||||
const app = express();
|
||||
@@ -52,6 +53,31 @@ test('GET /stats s budoucím datem vrátí 400', async () => {
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
test('GET /stats s koncovým datem do týdne v budoucnosti vrátí 200', async () => {
|
||||
// Aktuální týden se načítá i s dny, které teprve budou
|
||||
const start = new Date();
|
||||
const end = new Date();
|
||||
end.setDate(end.getDate() + 3);
|
||||
const res = await request(buildApp())
|
||||
.get('/api/stats')
|
||||
.query({ startDate: formatDate(start), endDate: formatDate(end) })
|
||||
.set('Authorization', TOKEN);
|
||||
expect(res.status).toBe(200);
|
||||
expect(Array.isArray(res.body)).toBe(true);
|
||||
});
|
||||
|
||||
test('GET /stats s koncovým datem více než týden v budoucnosti vrátí 400', async () => {
|
||||
const start = new Date();
|
||||
start.setDate(start.getDate() + 8);
|
||||
const end = new Date(start);
|
||||
end.setDate(end.getDate() + 4);
|
||||
const res = await request(buildApp())
|
||||
.get('/api/stats')
|
||||
.query({ startDate: formatDate(start), endDate: formatDate(end) })
|
||||
.set('Authorization', TOKEN);
|
||||
expect(res.status).toBe(400);
|
||||
});
|
||||
|
||||
test('GET /stats/export vrátí XLSX soubor', async () => {
|
||||
const res = await request(buildApp())
|
||||
.get('/api/stats/export')
|
||||
|
||||
Reference in new issue
Block a user