- {{('SEARCH.LOGICAL_SEARCH.' + field + '_LABEL') | translate}}
+ {{('SEARCH.LOGICAL_SEARCH.' + field + '_LABEL') | translate}}
{
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [SearchLogicalFilterComponent],
- imports: [
- TranslateModule.forRoot(),
- ContentTestingModule
- ]
+ imports: [TranslateModule.forRoot(), ContentTestingModule]
});
fixture = TestBed.createComponent(SearchLogicalFilterComponent);
@@ -62,7 +59,7 @@ describe('SearchLogicalFilterComponent', () => {
* @returns list of labels
*/
function getInputsLabels(): string[] {
- return fixture.debugElement.queryAll(By.css('.adf-search-input mat-label')).map((label) => label.nativeElement.innerText);
+ return fixture.debugElement.queryAll(By.css(`[data-automation-id="adf-search-input-label"]`)).map((label) => label.nativeElement.innerText);
}
/**
@@ -164,7 +161,9 @@ describe('SearchLogicalFilterComponent', () => {
enterNewPhrase('test5 test6 ', 2);
component.submitValues();
expect(component.context.update).toHaveBeenCalled();
- expect(component.context.queryFragments[component.id]).toBe('((NOT field1:"test5" AND NOT field1:"test6") AND (NOT field2:"test5" AND NOT field2:"test6"))');
+ expect(component.context.queryFragments[component.id]).toBe(
+ '((NOT field1:"test5" AND NOT field1:"test6") AND (NOT field2:"test5" AND NOT field2:"test6"))'
+ );
});
it('should form correct query from match exact field and trim it', () => {
diff --git a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts
index 7242373914..69b40cd8d6 100644
--- a/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts
+++ b/lib/content-services/src/lib/search/components/search-panel/search-panel.component.spec.ts
@@ -20,22 +20,26 @@ import { SearchFilterList } from '../../models/search-filter-list.model';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { sizeOptions, stepOne, stepThree } from '../../../mock';
-import { By } from '@angular/platform-browser';
import { TranslateModule } from '@ngx-translate/core';
+import { HarnessLoader, TestKey } from '@angular/cdk/testing';
+import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
+import { MatCheckboxHarness } from '@angular/material/checkbox/testing';
+import { By } from '@angular/platform-browser';
describe('SearchCheckListComponent', () => {
+ let loader: HarnessLoader;
let fixture: ComponentFixture;
let component: SearchCheckListComponent;
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [
- TranslateModule.forRoot(),
- ContentTestingModule
- ]
+ imports: [TranslateModule.forRoot(), ContentTestingModule]
});
fixture = TestBed.createComponent(SearchCheckListComponent);
component = fixture.componentInstance;
+
+ fixture.detectChanges();
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should setup options from settings', () => {
@@ -49,7 +53,7 @@ describe('SearchCheckListComponent', () => {
expect(component.options.items).toEqual(options);
});
- it('should handle enter key as click on checkboxes', () => {
+ it('should handle enter key as click on checkboxes', async () => {
component.options = new SearchFilterList([
{ name: 'Folder', value: `TYPE:'cm:folder'`, checked: false },
{ name: 'Document', value: `TYPE:'cm:content'`, checked: false }
@@ -58,13 +62,12 @@ describe('SearchCheckListComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.queryAll(By.css('mat-checkbox'));
+ const options = await loader.getAllHarnesses(MatCheckboxHarness);
+ await (await options[0].host()).sendKeys(TestKey.ENTER);
+ expect(await options[0].isChecked()).toBe(true);
- optionElements[0].triggerEventHandler('keydown.enter', {});
- expect(component.options.items[0].checked).toBeTruthy();
-
- optionElements[0].triggerEventHandler('keydown.enter', {});
- expect(component.options.items[0].checked).toBeFalsy();
+ await (await options[0].host()).sendKeys(TestKey.ENTER);
+ expect(await options[0].isChecked()).toBe(false);
});
it('should setup operator from the settings', () => {
@@ -95,21 +98,13 @@ describe('SearchCheckListComponent', () => {
spyOn(component.context, 'update').and.stub();
- component.changeHandler(
- { checked: true } as any,
- component.options.items[0]
- );
+ component.changeHandler({ checked: true } as any, component.options.items[0]);
expect(component.context.queryFragments[component.id]).toEqual(`TYPE:'cm:folder'`);
- component.changeHandler(
- { checked: true } as any,
- component.options.items[1]
- );
+ component.changeHandler({ checked: true } as any, component.options.items[1]);
- expect(component.context.queryFragments[component.id]).toEqual(
- `TYPE:'cm:folder' OR TYPE:'cm:content'`
- );
+ expect(component.context.queryFragments[component.id]).toEqual(`TYPE:'cm:folder' OR TYPE:'cm:content'`);
});
it('should reset selected boxes', () => {
@@ -147,7 +142,7 @@ describe('SearchCheckListComponent', () => {
});
describe('Pagination', () => {
- it('should show 5 items when pageSize not defined', () => {
+ it('should show 5 items when pageSize not defined', async () => {
component.id = 'checklist';
component.context = {
queryFragments: {
@@ -160,13 +155,14 @@ describe('SearchCheckListComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.queryAll(By.css('mat-checkbox'));
- expect(optionElements.length).toEqual(5);
- const labels = Array.from(optionElements).map(element => element.nativeElement.innerText);
+ const options = await loader.getAllHarnesses(MatCheckboxHarness);
+ expect(options.length).toEqual(5);
+
+ const labels = await Promise.all(Array.from(options).map(async (element) => element.getLabelText()));
expect(labels).toEqual(stepOne);
});
- it('should show all items when pageSize is high', () => {
+ it('should show all items when pageSize is high', async () => {
component.id = 'checklist';
component.context = {
queryFragments: {
@@ -178,14 +174,15 @@ describe('SearchCheckListComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.queryAll(By.css('mat-checkbox'));
- expect(optionElements.length).toEqual(13);
- const labels = Array.from(optionElements).map(element => element.nativeElement.innerText);
+ const options = await loader.getAllHarnesses(MatCheckboxHarness);
+ expect(options.length).toEqual(13);
+
+ const labels = await Promise.all(Array.from(options).map(async (element) => element.getLabelText()));
expect(labels).toEqual(stepThree);
});
});
- it('should able to check/reset the checkbox', () => {
+ it('should able to check/reset the checkbox', async () => {
component.id = 'checklist';
component.context = {
queryFragments: {
@@ -198,16 +195,15 @@ describe('SearchCheckListComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.query(By.css('mat-checkbox'));
- optionElements.triggerEventHandler('change', { checked: true });
+ const checkbox = await loader.getHarness(MatCheckboxHarness);
+ await checkbox.check();
expect(component.submitValues).toHaveBeenCalled();
const clearAllElement = fixture.debugElement.query(By.css('button[title="SEARCH.FILTER.ACTIONS.CLEAR-ALL"]'));
- clearAllElement.triggerEventHandler('click', {} );
+ clearAllElement.triggerEventHandler('click', {});
fixture.detectChanges();
- const selectedElements = fixture.debugElement.queryAll(By.css('.mat-checkbox-checked'));
- expect(selectedElements.length).toBe(0);
+ expect(await checkbox.isChecked()).toBe(false);
});
});
diff --git a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts
index 221ee0b037..415217637f 100644
--- a/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts
+++ b/lib/content-services/src/lib/search/components/search-radio/search-radio.component.spec.ts
@@ -16,29 +16,31 @@
*/
import { sizeOptions, stepOne, stepThree } from '../../../mock';
-import { By } from '@angular/platform-browser';
import { SearchRadioComponent } from './search-radio.component';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { TranslateModule } from '@ngx-translate/core';
+import { HarnessLoader } from '@angular/cdk/testing';
+import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
+import { MatRadioButtonHarness, MatRadioGroupHarness } from '@angular/material/radio/testing';
describe('SearchRadioComponent', () => {
- let fixture: ComponentFixture;
- let component: SearchRadioComponent;
+ let loader: HarnessLoader;
+ let fixture: ComponentFixture;
+ let component: SearchRadioComponent;
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [
- TranslateModule.forRoot(),
- ContentTestingModule
- ]
- });
- fixture = TestBed.createComponent(SearchRadioComponent);
- component = fixture.componentInstance;
- });
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [TranslateModule.forRoot(), ContentTestingModule]
+ });
+ fixture = TestBed.createComponent(SearchRadioComponent);
+ component = fixture.componentInstance;
- describe('Pagination', () => {
- it('should show 5 items when pageSize not defined', () => {
+ loader = TestbedHarnessEnvironment.loader(fixture);
+ });
+
+ describe('Pagination', () => {
+ it('should show 5 items when pageSize not defined', async () => {
component.id = 'radio';
component.context = {
queryFragments: {
@@ -51,13 +53,14 @@ describe('SearchRadioComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.queryAll(By.css('mat-radio-button'));
- expect(optionElements.length).toEqual(5);
- const labels = Array.from(optionElements).map(element => element.nativeElement.innerText);
+ const options = await loader.getAllHarnesses(MatRadioButtonHarness);
+ expect(options.length).toEqual(5);
+
+ const labels = await Promise.all(Array.from(options).map(async (element) => element.getLabelText()));
expect(labels).toEqual(stepOne);
});
- it('should show all items when pageSize is high', () => {
+ it('should show all items when pageSize is high', async () => {
component.id = 'radio';
component.context = {
queryFragments: {
@@ -69,14 +72,15 @@ describe('SearchRadioComponent', () => {
component.ngOnInit();
fixture.detectChanges();
- const optionElements = fixture.debugElement.queryAll(By.css('mat-radio-button'));
- expect(optionElements.length).toEqual(13);
- const labels = Array.from(optionElements).map(element => element.nativeElement.innerText);
+ const options = await loader.getAllHarnesses(MatRadioButtonHarness);
+ expect(options.length).toEqual(13);
+
+ const labels = await Promise.all(Array.from(options).map(async (element) => element.getLabelText()));
expect(labels).toEqual(stepThree);
});
});
- it('should able to check the radio button', async () => {
+ it('should able to check the radio button', async () => {
component.id = 'radio';
component.context = {
queryFragments: {
@@ -85,15 +89,10 @@ describe('SearchRadioComponent', () => {
update: () => {}
} as any;
component.settings = { options: sizeOptions } as any;
- spyOn(component.context, 'update').and.stub();
- fixture.detectChanges();
- await fixture.whenStable();
- const optionElements = fixture.debugElement.query(By.css('mat-radio-group'));
- optionElements.triggerEventHandler('change', { value: sizeOptions[0].value });
- fixture.detectChanges();
+ const group = await loader.getHarness(MatRadioGroupHarness);
+ await group.checkRadioButton({ selector: `[data-automation-id="search-radio-${sizeOptions[0].name}"]` });
- expect(component.context.update).toHaveBeenCalled();
expect(component.context.queryFragments[component.id]).toBe(sizeOptions[0].value);
});
});
diff --git a/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts b/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts
index b33b0ef7df..2ba2a5f116 100644
--- a/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts
+++ b/lib/content-services/src/lib/search/components/search-text/search-text.component.spec.ts
@@ -19,17 +19,19 @@ import { SearchTextComponent } from './search-text.component';
import { ContentTestingModule } from '../../../testing/content.testing.module';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
+import { HarnessLoader } from '@angular/cdk/testing';
+import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
+import { MatInputHarness } from '@angular/material/input/testing';
+import { MatButtonHarness } from '@angular/material/button/testing';
describe('SearchTextComponent', () => {
+ let loader: HarnessLoader;
let fixture: ComponentFixture;
let component: SearchTextComponent;
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [
- TranslateModule.forRoot(),
- ContentTestingModule
- ]
+ imports: [TranslateModule.forRoot(), ContentTestingModule]
});
fixture = TestBed.createComponent(SearchTextComponent);
component = fixture.componentInstance;
@@ -44,6 +46,8 @@ describe('SearchTextComponent', () => {
queryFragments: {},
update: () => {}
} as any;
+
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should parse value from the context at startup', () => {
@@ -100,16 +104,19 @@ describe('SearchTextComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
expect(component.value).toEqual('secret.pdf');
- const input = fixture.debugElement.nativeElement.querySelector('.mat-form-field-infix input');
- expect(input.value).toEqual('secret.pdf');
+
+ const input = await loader.getHarness(MatInputHarness);
+ expect(await input.getValue()).toBe('secret.pdf');
});
- it('should be able to reset by clicking clear button', async () => {
+ it('should be able to reset by clicking clear button', async () => {
component.context.queryFragments[component.id] = `cm:name:'secret.pdf'`;
fixture.detectChanges();
await fixture.whenStable();
- const clearElement = fixture.debugElement.nativeElement.querySelector('button');
- clearElement.click();
+
+ const clearButton = await loader.getHarness(MatButtonHarness);
+ await clearButton.click();
+
expect(component.value).toBe('');
expect(component.context.queryFragments[component.id]).toBe('');
});
diff --git a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts
index 02fa9ecbbd..2281db8bfa 100644
--- a/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts
+++ b/lib/content-services/src/lib/site-dropdown/sites-dropdown.component.spec.ts
@@ -15,13 +15,12 @@
* limitations under the License.
*/
-import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { By } from '@angular/platform-browser';
import { DropdownSitesComponent, Relations } from './sites-dropdown.component';
import { AuthenticationService } from '@alfresco/adf-core';
import { of } from 'rxjs';
-import { getFakeSitePaging,
+import {
+ getFakeSitePaging,
getFakeSitePagingNoMoreItems,
getFakeSitePagingFirstPage,
getFakeSitePagingLastPage,
@@ -30,6 +29,10 @@ import { getFakeSitePaging,
import { ContentTestingModule } from '../testing/content.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { SitesService } from '../common/services/sites.service';
+import { HarnessLoader } from '@angular/cdk/testing';
+import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
+import { MatSelectHarness } from '@angular/material/select/testing';
+import { SiteEntry } from '@alfresco/js-api';
const customSiteList = {
list: {
@@ -51,70 +54,57 @@ const customSiteList = {
};
describe('DropdownSitesComponent', () => {
-
+ let loader: HarnessLoader;
let component: any;
let fixture: ComponentFixture;
- let debug: DebugElement;
let element: HTMLElement;
let siteService: SitesService;
let authService: AuthenticationService;
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [
- TranslateModule.forRoot(),
- ContentTestingModule
- ]
+ imports: [TranslateModule.forRoot(), ContentTestingModule]
});
});
describe('Rendering tests', () => {
-
describe('Infinite Loading', () => {
-
beforeEach(() => {
siteService = TestBed.inject(SitesService);
fixture = TestBed.createComponent(DropdownSitesComponent);
- debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePaging()));
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
- it('Should show loading item if there are more itemes', async () => {
+ it('Should show loading item if there are more items', async () => {
fixture.detectChanges();
await fixture.whenStable();
expect(element.querySelector('[data-automation-id="site-loading"]')).toBeDefined();
});
- it('Should not show loading item if there are more itemes', async () => {
+ it('Should not show loading item if there are more items', async () => {
fixture.detectChanges();
await fixture.whenStable();
fixture.detectChanges();
expect(element.querySelector('[data-automation-id="site-loading"]')).toBeNull();
});
-
});
describe('Sites', () => {
-
beforeEach(() => {
siteService = TestBed.inject(SitesService);
spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePagingNoMoreItems()));
fixture = TestBed.createComponent(DropdownSitesComponent);
- debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
- const openSelectBox = () => {
- const selectBox = debug.query(By.css(('[data-automation-id="site-my-files-option"] .mat-select-trigger')));
- selectBox.triggerEventHandler('click', null);
- };
-
it('Dropdown sites should be rendered', async () => {
fixture.detectChanges();
await fixture.whenStable();
@@ -131,13 +121,11 @@ describe('DropdownSitesComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
- fixture.detectChanges();
- await fixture.whenStable();
-
- const options: any = debug.queryAll(By.css('mat-option'));
- expect(options[0].nativeElement.innerText).toContain('DROPDOWN.MY_FILES_OPTION');
+ const options = await select.getOptions();
+ expect(await options[0].getText()).toContain('DROPDOWN.MY_FILES_OPTION');
});
it('should hide the "My files" option if the developer desires that way', async () => {
@@ -146,23 +134,19 @@ describe('DropdownSitesComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
- fixture.detectChanges();
- await fixture.whenStable();
-
- const options: any = debug.queryAll(By.css('mat-option'));
- expect(options[0].nativeElement.innerText).not.toContain('DROPDOWN.MY_FILES_OPTION');
+ const options = await select.getOptions();
+ expect(await options[0].getText()).not.toContain('DROPDOWN.MY_FILES_OPTION');
});
it('should show the default placeholder label by default', async () => {
fixture.detectChanges();
await fixture.whenStable();
- openSelectBox();
-
- fixture.detectChanges();
- await fixture.whenStable();
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
expect(fixture.nativeElement.innerText.trim()).toContain('NODE_SELECTOR.LOCATION');
});
@@ -173,10 +157,8 @@ describe('DropdownSitesComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
- openSelectBox();
-
- fixture.detectChanges();
- await fixture.whenStable();
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
expect(fixture.nativeElement.innerText.trim()).toContain('NODE_SELECTOR.LOCATION');
});
@@ -187,51 +169,42 @@ describe('DropdownSitesComponent', () => {
fixture.detectChanges();
await fixture.whenStable();
- openSelectBox();
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
- fixture.detectChanges();
- await fixture.whenStable();
+ const options = await select.getOptions();
- const options = debug.queryAll(By.css('mat-option'));
- options[0].triggerEventHandler('click', null);
-
- fixture.detectChanges();
- await fixture.whenStable();
-
- expect(options[0].nativeElement.innerText).toContain('PERSONAL_FILES');
- expect(options[1].nativeElement.innerText).toContain('FILE_LIBRARIES');
+ expect(await options[0].getText()).toContain('PERSONAL_FILES');
+ expect(await options[1].getText()).toContain('FILE_LIBRARIES');
});
it('should load sites by default', async () => {
fixture.detectChanges();
await fixture.whenStable();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
+ const options = await select.getOptions();
+
+ expect(await options[1].getText()).toContain('fake-test-site');
+ expect(await options[2].getText()).toContain('fake-test-2');
+ });
+
+ it('should raise an event when a site is selected', async () => {
fixture.detectChanges();
await fixture.whenStable();
- const options: any = debug.queryAll(By.css('mat-option'));
- expect(options[1].nativeElement.innerText).toContain('fake-test-site');
- expect(options[2].nativeElement.innerText).toContain('fake-test-2');
- });
+ let site: SiteEntry;
+ component.change.subscribe((value) => (site = value));
- it('should raise an event when a site is selected', (done) => {
- fixture.detectChanges();
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
- fixture.detectChanges();
- const options: any = debug.queryAll(By.css('mat-option'));
- options[1].nativeElement.click();
- fixture.detectChanges();
- });
+ const options = await select.getOptions();
+ await options[1].click();
- component.change.subscribe((site) => {
- expect(site.entry.guid).toBe('fake-1');
- done();
- });
+ expect(site.entry.guid).toBe('fake-1');
});
it('should be possible to select the default value', async () => {
@@ -245,13 +218,13 @@ describe('DropdownSitesComponent', () => {
});
describe('Default value', () => {
-
beforeEach(() => {
siteService = TestBed.inject(SitesService);
spyOn(siteService, 'getSites').and.returnValues(of(getFakeSitePagingFirstPage()), of(getFakeSitePagingLastPage()));
fixture = TestBed.createComponent(DropdownSitesComponent);
component = fixture.componentInstance;
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
it('should load new sites if default value is not in the first page', (done) => {
@@ -277,15 +250,14 @@ describe('DropdownSitesComponent', () => {
});
describe('Sites with members', () => {
-
beforeEach(() => {
siteService = TestBed.inject(SitesService);
spyOn(siteService, 'getSites').and.returnValue(of(getFakeSitePagingWithMembers()));
fixture = TestBed.createComponent(DropdownSitesComponent);
- debug = fixture.debugElement;
element = fixture.nativeElement;
component = fixture.componentInstance;
+ loader = TestbedHarnessEnvironment.loader(fixture);
});
afterEach(() => {
@@ -293,28 +265,23 @@ describe('DropdownSitesComponent', () => {
});
describe('No relations', () => {
-
beforeEach(() => {
component.relations = Relations.Members;
authService = TestBed.inject(AuthenticationService);
});
- it('should show only sites which logged user is member of when member relation is set', (done) => {
+ it('should show only sites which logged user is member of when member relation is set', async () => {
spyOn(authService, 'getEcmUsername').and.returnValue('test');
-
fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- const options: any = debug.queryAll(By.css('mat-option'));
- expect(options[1].nativeElement.innerText).toContain('FAKE-SITE-PUBLIC');
- expect(options[2].nativeElement.innerText).toContain('FAKE-PRIVATE-SITE-MEMBER');
- expect(options[3]).toBeUndefined();
- done();
- });
- });
+ await fixture.whenStable();
+
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
+
+ const options = await select.getOptions();
+
+ expect(await options[1].getText()).toContain('FAKE-SITE-PUBLIC');
+ expect(await options[2].getText()).toContain('FAKE-PRIVATE-SITE-MEMBER');
});
});
@@ -324,22 +291,19 @@ describe('DropdownSitesComponent', () => {
authService = TestBed.inject(AuthenticationService);
});
- it('should show all the sites if no relation is set', (done) => {
+ it('should show all the sites if no relation is set', async () => {
spyOn(authService, 'getEcmUsername').and.returnValue('test');
-
fixture.detectChanges();
- fixture.whenStable().then(() => {
- fixture.detectChanges();
- debug.query(By.css('.mat-select-trigger')).triggerEventHandler('click', null);
- fixture.detectChanges();
- fixture.whenStable().then(() => {
- const options: any = debug.queryAll(By.css('mat-option'));
- expect(options[1].nativeElement.innerText).toContain('FAKE-MODERATED-SITE');
- expect(options[2].nativeElement.innerText).toContain('FAKE-SITE-PUBLIC');
- expect(options[3].nativeElement.innerText).toContain('FAKE-PRIVATE-SITE-MEMBER');
- done();
- });
- });
+ await fixture.whenStable();
+
+ const select = await loader.getHarness(MatSelectHarness);
+ await select.open();
+
+ const options = await select.getOptions();
+
+ expect(await options[1].getText()).toContain('FAKE-MODERATED-SITE');
+ expect(await options[2].getText()).toContain('FAKE-SITE-PUBLIC');
+ expect(await options[3].getText()).toContain('FAKE-PRIVATE-SITE-MEMBER');
});
});
});
diff --git a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.html b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.html
index 8058577375..54dc152b49 100644
--- a/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.html
+++ b/lib/content-services/src/lib/upload/components/file-uploading-dialog.component.html
@@ -8,6 +8,7 @@