mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[MNT-24628] Handle difference between config object ticket and browser storage ticket (#10270)
* [MNT-24628] Handle difference between config object ticket and browser storage ticket * [MNT-24628] Add unit tests * [MNT-24628] Added null/undefined checks
This commit is contained in:
@@ -62,6 +62,39 @@ describe('Basic configuration test', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('ticket mismatch', () => {
|
||||
it('should update config ticketEcm on ticket_mismatch event', (done) => {
|
||||
// Tickets
|
||||
const mockStorageTicket = 'storage-ticket';
|
||||
const mockConfigTicket = 'config-ticket';
|
||||
|
||||
// Create a mock storage
|
||||
const storageContent = { 'ticket-ECM': mockStorageTicket };
|
||||
const mockStorage = { getItem: (key: string) => storageContent[key] };
|
||||
|
||||
// Initialize AlfrescoApi instance (without ticketEcm to prevent validateTicket from being called at this point)
|
||||
const alfrescoApi = new AlfrescoApi({ authType: 'BASIC' });
|
||||
|
||||
// Initializes configuration and storage
|
||||
alfrescoApi.config.ticketEcm = mockConfigTicket;
|
||||
alfrescoApi.contentClient.config.ticketEcm = mockConfigTicket;
|
||||
alfrescoApi.contentClient.storage = mockStorage as any;
|
||||
|
||||
// Ensure alfrescoApi and contentClient have the config ticket
|
||||
assert.equal(alfrescoApi.config.ticketEcm, mockConfigTicket);
|
||||
assert.equal(alfrescoApi.contentClient.config.ticketEcm, mockConfigTicket);
|
||||
|
||||
alfrescoApi.on('ticket_mismatch', () => {
|
||||
// As the ticket mismatch event is triggered, the ticketEcm should now be the one from storage
|
||||
assert.equal(alfrescoApi.config.ticketEcm, mockStorageTicket);
|
||||
assert.equal(alfrescoApi.contentClient.config.ticketEcm, mockStorageTicket);
|
||||
done();
|
||||
});
|
||||
|
||||
alfrescoApi.contentClient.getAlfTicket(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('setconfig parameter ', () => {
|
||||
it('should be possible change the host in the client', () => {
|
||||
const config = {
|
||||
|
Reference in New Issue
Block a user