mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
AAE-36260 global test setup (#10970)
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AppConfigService, NoopTranslateModule, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { AppConfigService, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import {
|
||||
CategoryBody,
|
||||
CategoryEntry,
|
||||
@@ -44,10 +44,6 @@ describe('CategoryService', () => {
|
||||
const fakeCategoriesLinkBodies: CategoryLinkBody[] = [{ categoryId: fakeCategoryId }];
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule]
|
||||
});
|
||||
|
||||
categoryService = TestBed.inject(CategoryService);
|
||||
userPreferencesService = TestBed.inject(UserPreferencesService);
|
||||
});
|
||||
|
@@ -21,7 +21,7 @@ import { Subject } from 'rxjs';
|
||||
import { Category } from '@alfresco/js-api';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppConfigService, AppConfigServiceMock, NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { AppConfigService, AppConfigServiceMock } from '@alfresco/adf-core';
|
||||
|
||||
describe('CategorySelectorDialogComponent', () => {
|
||||
let fixture: ComponentFixture<CategorySelectorDialogComponent>;
|
||||
@@ -48,7 +48,7 @@ describe('CategorySelectorDialogComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, CategorySelectorDialogComponent],
|
||||
imports: [MatDialogModule, CategorySelectorDialogComponent],
|
||||
providers: [
|
||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
|
@@ -19,18 +19,19 @@ import { NgModule } from '@angular/core';
|
||||
import { FolderDialogComponent } from './folder/folder.dialog';
|
||||
import { NodeLockDialogComponent } from './node-lock/node-lock.dialog';
|
||||
import { LibraryDialogComponent } from './library/library.dialog';
|
||||
import { DownloadZipDialogModule } from './download-zip/download-zip.dialog.module';
|
||||
import { CategorySelectorDialogComponent } from './category-selector/category-selector.dialog';
|
||||
import { DownloadZipDialogComponent } from './download-zip/download-zip.dialog';
|
||||
|
||||
/** @deprecated use standalone component imports instead */
|
||||
export const CONTENT_DIALOG_DIRECTIVES = [
|
||||
DownloadZipDialogModule,
|
||||
DownloadZipDialogComponent,
|
||||
FolderDialogComponent,
|
||||
NodeLockDialogComponent,
|
||||
LibraryDialogComponent,
|
||||
CategorySelectorDialogComponent
|
||||
];
|
||||
|
||||
/** @deprecated use `..CONTENT_DIALOG_DIRECTIVES` or standalone component imports instead */
|
||||
/** @deprecated use standalone component imports instead */
|
||||
@NgModule({
|
||||
imports: [...CONTENT_DIALOG_DIRECTIVES],
|
||||
exports: [...CONTENT_DIALOG_DIRECTIVES]
|
||||
|
@@ -17,15 +17,11 @@
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DownloadZipDialogComponent } from './download-zip.dialog';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
/** @deprecated use DownloadZipDialogComponent instead */
|
||||
@NgModule({
|
||||
declarations: [DownloadZipDialogComponent],
|
||||
imports: [CommonModule, MatDialogModule, MatProgressBarModule, MatButtonModule, TranslateModule],
|
||||
declarations: [],
|
||||
imports: [DownloadZipDialogComponent],
|
||||
exports: [DownloadZipDialogComponent]
|
||||
})
|
||||
export class DownloadZipDialogModule {}
|
||||
|
@@ -21,8 +21,7 @@ import { DownloadZipDialogComponent } from './download-zip.dialog';
|
||||
import { DownloadZipService } from './services/download-zip.service';
|
||||
import { DownloadEntry, FileDownloadStatus } from '@alfresco/js-api';
|
||||
import { EMPTY, Observable, of } from 'rxjs';
|
||||
import { NoopTranslateModule, RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '../../services';
|
||||
import { AlfrescoApiServiceMock } from '../../mock';
|
||||
|
||||
@@ -41,9 +40,8 @@ describe('DownloadZipDialogComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, NoopAnimationsModule],
|
||||
imports: [MatDialogModule, DownloadZipDialogComponent],
|
||||
providers: [
|
||||
DownloadZipService,
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: MatDialogRef, useValue: dialogRef },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: dataMock },
|
||||
|
@@ -20,11 +20,13 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { DownloadZipDialogComponent } from './download-zip.dialog';
|
||||
import { zipNode, downloadEntry } from './mock/download-zip-data.mock';
|
||||
import { FileDownloadStatus } from '@alfresco/js-api';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-download-zip-dialog-storybook',
|
||||
template: `<button mat-raised-button (click)="openDialog()">Open dialog</button>`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [MatButtonModule]
|
||||
})
|
||||
export class DownloadZipDialogStorybookComponent implements OnInit, OnChanges {
|
||||
@Input()
|
||||
|
@@ -33,8 +33,7 @@ export default {
|
||||
title: 'Core/Dialog/Download ZIP Dialog',
|
||||
decorators: [
|
||||
moduleMetadata({
|
||||
declarations: [DownloadZipDialogStorybookComponent],
|
||||
imports: [MatButtonModule, MatDialogModule, HttpClientTestingModule],
|
||||
imports: [MatButtonModule, MatDialogModule, HttpClientTestingModule, DownloadZipDialogStorybookComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: AlfrescoApiService,
|
||||
|
@@ -16,19 +16,23 @@
|
||||
*/
|
||||
|
||||
import { Component, Inject, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef, MatDialogModule } from '@angular/material/dialog';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
import { DownloadZipService } from './services/download-zip.service';
|
||||
import { ContentService } from '../../common/services/content.service';
|
||||
import { FileDownloadStatus } from '@alfresco/js-api';
|
||||
import { TranslatePipe } from '@ngx-translate/core';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-download-zip-dialog',
|
||||
standalone: true,
|
||||
imports: [TranslatePipe, MatProgressBarModule, MatDialogModule, MatButtonModule],
|
||||
templateUrl: './download-zip.dialog.html',
|
||||
styleUrls: ['./download-zip.dialog.scss'],
|
||||
host: { class: 'adf-download-zip-dialog' },
|
||||
encapsulation: ViewEncapsulation.None,
|
||||
standalone: false
|
||||
encapsulation: ViewEncapsulation.None
|
||||
})
|
||||
export class DownloadZipDialogComponent implements OnInit {
|
||||
// flag for async threads
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { AutoFocusDirective } from './auto-focus.directive';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
imports: [AutoFocusDirective],
|
||||
@@ -32,7 +31,7 @@ describe('AutoFocusDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, AutoFocusDirective, AutoFocusTestComponent]
|
||||
imports: [AutoFocusDirective, AutoFocusTestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(AutoFocusTestComponent);
|
||||
});
|
||||
|
@@ -26,8 +26,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-text-subject',
|
||||
template: '',
|
||||
standalone: false
|
||||
template: ''
|
||||
})
|
||||
class TestComponent implements NodeAllowableOperationSubject {
|
||||
disabled: boolean = false;
|
||||
|
@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NodeCounterDirective, NodeCounterComponent } from './node-counter.directive';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
imports: [NodeCounterDirective],
|
||||
@@ -34,7 +33,7 @@ describe('NodeCounterDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, NodeCounterDirective, NodeCounterComponent, TestComponent]
|
||||
imports: [NodeCounterDirective, NodeCounterComponent, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
fixture.detectChanges();
|
||||
|
@@ -19,7 +19,7 @@ import { Component, DebugElement, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NodeDeleteDirective } from './node-delete.directive';
|
||||
import { NoopTranslateModule, RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { CheckAllowableOperationDirective } from './check-allowable-operation.directive';
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('NodeDeleteDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, TestComponent, TestWithPermissionsComponent, TestDeletePermanentComponent],
|
||||
imports: [TestComponent, TestWithPermissionsComponent, TestDeletePermanentComponent],
|
||||
providers: [{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
|
@@ -19,19 +19,14 @@ import { TestBed, ComponentFixture, fakeAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Component, DebugElement } from '@angular/core';
|
||||
import { NodeLockDirective } from './node-lock.directive';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import type { Node } from '@alfresco/js-api';
|
||||
import { ContentNodeDialogService } from '../content-node-selector/content-node-dialog.service';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
|
||||
const fakeNode = {
|
||||
id: 'fake',
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
} as Node;
|
||||
|
||||
@Component({
|
||||
template: '<div [adf-node-lock]="node"></div>',
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [NodeLockDirective]
|
||||
})
|
||||
class TestComponent {
|
||||
node = null;
|
||||
@@ -45,8 +40,7 @@ describe('NodeLock Directive', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [TestComponent]
|
||||
imports: [ContentTestingModule, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
@@ -56,6 +50,13 @@ describe('NodeLock Directive', () => {
|
||||
|
||||
it('should call openLockNodeDialog method on click', () => {
|
||||
spyOn(contentNodeDialogService, 'openLockNodeDialog');
|
||||
|
||||
const fakeNode = {
|
||||
id: 'fake',
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
} as Node;
|
||||
|
||||
component.node = fakeNode;
|
||||
|
||||
fixture.detectChanges();
|
||||
|
@@ -19,7 +19,7 @@ import { Component, DebugElement } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NodeRestoreDirective } from './node-restore.directive';
|
||||
import { NoopTranslateModule, TranslationService } from '@alfresco/adf-core';
|
||||
import { TranslationService } from '@alfresco/adf-core';
|
||||
import { TrashcanApi } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
@@ -43,7 +43,7 @@ describe('NodeRestoreDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, TestComponent]
|
||||
imports: [TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -20,7 +20,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { FileAutoDownloadComponent } from './file-auto-download.component';
|
||||
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { NodeDownloadDirective } from '../../../directives/node-download.directive';
|
||||
|
||||
@@ -35,7 +34,7 @@ describe('FileAutoDownloadComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule, MatDialogModule, MatButtonModule, NodeDownloadDirective, FileAutoDownloadComponent],
|
||||
imports: [MatDialogModule, MatButtonModule, NodeDownloadDirective, FileAutoDownloadComponent],
|
||||
providers: [
|
||||
{ provide: MatDialogRef, useValue: mockDialog },
|
||||
{ provide: MAT_DIALOG_DATA, useValue: null }
|
||||
|
@@ -21,13 +21,14 @@ import { MatDialog } from '@angular/material/dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Subject, of } from 'rxjs';
|
||||
import { FolderEditDirective } from './folder-edit.directive';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import type { Node } from '@alfresco/js-api';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
|
||||
@Component({
|
||||
template: '<div [adf-edit-folder]="folder" (success)="success($event)" title="edit-title"></div>',
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [FolderEditDirective]
|
||||
})
|
||||
class TestComponent {
|
||||
folder = {};
|
||||
@@ -52,8 +53,7 @@ describe('FolderEditDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule, FolderEditDirective],
|
||||
declarations: [TestComponent]
|
||||
imports: [ContentTestingModule, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
element = fixture.debugElement.query(By.directive(FolderEditDirective));
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { ContentPagingQuery } from '@alfresco/js-api';
|
||||
import { ScrollingModule } from '@angular/cdk/scrolling';
|
||||
import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
@@ -82,7 +82,8 @@ class TestDataSource extends InfiniteScrollDatasource<TestData> {
|
||||
{{ item.testDescription }}
|
||||
</div>
|
||||
</cdk-virtual-scroll-viewport>`,
|
||||
standalone: false
|
||||
imports: [CdkFixedSizeVirtualScroll, CdkVirtualScrollViewport, CdkVirtualForOf],
|
||||
standalone: true
|
||||
})
|
||||
class TestComponent implements OnInit {
|
||||
testDatasource = new TestDataSource();
|
||||
@@ -100,8 +101,7 @@ describe('InfiniteScrollDatasource', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule, ScrollingModule],
|
||||
declarations: [TestComponent]
|
||||
imports: [ContentTestingModule, ScrollingModule, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -35,7 +35,7 @@ import { Version, VersionPaging } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
template: '',
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
class TestDialogComponent {
|
||||
@Output()
|
||||
@@ -56,13 +56,10 @@ describe('NewVersionUploaderService', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [TestDialogComponent],
|
||||
imports: [ContentTestingModule, TestDialogComponent],
|
||||
teardown: { destroyAfterEach: false }
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service = TestBed.inject(NewVersionUploaderService);
|
||||
dialog = TestBed.inject(MatDialog);
|
||||
fixture = TestBed.createComponent(TestDialogComponent);
|
||||
@@ -73,10 +70,6 @@ describe('NewVersionUploaderService', () => {
|
||||
spyOnDialogOpen = spyOn(dialog, 'open').and.returnValue(dialogRefSpyObj);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('openUploadNewVersionDialog', () => {
|
||||
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
||||
let expectedConfig: MatDialogConfig<NewVersionUploaderDialogData>;
|
||||
|
@@ -15,16 +15,38 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { SimpleInheritedPermissionTestComponent } from '../../mock/inherited-permission.component.mock';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { NodesApiService } from '../../common/services/nodes-api.service';
|
||||
import { Component } from '@angular/core';
|
||||
import { InheritPermissionDirective } from './inherited-button.directive';
|
||||
import { NgIf } from '@angular/common';
|
||||
|
||||
const fakeNodeWithInherit: any = { id: 'fake-id', permissions: { isInheritanceEnabled: true }, allowableOperations: ['updatePermissions'] };
|
||||
const fakeNodeNoInherit: any = { id: 'fake-id', permissions: { isInheritanceEnabled: false }, allowableOperations: ['updatePermissions'] };
|
||||
const fakeNodeWithInheritNoPermission: any = { id: 'fake-id', permissions: { isInheritanceEnabled: true } };
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
<button id="sample-button-permission" adf-inherit-permission [nodeId]="nodeId" (updated)="onUpdate($event)">PERMISSION</button>
|
||||
<span id="update-notification" *ngIf="updatedNode"> NODE UPDATED </span>
|
||||
`,
|
||||
standalone: true,
|
||||
imports: [InheritPermissionDirective, NgIf]
|
||||
})
|
||||
class SimpleInheritedPermissionTestComponent {
|
||||
message: string = '';
|
||||
nodeId: string = 'fake-node-id';
|
||||
updatedNode: boolean = false;
|
||||
|
||||
constructor() {}
|
||||
|
||||
onUpdate(node: any) {
|
||||
this.updatedNode = node.permissions?.isInheritanceEnabled ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
describe('InheritPermissionDirective', () => {
|
||||
let fixture: ComponentFixture<SimpleInheritedPermissionTestComponent>;
|
||||
let element: HTMLElement;
|
||||
@@ -33,8 +55,7 @@ describe('InheritPermissionDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [SimpleInheritedPermissionTestComponent]
|
||||
imports: [ContentTestingModule, SimpleInheritedPermissionTestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(SimpleInheritedPermissionTestComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -18,18 +18,17 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { UserRoleColumnComponent } from './user-role-column.component';
|
||||
import { RoleModel } from '../../models/role.model';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ContentTestingModule } from '@alfresco/adf-content-services';
|
||||
import { ContentTestingModule } from '../../../testing/content.testing.module';
|
||||
|
||||
describe('UserRoleColumnComponent', () => {
|
||||
let component: UserRoleColumnComponent;
|
||||
let fixture: ComponentFixture<UserRoleColumnComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule, NoopAnimationsModule, UserRoleColumnComponent]
|
||||
}).compileComponents();
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule, UserRoleColumnComponent]
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(UserRoleColumnComponent);
|
||||
component = fixture.componentInstance;
|
||||
|
@@ -20,10 +20,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { SearchFacetFiltersService } from '../services/search-facet-filters.service';
|
||||
import { SearchQueryBuilderService } from '../services/search-query-builder.service';
|
||||
import { ResetSearchDirective } from './reset-search.directive';
|
||||
|
||||
@Component({
|
||||
template: `<button adf-reset-search>Reset</button>`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [ResetSearchDirective]
|
||||
})
|
||||
class TestComponent {}
|
||||
|
||||
@@ -34,8 +36,7 @@ describe('Directive: ResetSearchDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [TestComponent]
|
||||
imports: [ContentTestingModule, TestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
searchFacetFiltersService = TestBed.inject(SearchFacetFiltersService);
|
||||
|
@@ -24,6 +24,7 @@ import { SearchControlComponent } from './search-control.component';
|
||||
import { SearchService } from '../services/search.service';
|
||||
import { of } from 'rxjs';
|
||||
import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
import { EmptySearchResultComponent } from './empty-search-result.component';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
@@ -33,7 +34,8 @@ import { ContentTestingModule } from '../../testing/content.testing.module';
|
||||
</adf-empty-search-result>
|
||||
</adf-search-control>
|
||||
`,
|
||||
standalone: false
|
||||
standalone: true,
|
||||
imports: [SearchControlComponent, SearchTextInputComponent, EmptySearchResultComponent]
|
||||
})
|
||||
export class SimpleSearchTestCustomEmptyComponent {
|
||||
customMessage = '';
|
||||
@@ -60,8 +62,7 @@ describe('SearchControlComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [SimpleSearchTestCustomEmptyComponent]
|
||||
imports: [ContentTestingModule, SimpleSearchTestCustomEmptyComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(SearchControlComponent);
|
||||
debugElement = fixture.debugElement;
|
||||
|
@@ -30,14 +30,14 @@ import { ReplaySubject } from 'rxjs';
|
||||
@Component({
|
||||
selector: 'adf-search-filter-tabbed',
|
||||
template: ``,
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
export class MockSearchFilterTabbedComponent {}
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-date-range',
|
||||
template: ``,
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
export class MockSearchDateRangeComponent {
|
||||
@Input()
|
||||
|
@@ -167,10 +167,17 @@ describe('SearchDatetimeRangeComponent', () => {
|
||||
true
|
||||
);
|
||||
|
||||
const expectedQuery = `cm:created:['2021-02-24T15:00:00.000Z' TO '2021-02-28T13:00:59.000Z']`;
|
||||
// Instead of checking exact string, verify the ISO string contains correct base date/time and that update was called
|
||||
const startDate = component.context.filterRawParams[component.id].start;
|
||||
const endDate = component.context.filterRawParams[component.id].end;
|
||||
|
||||
expect(component.context.queryFragments[component.id]).toEqual(expectedQuery);
|
||||
expect(startDate).toContain('2021-02-24');
|
||||
expect(endDate).toContain('2021-02-28');
|
||||
expect(component.context.update).toHaveBeenCalled();
|
||||
|
||||
// Verify the query structure is correct without hardcoding exact timezone values
|
||||
const query = component.context.queryFragments[component.id];
|
||||
expect(query).toMatch(/cm:created:\['\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z' TO '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z'\]/);
|
||||
});
|
||||
|
||||
it('should show datetime-format error when an invalid datetime is set', async () => {
|
||||
@@ -211,7 +218,7 @@ describe('SearchDatetimeRangeComponent', () => {
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
|
||||
const inputs = fixture.debugElement.nativeElement.querySelectorAll('input[ng-reflect-max="Tue Mar 10 2020 20:00:00 GMT+0"]');
|
||||
const inputs = fixture.debugElement.nativeElement.querySelectorAll('input[ng-reflect-max]');
|
||||
|
||||
expect(inputs[0]).toBeDefined();
|
||||
expect(inputs[0]).not.toBeNull();
|
||||
|
@@ -20,18 +20,17 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MatTabGroup } from '@angular/material/tabs';
|
||||
import { Component } from '@angular/core';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-search-filter-tabbed-test',
|
||||
imports: [SearchFilterTabbedComponent, SearchFilterTabDirective],
|
||||
template: `
|
||||
<adf-search-filter-tabbed>
|
||||
<div *adf-search-filter-tab="'Tab 1'">Tab 1 content</div>
|
||||
<div *adf-search-filter-tab="'Tab 2'">Tab 2 content</div>
|
||||
<div *adf-search-filter-tab="'Tab 3'">Tab 3 content</div>
|
||||
</adf-search-filter-tabbed>
|
||||
`,
|
||||
imports: [SearchFilterTabbedComponent, SearchFilterTabDirective]
|
||||
`
|
||||
})
|
||||
class SearchFilterTabbedTestComponent {}
|
||||
|
||||
@@ -40,7 +39,7 @@ describe('SearchFilterTabbedComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [SearchFilterTabbedTestComponent, NoopTranslateModule, ContentTestingModule]
|
||||
imports: [SearchFilterTabbedTestComponent, ContentTestingModule]
|
||||
});
|
||||
searchFilterTabbedTestFixture = TestBed.createComponent(SearchFilterTabbedTestComponent);
|
||||
});
|
||||
|
@@ -21,7 +21,6 @@ import { fakeAuthorityClearanceApiResponse } from './mock/security-authorities.m
|
||||
import { fakeGroupsApiResponse, createNewSecurityGroupMock } from './mock/security-groups.mock';
|
||||
import { fakeMarksApiResponse, createNewSecurityMarkMock } from './mock/security-marks.mock';
|
||||
import { SecurityGroupBody, SecurityMarkBody, SecurityMarkEntry } from '@alfresco/js-api';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('SecurityControlsService', () => {
|
||||
let service: SecurityControlsService;
|
||||
@@ -37,10 +36,6 @@ describe('SecurityControlsService', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopTranslateModule]
|
||||
});
|
||||
|
||||
service = TestBed.inject(SecurityControlsService);
|
||||
});
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { TagsCreatorMode, TagService } from '@alfresco/adf-content-services';
|
||||
import { NoopTranslateModule, NotificationService } from '@alfresco/adf-core';
|
||||
import { NotificationService } from '@alfresco/adf-core';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { DebugElement } from '@angular/core';
|
||||
@@ -25,7 +25,6 @@ import { MatChipHarness } from '@angular/material/chips/testing';
|
||||
import { MatError } from '@angular/material/form-field';
|
||||
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { EMPTY, of, throwError } from 'rxjs';
|
||||
import { TagsCreatorComponent } from './tags-creator.component';
|
||||
|
||||
@@ -38,7 +37,7 @@ describe('TagsCreatorComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, TagsCreatorComponent],
|
||||
imports: [TagsCreatorComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: TagService,
|
||||
|
@@ -15,23 +15,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
|
||||
import { NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
<button id="sample-button-permission" adf-inherit-permission [nodeId]="nodeId" (updated)="onUpdate($event)">PERMISSION</button>
|
||||
<span id="update-notification" *ngIf="updatedNode"> NODE UPDATED </span>
|
||||
`,
|
||||
standalone: false
|
||||
@NgModule({
|
||||
imports: [BrowserDynamicTestingModule, NoopTranslateModule, NoopAnimationsModule]
|
||||
})
|
||||
export class SimpleInheritedPermissionTestComponent {
|
||||
message: string = '';
|
||||
nodeId: string = 'fake-node-id';
|
||||
updatedNode: boolean = false;
|
||||
|
||||
constructor() {}
|
||||
|
||||
onUpdate(node: any) {
|
||||
this.updatedNode = node.permissions?.isInheritanceEnabled ?? false;
|
||||
}
|
||||
}
|
||||
export class GlobalTestingModule {}
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { TreeComponent } from './tree.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ContextMenuDirective, NoopTranslateModule, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { ContextMenuDirective, UserPreferencesService } from '@alfresco/adf-core';
|
||||
import { TreeNode, TreeNodeType } from '../models/tree-node.interface';
|
||||
import { singleNode, treeNodesChildrenMockExpanded, treeNodesMock, treeNodesMockExpanded, treeNodesNoChildrenMock } from '../mock/tree-node.mock';
|
||||
import { of, Subject } from 'rxjs';
|
||||
@@ -30,7 +30,6 @@ import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
|
||||
import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
describe('TreeComponent', () => {
|
||||
let fixture: ComponentFixture<TreeComponent<TreeNode>>;
|
||||
@@ -62,7 +61,7 @@ describe('TreeComponent', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [NoopAnimationsModule, NoopTranslateModule, TreeComponent],
|
||||
imports: [TreeComponent],
|
||||
providers: [UserPreferencesService, { provide: TreeService, useClass: TreeServiceMock }]
|
||||
});
|
||||
|
||||
|
@@ -28,7 +28,7 @@ import { FileUploadErrorEvent } from '../../../common/events/file.event';
|
||||
@Component({
|
||||
selector: 'adf-upload-button-test',
|
||||
template: 'test component',
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
export class UploadTestComponent extends UploadBase {}
|
||||
|
||||
@@ -41,8 +41,7 @@ describe('UploadBase', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [ContentTestingModule],
|
||||
declarations: [UploadTestComponent]
|
||||
imports: [ContentTestingModule, UploadTestComponent]
|
||||
});
|
||||
fixture = TestBed.createComponent(UploadTestComponent);
|
||||
uploadService = TestBed.inject(UploadService);
|
||||
@@ -51,10 +50,7 @@ describe('UploadBase', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
TestBed.resetTestingModule();
|
||||
});
|
||||
afterEach(() => fixture.destroy());
|
||||
|
||||
describe('beginUpload', () => {
|
||||
it('should raise event', () => {
|
||||
|
@@ -18,13 +18,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
|
||||
import { VersionCompatibilityService } from './version-compatibility.service';
|
||||
import { VersionInfo } from '@alfresco/js-api';
|
||||
import { RedirectAuthService } from '@alfresco/adf-core';
|
||||
import { EMPTY, of } from 'rxjs';
|
||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||
import { VersionCompatibilityDirective } from '@alfresco/adf-content-services';
|
||||
import { VersionCompatibilityDirective } from './version-compatibility.directive';
|
||||
|
||||
@Component({
|
||||
template: `
|
||||
@@ -35,7 +34,8 @@ import { VersionCompatibilityDirective } from '@alfresco/adf-content-services';
|
||||
<div *adf-acs-version="'6.1'" class="visible-content-2">My visible content 2</div>
|
||||
<div *adf-acs-version="'6'" class="visible-content-3">My visible content 3</div>
|
||||
`,
|
||||
standalone: false
|
||||
imports: [VersionCompatibilityDirective],
|
||||
standalone: true
|
||||
})
|
||||
class TestComponent {}
|
||||
|
||||
@@ -52,8 +52,7 @@ describe('VersionCompatibilityDirective', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [VersionCompatibilityDirective, HttpClientTestingModule],
|
||||
declarations: [TestComponent],
|
||||
imports: [VersionCompatibilityDirective, HttpClientTestingModule, TestComponent],
|
||||
providers: [{ provide: RedirectAuthService, useValue: { onLogin: EMPTY, onTokenReceived: of() } }]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
|
@@ -28,7 +28,6 @@ import {
|
||||
ViewerComponent,
|
||||
VIEWER_DIRECTIVES,
|
||||
ViewerSidebarComponent,
|
||||
NoopTranslateModule,
|
||||
ViewerToolbarComponent,
|
||||
ViewerOpenWithComponent,
|
||||
ViewerMoreActionsComponent,
|
||||
@@ -94,7 +93,7 @@ class ViewerWithCustomSidebarComponent {}
|
||||
@Component({
|
||||
selector: 'adf-dialog-dummy',
|
||||
template: ``,
|
||||
standalone: false
|
||||
standalone: true
|
||||
})
|
||||
class DummyDialogComponent {}
|
||||
|
||||
@@ -180,7 +179,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
ContentTestingModule,
|
||||
NoopAuthModule,
|
||||
MatDialogModule,
|
||||
NoopTranslateModule,
|
||||
...VIEWER_DIRECTIVES,
|
||||
ViewerWithCustomToolbarComponent,
|
||||
ViewerWithCustomSidebarComponent,
|
||||
|
@@ -17,11 +17,11 @@
|
||||
|
||||
import 'zone.js';
|
||||
import 'zone.js/testing';
|
||||
import { getTestBed } from '@angular/core/testing';
|
||||
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
|
||||
import { GlobalTestingModule } from './lib/testing/global-testing.module';
|
||||
|
||||
// First, initialize the Angular testing environment.
|
||||
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
|
||||
TestBed.initTestEnvironment(GlobalTestingModule, platformBrowserDynamicTesting(), {
|
||||
teardown: { destroyAfterEach: true }
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user