@@ -61,13 +61,13 @@ describe('renderMarkup', () => {
6161 } )
6262
6363 it ( 'full variant tiles carry only live telemetry (no delay tile); delay lives in the arc anchor' , ( ) => {
64- const out = renderMarkup ( { ...sampleFlight , delayMin : 14 , schedEta : '14:22 ' } , 'full' , 0 , 'https://example.com' )
64+ const out = renderMarkup ( { ...sampleFlight , delayMin : 22 , schedEta : '14:14 ' } , 'full' , 0 , 'https://example.com' )
6565 expect ( out ) . toContain ( '>ALT<' )
6666 expect ( out ) . toContain ( '>SPD<' )
6767 expect ( out ) . toContain ( '>HDG<' )
6868 expect ( out ) . not . toContain ( '>ARR<' ) // no delay tile
69- expect ( out ) . not . toContain ( '14m late' ) // no worded delta
70- expect ( out ) . toContain ( 'was 14:22 ' ) // scheduled anchor on the arc
69+ expect ( out ) . not . toContain ( '22m late' ) // no worded delta
70+ expect ( out ) . toContain ( 'was 14:14 ' ) // scheduled anchor on the arc (notable, >15 min)
7171 } )
7272
7373 it ( 'falls back to derived time-left + trip tiles when there is no live telemetry (no row of --)' , ( ) => {
@@ -123,47 +123,51 @@ describe('renderMarkup', () => {
123123 expect ( half ) . toContain ( 'plane-icon' ) // inline SVG on the flat route line
124124 } )
125125
126- it ( 'shows the scheduled "was" anchor (two absolute clocks) only when the flight deviates ' , ( ) => {
126+ it ( 'shows the scheduled "was" anchor only for notable (>15 min) deviations, not minor ones ' , ( ) => {
127127 // assert on the rendered anchor text, not the (always-present) .route-sched CSS rule
128- // late: actual 14:36, scheduled 14:22
129- const late = renderMarkup ( { ...sampleFlight , delayMin : 14 , schedEta : '14:22 ' } , 'half_vertical' , 0 , 'https://example.com' )
130- expect ( late ) . toContain ( '>was 14:22 <' )
131- expect ( late ) . not . toContain ( '14m late' ) // no delta / no math
132-
133- // early: actual 14:36, scheduled 14:48 — still an absolute clock, no negative delta / word
134- const early = renderMarkup ( { ...sampleFlight , delayMin : - 12 , schedEta : '14:48 ' } , 'half_vertical' , 0 , 'https://example.com' )
135- expect ( early ) . toContain ( '>was 14:48 <' )
128+ // notably late (22 min): anchor shows the original scheduled clock
129+ const late = renderMarkup ( { ...sampleFlight , delayMin : 22 , schedEta : '14:14 ' } , 'half_vertical' , 0 , 'https://example.com' )
130+ expect ( late ) . toContain ( '>was 14:14 <' )
131+ expect ( late ) . not . toContain ( '22m late' ) // no delta / no math
132+
133+ // notably early (20 min): still an absolute clock, no negative delta / word
134+ const early = renderMarkup ( { ...sampleFlight , delayMin : - 20 , schedEta : '14:56 ' } , 'half_vertical' , 0 , 'https://example.com' )
135+ expect ( early ) . toContain ( '>was 14:56 <' )
136136 expect ( early ) . not . toContain ( 'early' )
137137
138- // on-time (within window): no anchor even though schedEta is present
139- const onTime = renderMarkup ( { ...sampleFlight , delayMin : 1 , schedEta : '14:35' } , 'half_vertical' , 0 , 'https://example.com' )
140- expect ( onTime ) . not . toContain ( '>was ' )
138+ // minor deviation within the 15-min window: no anchor (the actual time already carries it) —
139+ // a plane landing 10 min off isn't worth an extra line on an at-a-glance display
140+ const minorLate = renderMarkup ( { ...sampleFlight , delayMin : 10 , schedEta : '14:26' } , 'half_vertical' , 0 , 'https://example.com' )
141+ expect ( minorLate ) . not . toContain ( '>was ' )
142+ const minorEarly = renderMarkup ( { ...sampleFlight , delayMin : - 12 , schedEta : '14:48' } , 'half_vertical' , 0 , 'https://example.com' )
143+ expect ( minorEarly ) . not . toContain ( '>was ' )
144+
141145 // unknown schedule: no anchor
142146 const unknown = renderMarkup ( { ...sampleFlight , delayMin : null , schedEta : '--' } , 'half_vertical' , 0 , 'https://example.com' )
143147 expect ( unknown ) . not . toContain ( '>was ' )
144148 } )
145149
146- it ( 'anchors departure and arrival independently (a late pushback shows "was" under the origin )' , ( ) => {
147- // Departed 14 late, arrived on time (made up the time en route): only the origin gets an anchor.
148- const depLate = { ...sampleFlight , depDelayMin : 14 , schedDep : '07:58 ' , delayMin : 0 , schedEta : '14:36' }
150+ it ( 'anchors departure and arrival independently (each gated on its own >15 min deviation )' , ( ) => {
151+ // Departed 22 late, arrived on time (made up the time en route): only the origin gets an anchor.
152+ const depLate = { ...sampleFlight , depDelayMin : 22 , schedDep : '07:50 ' , delayMin : 0 , schedEta : '14:36' }
149153 const full = renderMarkup ( depLate , 'full' , 0 , 'https://example.com' )
150- expect ( full ) . toContain ( 'was 07:58 ' ) // origin anchor
154+ expect ( full ) . toContain ( 'was 07:50 ' ) // origin anchor
151155 expect ( full ) . not . toContain ( 'was 14:36' ) // arrival on time -> no anchor
152156 const half = renderMarkup ( depLate , 'half_vertical' , 0 , 'https://example.com' )
153- expect ( half ) . toContain ( '>was 07:58 <' )
157+ expect ( half ) . toContain ( '>was 07:50 <' )
154158
155- // Both deviate -> both anchors render.
156- const both = { ...sampleFlight , depDelayMin : 14 , schedDep : '07:58 ' , delayMin : 14 , schedEta : '14:22 ' }
159+ // Both deviate notably -> both anchors render.
160+ const both = { ...sampleFlight , depDelayMin : 22 , schedDep : '07:50 ' , delayMin : 22 , schedEta : '14:14 ' }
157161 const bothOut = renderMarkup ( both , 'half_vertical' , 0 , 'https://example.com' )
158- expect ( bothOut ) . toContain ( '>was 07:58 <' )
159- expect ( bothOut ) . toContain ( '>was 14:22 <' )
160-
161- // Opposite directions (late pushback, early arrival) both anchor — the "was" is an absolute
162- // clock, so the sign of each delay is irrelevant to the display .
163- const mixed = { ...sampleFlight , depDelayMin : 14 , schedDep : '07:58 ' , delayMin : - 10 , schedEta : '14:46' }
164- const mixedOut = renderMarkup ( mixed , 'full' , 0 , 'https://example.com' )
165- expect ( mixedOut ) . toContain ( 'was 07:58 ' ) // late departure
166- expect ( mixedOut ) . toContain ( 'was 14:46' ) // early arrival
162+ expect ( bothOut ) . toContain ( '>was 07:50 <' )
163+ expect ( bothOut ) . toContain ( '>was 14:14 <' )
164+
165+ // The screenshot case: pushed back 26 late but arrives only 10 early -> origin anchors, the
166+ // in-window arrival does not (10 < 15), even though the departure deviation is notable .
167+ const departedLateArrivedClose = { ...sampleFlight , depDelayMin : 26 , schedDep : '07:46 ' , delayMin : - 10 , schedEta : '14:46' }
168+ const mixedOut = renderMarkup ( departedLateArrivedClose , 'full' , 0 , 'https://example.com' )
169+ expect ( mixedOut ) . toContain ( 'was 07:46 ' ) // notable late departure
170+ expect ( mixedOut ) . not . toContain ( 'was 14:46' ) // minor early arrival -> gated out
167171 } )
168172
169173 it ( 'shows the on-time verdict as the 4th full-card tile (label-less), and hides it when unknown' , ( ) => {
0 commit comments