mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(notices): hand the release notice only to a bundle built for the running version
After an update the service worker keeps serving the previous bundle until the new one is installed. That shell announces the release layout too, so the layout alone let it draw the notice with its own older texts and use it up for the version now running with one click on X. The bundle now sends the version it was built as (client/package.json, baked in by define), and the server compares it with its own before it hands a notice with a release block over. A shell of another version is told nothing and gets the notice after the reload, from the bundle that can draw it. This holds for every update, not only the one that introduced the parameter.
This commit is contained in:
@@ -15,7 +15,7 @@ describe('systemNoticeStore', () => {
|
||||
// can draw the release layout, so an older bundle never shows it as bare keys and
|
||||
// never dismisses it for good. This bundle has to announce it on every fetch.
|
||||
describe('FE-SYSNOTICE-001: fetch() announces the layouts this bundle can draw', () => {
|
||||
it('sends supports=release with the active-notices request', async () => {
|
||||
it('sends supports=release and the version this bundle was built as', async () => {
|
||||
const urls: URL[] = [];
|
||||
server.use(
|
||||
http.get('/api/system-notices/active', ({ request }) => {
|
||||
@@ -28,6 +28,10 @@ describe('systemNoticeStore', () => {
|
||||
|
||||
expect(urls).toHaveLength(1);
|
||||
expect(urls[0].searchParams.get('supports')).toBe('release');
|
||||
// The value `define` bakes in from client/package.json: the server compares it
|
||||
// with its own version before it hands the release notice over.
|
||||
expect(urls[0].searchParams.get('ui')).toBe(__TREK_UI_VERSION__);
|
||||
expect(urls[0].searchParams.get('ui')).toMatch(/^\d+\.\d+\.\d+/);
|
||||
expect(useSystemNoticeStore.getState().loaded).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user