AAE-36260 global test setup (#10970)

This commit is contained in:
Denys Vuika
2025-07-07 12:41:59 -04:00
committed by GitHub
parent e96f5b3c48
commit 5438eef9db
104 changed files with 358 additions and 433 deletions

View File

@@ -16,21 +16,19 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { FlagsComponent } from './flags.component';
import { FeaturesDirective } from '../../directives/features.directive';
import { WritableFeaturesServiceToken } from '../../interfaces/features.interface';
import { provideMockFeatureFlags } from '../../mocks/features-service-mock.factory';
import { StorageFeaturesService } from '../../services/storage-features.service';
import { NoopTranslateModule } from '@alfresco/adf-core';
describe('FlagsComponent', () => {
let component: FlagsComponent;
let fixture: ComponentFixture<FlagsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [FlagsComponent, NoopTranslateModule, FeaturesDirective, NoopAnimationsModule],
beforeEach(() => {
TestBed.configureTestingModule({
imports: [FlagsComponent, FeaturesDirective],
providers: [
{ provide: WritableFeaturesServiceToken, useClass: StorageFeaturesService },
provideMockFeatureFlags({
@@ -39,7 +37,7 @@ describe('FlagsComponent', () => {
feature3: true
})
]
}).compileComponents();
});
const storageFeaturesService = TestBed.inject(WritableFeaturesServiceToken);
storageFeaturesService.init();

View File

@@ -15,7 +15,6 @@
* limitations under the License.
*/
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideMockFeatureFlags } from '../mocks/features-service-mock.factory';
@@ -28,7 +27,8 @@ import { UnitTestingUtils } from '../../../../src/lib/testing/unit-testing-utils
<div id="underFeatureFlag" *adfForFeatures="features"></div>
</div>
`,
standalone: false
standalone: true,
imports: [FeaturesDirective]
})
class TestWithEnabledFlagComponent {
features = 'feature1';
@@ -39,7 +39,8 @@ class TestWithEnabledFlagComponent {
<div id="underFeatureFlag" *adfForFeatures="features"></div>
</div>
`,
standalone: false
standalone: true,
imports: [FeaturesDirective]
})
class TestWithDisabledFlagComponent {
features = ['feature1', 'feature2'];
@@ -52,7 +53,7 @@ describe('FeaturesDirective', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
imports: [CommonModule, FeaturesDirective],
imports: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent],
providers: [
provideMockFeatureFlags({
feature1: true,
@@ -60,8 +61,7 @@ describe('FeaturesDirective', () => {
feature3: true
}),
FeaturesDirective
],
declarations: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent]
]
});
enabledFixture = TestBed.createComponent(TestWithEnabledFlagComponent);
enabledFixture.detectChanges();

View File

@@ -15,7 +15,6 @@
* limitations under the License.
*/
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { provideMockFeatureFlags } from '../mocks/features-service-mock.factory';
@@ -28,7 +27,7 @@ import { UnitTestingUtils } from '../../../../src/lib/testing/unit-testing-utils
<div id="underFeatureFlag" *adfNotForFeatures="features"></div>
</div>
`,
standalone: false
imports: [NotFeaturesDirective]
})
class TestWithEnabledFlagComponent {
features = ['feature1', 'feature3'];
@@ -40,7 +39,7 @@ class TestWithEnabledFlagComponent {
<div id="underFeatureFlag" *adfNotForFeatures="features"></div>
</div>
`,
standalone: false
imports: [NotFeaturesDirective]
})
class TestWithDisabledFlagComponent {
features = 'feature2';
@@ -53,7 +52,7 @@ describe('NotFeaturesDirective', () => {
beforeEach(async () => {
TestBed.configureTestingModule({
imports: [CommonModule, NotFeaturesDirective],
imports: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent],
providers: [
provideMockFeatureFlags({
feature1: true,
@@ -61,8 +60,7 @@ describe('NotFeaturesDirective', () => {
feature3: true
}),
NotFeaturesDirective
],
declarations: [TestWithEnabledFlagComponent, TestWithDisabledFlagComponent]
]
});
enabledFixture = TestBed.createComponent(TestWithEnabledFlagComponent);
enabledFixture.detectChanges();