mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 23:33:10 +00:00
Harden contextual search on the weekly board and expose paginated cross-week GET /board/search with date presets, FE filter params, SQL indexes, and unit tests.
60 lines
1.8 KiB
JavaScript
60 lines
1.8 KiB
JavaScript
import http from 'k6/http';
|
|
import { check, sleep } from 'k6';
|
|
import { Trend } from 'k6/metrics';
|
|
|
|
const boardNoSearch = new Trend('board_no_search', true);
|
|
const boardWithSearch = new Trend('board_with_search', true);
|
|
const advancedPreset = new Trend('advanced_preset', true);
|
|
const advancedMultiFilter = new Trend('advanced_multi_filter', true);
|
|
|
|
const BASE_URL = __ENV.BASE_URL || 'https://localhost:5001';
|
|
const JWT = __ENV.JWT || '';
|
|
const WEEK_START = __ENV.WEEK_START || '2026-06-22';
|
|
|
|
export const options = {
|
|
vus: 10,
|
|
duration: '30s',
|
|
thresholds: {
|
|
board_no_search: ['p(95)<800'],
|
|
board_with_search: ['p(95)<1000'],
|
|
advanced_preset: ['p(95)<1200'],
|
|
advanced_multi_filter: ['p(95)<1500'],
|
|
},
|
|
};
|
|
|
|
const headers = {
|
|
Authorization: `Bearer ${JWT}`,
|
|
Accept: 'application/json',
|
|
};
|
|
|
|
export default function () {
|
|
const boardRes = http.get(
|
|
`${BASE_URL}/api/workorders/board?weekStart=${WEEK_START}`,
|
|
{ headers }
|
|
);
|
|
boardNoSearch.add(boardRes.timings.duration);
|
|
check(boardRes, { 'board 200': (r) => r.status === 200 });
|
|
|
|
const searchRes = http.get(
|
|
`${BASE_URL}/api/workorders/board?weekStart=${WEEK_START}&search=BK5`,
|
|
{ headers }
|
|
);
|
|
boardWithSearch.add(searchRes.timings.duration);
|
|
check(searchRes, { 'board search 200': (r) => r.status === 200 });
|
|
|
|
const advRes = http.get(
|
|
`${BASE_URL}/api/workorders/board/search?datePreset=thisMonth&page=1&pageSize=50`,
|
|
{ headers }
|
|
);
|
|
advancedPreset.add(advRes.timings.duration);
|
|
check(advRes, { 'advanced preset 200': (r) => r.status === 200 });
|
|
|
|
const multiRes = http.get(
|
|
`${BASE_URL}/api/workorders/board/search?datePreset=thisMonth&sites=BK5&types=PM&search=HVAC&page=1`,
|
|
{ headers }
|
|
);
|
|
advancedMultiFilter.add(multiRes.timings.duration);
|
|
check(multiRes, { 'advanced multi 200': (r) => r.status === 200 });
|
|
|
|
sleep(0.5);
|
|
}
|