-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* ACS-8398 Unit tests for search ai effects * ACS-8398 Unit tests for canDisplayKnowledgeRetrievalButton rule * ACS-8398 Unit tests for changes in document base page * ACS-8398 Added unit tests for changes in recent files component * ACS-8398 Unit tests for changes in lists pages * ACS-8398 Moved variable to inside of describe * ACS-8398 Moved repeated code to function * ACS-8398 Reverted one change * ACS-8398 Fix after rebase * ACS-8398 Fix issue with repeated code * ACS-8398 Fix issue with repeated code * ACS-8398 Fixed unit tests * ACS-8398 Fixed unit tests * ACS-8398 Trigger job
- Loading branch information
1 parent
3ec6d0b
commit 0fb9f9e
Showing
9 changed files
with
325 additions
and
39 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
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
77 changes: 77 additions & 0 deletions
77
projects/aca-content/src/lib/store/effects/search-ai.effects.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,77 @@ | ||
/*! | ||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Alfresco Example Content Application | ||
* | ||
* This file is part of the Alfresco Example Content Application. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Alfresco Example Content Application is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
import { EffectsModule } from '@ngrx/effects'; | ||
import { SearchAiEffects } from './search-ai.effects'; | ||
import { Store } from '@ngrx/store'; | ||
import { AppTestingModule } from '../../testing/app-testing.module'; | ||
import { SearchAiNavigationService } from '../../services/search-ai-navigation.service'; | ||
import { AppStore, SearchByTermAiAction, ToggleAISearchInput } from '@alfresco/aca-shared/store'; | ||
import { SearchAiService } from '@alfresco/adf-content-services'; | ||
|
||
describe('SearchAiEffects', () => { | ||
let store: Store<AppStore>; | ||
|
||
const agentId = '1'; | ||
const searchTerm = 'test'; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [AppTestingModule, EffectsModule.forRoot([SearchAiEffects])] | ||
}); | ||
store = TestBed.inject(Store); | ||
}); | ||
|
||
describe('searchByTerm$', () => { | ||
it('should call navigateToSearchAi on SearchAiNavigationService', () => { | ||
const searchAiNavigationService = TestBed.inject(SearchAiNavigationService); | ||
spyOn(searchAiNavigationService, 'navigateToSearchAi'); | ||
|
||
store.dispatch( | ||
new SearchByTermAiAction({ | ||
searchTerm, | ||
agentId | ||
}) | ||
); | ||
expect(searchAiNavigationService.navigateToSearchAi).toHaveBeenCalledWith({ | ||
query: searchTerm, | ||
agentId | ||
}); | ||
}); | ||
}); | ||
describe('toggleAISearchInput$', () => { | ||
it('should call updateSearchAiInputState on SearchAiService', () => { | ||
const searchAiService = TestBed.inject(SearchAiService); | ||
spyOn(searchAiService, 'updateSearchAiInputState'); | ||
|
||
store.dispatch(new ToggleAISearchInput(agentId, searchTerm)); | ||
expect(searchAiService.updateSearchAiInputState).toHaveBeenCalledWith({ | ||
active: true, | ||
selectedAgentId: agentId, | ||
searchTerm | ||
}); | ||
}); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
projects/aca-content/src/lib/testing/document-base-page-utils.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,103 @@ | ||
/*! | ||
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved. | ||
* | ||
* Alfresco Example Content Application | ||
* | ||
* This file is part of the Alfresco Example Content Application. | ||
* If the software was purchased under a paid Alfresco license, the terms of | ||
* the paid license agreement will prevail. Otherwise, the software is | ||
* provided under the following open source license terms: | ||
* | ||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Alfresco Example Content Application is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
import { AgentService, SearchAiInputState, SearchAiService } from '@alfresco/adf-content-services'; | ||
import { DebugElement, Type } from '@angular/core'; | ||
import { By } from '@angular/platform-browser'; | ||
import { SearchAiInputContainerComponent } from '../components/knowledge-retrieval/search-ai/search-ai-input-container/search-ai-input-container.component'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { PageComponent } from '@alfresco/aca-shared'; | ||
import { Agent } from '@alfresco/js-api/typings'; | ||
|
||
export const testHeader = <T extends PageComponent>(component: Type<T>, checkHeaderVisibility = true) => { | ||
describe('Header', () => { | ||
let fixture: ComponentFixture<T>; | ||
let toggleSearchAiInput$: BehaviorSubject<SearchAiInputState>; | ||
|
||
const getSearchAiInputElement = (): DebugElement => fixture.debugElement.query(By.directive(SearchAiInputContainerComponent)); | ||
|
||
const getHeaderElement = (): DebugElement => fixture.debugElement.query(By.css('.aca-header-container')); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(component); | ||
toggleSearchAiInput$ = new BehaviorSubject<SearchAiInputState>({ | ||
searchTerm: '' | ||
} as SearchAiInputState); | ||
TestBed.inject(SearchAiService).toggleSearchAiInput$ = toggleSearchAiInput$; | ||
spyOn(TestBed.inject(AgentService), 'getAgents').and.returnValue(new Subject<Agent[]>()); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should display ai input if input is active', () => { | ||
toggleSearchAiInput$.next({ | ||
active: true, | ||
searchTerm: '' | ||
}); | ||
|
||
fixture.detectChanges(); | ||
expect(getSearchAiInputElement()).not.toBeNull(); | ||
}); | ||
|
||
it('should not display ai input if input is not active', () => { | ||
toggleSearchAiInput$.next({ | ||
active: false, | ||
searchTerm: '' | ||
}); | ||
|
||
fixture.detectChanges(); | ||
expect(getSearchAiInputElement()).toBeNull(); | ||
}); | ||
|
||
it('should not display ai input by default', () => { | ||
expect(getSearchAiInputElement()).toBeNull(); | ||
}); | ||
|
||
if (checkHeaderVisibility) { | ||
it('should not display header if input is active', () => { | ||
toggleSearchAiInput$.next({ | ||
active: true, | ||
searchTerm: '' | ||
}); | ||
|
||
fixture.detectChanges(); | ||
expect(getHeaderElement()).toBeNull(); | ||
}); | ||
|
||
it('should display header if input is not active', () => { | ||
toggleSearchAiInput$.next({ | ||
active: false, | ||
searchTerm: '' | ||
}); | ||
|
||
fixture.detectChanges(); | ||
expect(getHeaderElement()).not.toBeNull(); | ||
}); | ||
|
||
it('should display header by default', () => { | ||
expect(getHeaderElement()).not.toBeNull(); | ||
}); | ||
} | ||
}); | ||
}; |
Oops, something went wrong.