-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into issue-30367-Implement…
…-Abandoned-Job-Detection-and-Recovery-fixes
- Loading branch information
Showing
5 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 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 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
83 changes: 83 additions & 0 deletions
83
...bs/portlets/edit-ema/portlet/src/lib/store/features/editor/toolbar/withUVEToolbar.spec.ts
This file contains 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,83 @@ | ||
import { describe } from '@jest/globals'; | ||
import { createServiceFactory, mockProvider, SpectatorService } from '@ngneat/spectator/jest'; | ||
import { signalStore, withState } from '@ngrx/signals'; | ||
import { of } from 'rxjs'; | ||
|
||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
import { withUVEToolbar } from './withUVEToolbar'; | ||
|
||
import { DotPageApiService } from '../../../../services/dot-page-api.service'; | ||
import { UVE_STATUS } from '../../../../shared/enums'; | ||
import { MOCK_RESPONSE_HEADLESS } from '../../../../shared/mocks'; | ||
import { UVEState } from '../../../models'; | ||
|
||
const pageParams = { | ||
url: 'test-url', | ||
language_id: '1', | ||
'com.dotmarketing.persona.id': 'dot:persona', | ||
variantName: 'DEFAULT', | ||
clientHost: 'http://localhost:3000' | ||
}; | ||
|
||
const initialState: UVEState = { | ||
isEnterprise: true, | ||
languages: [], | ||
pageAPIResponse: MOCK_RESPONSE_HEADLESS, | ||
currentUser: null, | ||
experiment: null, | ||
errorCode: null, | ||
pageParams, | ||
status: UVE_STATUS.LOADED, | ||
isTraditionalPage: false, | ||
canEditPage: true, | ||
pageIsLocked: true, | ||
isClientReady: false | ||
}; | ||
|
||
export const uveStoreMock = signalStore(withState<UVEState>(initialState), withUVEToolbar()); | ||
|
||
describe('withEditor', () => { | ||
let spectator: SpectatorService<InstanceType<typeof uveStoreMock>>; | ||
let store: InstanceType<typeof uveStoreMock>; | ||
|
||
const createService = createServiceFactory({ | ||
service: uveStoreMock, | ||
providers: [ | ||
mockProvider(Router), | ||
mockProvider(ActivatedRoute), | ||
mockProvider(Router), | ||
mockProvider(ActivatedRoute), | ||
{ | ||
provide: DotPageApiService, | ||
useValue: { | ||
get() { | ||
return of(MOCK_RESPONSE_HEADLESS); | ||
}, | ||
getClientPage() { | ||
return of(MOCK_RESPONSE_HEADLESS); | ||
}, | ||
save: jest.fn() | ||
} | ||
} | ||
] | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createService(); | ||
store = spectator.service; | ||
}); | ||
|
||
describe('Computed', () => { | ||
it('should return the right API URL', () => { | ||
const params = { ...pageParams }; | ||
// Delete the url from the params to test the function | ||
delete params.url; | ||
|
||
const queryParams = new URLSearchParams(params).toString(); | ||
const expectURL = `/api/v1/page/json/test-url?${queryParams}`; | ||
|
||
expect(store.$apiURL()).toBe(expectURL); | ||
}); | ||
}); | ||
}); |
This file contains 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