FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
AntennaPatternMesh.test.ts
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2025-present FERS Contributors (see AUTHORS.md).
3
4import { describe, expect, it } from 'bun:test';
5import {
6 BACKEND_BUSY_MESSAGE,
7 getAntennaPreviewErrorAction,
8 isBackendBusyError,
9 shouldDeferAntennaPreviewFetch,
10} from './AntennaPatternMesh';
11
12describe('AntennaPatternMesh preview recovery', () => {
13 it('treats backend lock contention as a transient retry condition', () => {
14 const error = new Error(BACKEND_BUSY_MESSAGE);
15
16 expect(isBackendBusyError(error)).toBe(true);
17 expect(getAntennaPreviewErrorAction(error)).toEqual({
18 clearError: true,
19 clearPattern: false,
20 scheduleRetry: true,
21 });
22 });
23
24 it('preserves hard failures as visible preview errors', () => {
25 const error = new Error('antenna pattern file missing');
26
27 expect(isBackendBusyError(error)).toBe(false);
28 expect(getAntennaPreviewErrorAction(error)).toEqual({
29 clearError: false,
30 clearPattern: true,
31 scheduleRetry: false,
32 });
33 });
34
35 it('defers fetches until backend work has finished', () => {
36 expect(
37 shouldDeferAntennaPreviewFetch({
38 hasRequest: true,
39 isBackendSyncing: true,
40 isSimulating: false,
41 isGeneratingKml: false,
42 })
43 ).toBe(true);
44
45 expect(
46 shouldDeferAntennaPreviewFetch({
47 hasRequest: true,
48 isBackendSyncing: false,
49 isSimulating: true,
50 isGeneratingKml: false,
51 })
52 ).toBe(true);
53
54 expect(
55 shouldDeferAntennaPreviewFetch({
56 hasRequest: true,
57 isBackendSyncing: false,
58 isSimulating: false,
59 isGeneratingKml: true,
60 })
61 ).toBe(true);
62
63 expect(
64 shouldDeferAntennaPreviewFetch({
65 hasRequest: true,
66 isBackendSyncing: false,
67 isSimulating: false,
68 isGeneratingKml: false,
69 })
70 ).toBe(false);
71
72 expect(
73 shouldDeferAntennaPreviewFetch({
74 hasRequest: false,
75 isBackendSyncing: true,
76 isSimulating: true,
77 isGeneratingKml: true,
78 })
79 ).toBe(false);
80 });
81});