@@ -19,6 +19,8 @@ import supertest from 'supertest';
1919import type { Express } from 'express' ;
2020import type { UpdateState } from '../../../../../node/updater/types' ;
2121import { EMPTY_STATE } from '../../../../../node/updater/types' ;
22+ import { getEpVersion } from '../../../../../node/utils/Settings' ;
23+ import { parseSemver } from '../../../../../node/updater/versionCompare' ;
2224
2325// ---------------------------------------------------------------------------
2426// Module mocks — must appear before any import that transitively imports them.
@@ -83,34 +85,41 @@ const makeState = (latest: UpdateState['latest']): UpdateState => ({
8385 latest,
8486} ) ;
8587
86- /** A fake ReleaseInfo for a version that is a minor-version ahead of 3.1.0. */
88+ // Build fixtures relative to the actual current version so the test stays
89+ // stable across release bumps. Hard-coded versions break every time the
90+ // codebase rolls forward past the fixture (e.g. once 3.2.0 shipped, a
91+ // MINOR_AHEAD pinned at "3.2.0" no longer counted as minor-behind).
92+ const CUR = parseSemver ( getEpVersion ( ) ) ! ;
93+ const v = ( major : number , minor : number , patch : number ) => `${ major } .${ minor } .${ patch } ` ;
94+
95+ /** A fake ReleaseInfo for a version that is one minor ahead of current. */
8796const MINOR_AHEAD : UpdateState [ 'latest' ] = {
88- version : '3.2.0' ,
89- tag : 'v3.2.0' ,
97+ version : v ( CUR . major , CUR . minor + 1 , 0 ) ,
98+ tag : `v ${ v ( CUR . major , CUR . minor + 1 , 0 ) } ` ,
9099 body : '' ,
91100 publishedAt : '2026-05-01T00:00:00Z' ,
92101 prerelease : false ,
93- htmlUrl : ' https://github.com/ether/etherpad/releases/tag/v3.2.0' ,
102+ htmlUrl : ` https://github.com/ether/etherpad/releases/tag/v ${ v ( CUR . major , CUR . minor + 1 , 0 ) } ` ,
94103} ;
95104
96- /** A fake ReleaseInfo that is only a patch ahead of 3.1.0 (no minor/major delta). */
105+ /** A fake ReleaseInfo that is only a patch ahead of current (no minor/major delta). */
97106const PATCH_AHEAD : UpdateState [ 'latest' ] = {
98- version : '3.1.1' ,
99- tag : 'v3.1.1' ,
107+ version : v ( CUR . major , CUR . minor , CUR . patch + 1 ) ,
108+ tag : `v ${ v ( CUR . major , CUR . minor , CUR . patch + 1 ) } ` ,
100109 body : '' ,
101110 publishedAt : '2026-05-01T00:00:00Z' ,
102111 prerelease : false ,
103- htmlUrl : ' https://github.com/ether/etherpad/releases/tag/v3.1.1' ,
112+ htmlUrl : ` https://github.com/ether/etherpad/releases/tag/v ${ v ( CUR . major , CUR . minor , CUR . patch + 1 ) } ` ,
104113} ;
105114
106- /** A fake ReleaseInfo that is behind or equal to 3.1.0 (current >= latest). */
115+ /** A fake ReleaseInfo that is behind current (current >= latest). */
107116const SAME_OR_BEHIND : UpdateState [ 'latest' ] = {
108- version : '3.0.0' ,
109- tag : 'v3.0.0' ,
117+ version : v ( Math . max ( 0 , CUR . major - 1 ) , 0 , 0 ) ,
118+ tag : `v ${ v ( Math . max ( 0 , CUR . major - 1 ) , 0 , 0 ) } ` ,
110119 body : '' ,
111120 publishedAt : '2026-01-01T00:00:00Z' ,
112121 prerelease : false ,
113- htmlUrl : ' https://github.com/ether/etherpad/releases/tag/v3.0.0' ,
122+ htmlUrl : ` https://github.com/ether/etherpad/releases/tag/v ${ v ( Math . max ( 0 , CUR . major - 1 ) , 0 , 0 ) } ` ,
114123} ;
115124
116125// ---------------------------------------------------------------------------
0 commit comments