-
Notifications
You must be signed in to change notification settings - Fork 481
feat(websockets): migrate WebSocket stack to data-access and react to site CRUD events #34990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
c99d3a3
feat(websockets): migrate WebSocket stack to data-access and react to…
fmontes 628e100
fix(websockets): address code quality issues from simplify review
fmontes f7d6ce4
style: apply prettier formatting to websocket-related files
fmontes b913441
refactor(dot-site): remove intermediate Subject from site event handling
fmontes cbcc6e2
test(dot-site): add WebSocket site event tests and fix DotEventsSocke…
fmontes 975fc99
refactor(websockets): replace DotEventsSocketURL class with plain str…
fmontes 2540751
refactor(websockets): simplify WS URL construction using window.locat…
fmontes 9267850
refactor(websockets): inline WebSocket URL into service, remove token
fmontes 765ceff
feat(websockets): handle SWITCH_SITE event in toolbar
fmontes 58eb937
refactor(global-store): move site switching logic into GlobalStore
fmontes 8307027
refactor(toolbar): extract SWITCH_SITE navigation into DotSiteNavigat…
fmontes 5559864
refactor(toolbar): remove redundant navigation logic handled by DotSi…
fmontes 5d530fa
refactor(site-switch): replace legacy SiteService.switchSite$ with Gl…
fmontes a64bb92
refactor(websockets): replace DotcmsEventsService with DotEventsSocket
fmontes 3f04964
fix(websockets): address Copilot review findings
fmontes 2363ba7
:wqMerge branch 'main' into fix-websockets
fmontes b8c4e9c
test(dot-templates): update spec to use GlobalStore mock for site-switch
fmontes d232396
test(dot-template-list): update spec to use GlobalStore mock for site…
fmontes 1264326
test(dot-sub-nav): replace real GlobalStore with mockProvider to avoi…
fmontes 5b25212
fix(with-websocket): avoid inject() in onDestroy default param to pre…
fmontes 716e847
test(dot-site-navigation): fix spec structure and provider setup
fmontes 49cfbc6
test(container-list): update spec to use GlobalStore mock for site-sw…
fmontes 0612ac0
fix(dot-toolbar): use $currentSite signal alias in template
fmontes 013b054
fix format
fmontes 92fce41
fix(global-store, data-access): fix createServiceFactory misuse and M…
fmontes 51e5154
fix(data-access): make exponential backoff test deterministic by mock…
fmontes 1567181
fix format
fmontes 789e5f0
fix: address Copilot review — subscription leak, eager init, test acc…
fmontes defaf15
feat(websocket): remove legacy DotcmsEventsService stack to eliminate…
fmontes 3ed834a
fix(dotcms-ui): fix import order and unused EMPTY imports in spec files
fmontes 590946f
fix(dotcms-js, dot-plugins): fix import order and deduplicate DotEven…
fmontes 55b0ef1
fix(dotcms-js): suppress enforce-module-boundaries for DotEventsSocke…
fmontes bd96276
ci: trigger CI rerun
fmontes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...pps/dotcms-ui/src/app/api/services/dot-site-navigation/dot-site-navigation.effect.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { | ||
| createServiceFactory, | ||
| mockProvider, | ||
| SpectatorService, | ||
| SpyObject | ||
| } from '@ngneat/spectator/jest'; | ||
| import { Subject } from 'rxjs'; | ||
|
|
||
| import { DotRouterService } from '@dotcms/data-access'; | ||
| import { DotSite } from '@dotcms/dotcms-models'; | ||
| import { GlobalStore } from '@dotcms/store'; | ||
| import { MockDotRouterService, mockSites } from '@dotcms/utils-testing'; | ||
|
|
||
| import { DotSiteNavigationEffect } from './dot-site-navigation.effect'; | ||
|
|
||
| describe('DotSiteNavigationEffect', () => { | ||
| let spectator: SpectatorService<DotSiteNavigationEffect>; | ||
| let dotRouterService: SpyObject<DotRouterService>; | ||
| let switchSiteSubject: Subject<DotSite>; | ||
|
|
||
| const createService = createServiceFactory({ | ||
| service: DotSiteNavigationEffect, | ||
| providers: [{ provide: DotRouterService, useClass: MockDotRouterService }] | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| // switchSiteSubject must be assigned before createService() so the effect | ||
| // constructor receives the correct observable when it subscribes on instantiation. | ||
| switchSiteSubject = new Subject<DotSite>(); | ||
|
|
||
| spectator = createService({ | ||
| providers: [ | ||
| mockProvider(GlobalStore, { | ||
| switchSiteEvent$: jest.fn().mockReturnValue(switchSiteSubject.asObservable()) | ||
| }) | ||
| ] | ||
| }); | ||
|
|
||
| dotRouterService = spectator.inject(DotRouterService); | ||
| }); | ||
|
|
||
| it('should navigate to site browser when SWITCH_SITE fires on edit page', () => { | ||
| jest.spyOn(dotRouterService, 'isEditPage').mockReturnValue(true); | ||
| switchSiteSubject.next(mockSites[0] as unknown as DotSite); | ||
| expect(dotRouterService.goToSiteBrowser).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should NOT navigate when SWITCH_SITE fires on a non-edit page', () => { | ||
| jest.spyOn(dotRouterService, 'isEditPage').mockReturnValue(false); | ||
| switchSiteSubject.next(mockSites[0] as unknown as DotSite); | ||
| expect(dotRouterService.goToSiteBrowser).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
...web/apps/dotcms-ui/src/app/api/services/dot-site-navigation/dot-site-navigation.effect.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Injectable, inject } from '@angular/core'; | ||
| import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; | ||
|
|
||
| import { DotRouterService } from '@dotcms/data-access'; | ||
| import { GlobalStore } from '@dotcms/store'; | ||
|
|
||
| /** | ||
| * App-level effect that navigates away from the edit page whenever | ||
| * another user/tab switches the current site via WebSocket. | ||
| * | ||
| * Provided eagerly in app.config.ts so it is active for the full | ||
| * application lifetime without being tied to any particular component. | ||
| */ | ||
| @Injectable({ providedIn: 'root' }) | ||
| export class DotSiteNavigationEffect { | ||
| readonly #dotRouterService = inject(DotRouterService); | ||
|
|
||
| constructor() { | ||
| inject(GlobalStore) | ||
| .switchSiteEvent$() | ||
| .pipe(takeUntilDestroyed()) | ||
| .subscribe(() => { | ||
| if (this.#dotRouterService.isEditPage()) { | ||
| this.#dotRouterService.goToSiteBrowser(); | ||
| } | ||
| }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.