forked from onecx/onecx-portal-ui-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/search-widget-accessibility
- Loading branch information
Showing
53 changed files
with
1,085 additions
and
130 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
...ts/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.html
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,27 @@ | ||
<form [formGroup]="searchConfigFormGroup" [class]="'searchConfigDialog'"> | ||
<div> | ||
<input | ||
type="text" | ||
pInputText | ||
formControlName="searchConfigName" | ||
id="searchConfigName" | ||
[placeholder]="placeHolderKey | translate" | ||
/> | ||
</div> | ||
|
||
<div> | ||
<p-checkbox formControlName="saveInputValues" [value]="saveInputValues" [binary]="true" inputId="saveInputValuesId"> | ||
</p-checkbox> | ||
<label for="saveInputValuesId">{{ ("OCX_SEARCH_CONFIG.SAVE_INPUT_FIELDS_OPTION" | translate) }}</label> | ||
</div> | ||
|
||
<div> | ||
<p-checkbox | ||
formControlName="saveColumns" | ||
[value]="saveColumns" | ||
[binary]="true" | ||
inputId="saveColumnsId" | ||
></p-checkbox> | ||
<label for="saveColumnsId">{{ ("OCX_SEARCH_CONFIG.SAVE_COLUMNS_OPTION" | translate) }}</label> | ||
</div> | ||
</form> |
14 changes: 14 additions & 0 deletions
14
...ts/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.scss
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,14 @@ | ||
.searchConfigDialog { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1em; | ||
margin-bottom: 1em; | ||
} | ||
|
||
:host ::ng-deep .p-inputtext { | ||
width: 100%; | ||
} | ||
|
||
:host ::ng-deep .p-checkbox { | ||
margin-right: 1em; | ||
} |
147 changes: 147 additions & 0 deletions
147
...create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.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,147 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
import { CreateOrEditSearchConfigDialogComponent } from './create-or-edit-search-config-dialog.component' | ||
import { CheckboxModule } from 'primeng/checkbox' | ||
import { MockAuthModule } from '../../../mock-auth/mock-auth.module' | ||
import { TranslateTestingModule } from 'ngx-translate-testing' | ||
import { HttpClientTestingModule } from '@angular/common/http/testing' | ||
import { TranslateService } from '@ngx-translate/core' | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' | ||
import { PCheckboxHarness, CreateOrEditSearchConfigDialogHarness } from '../../../../../testing' | ||
import { DialogState } from '../../../services/portal-dialog.service' | ||
import { ReactiveFormsModule } from '@angular/forms' | ||
import { InputTextModule } from 'primeng/inputtext' | ||
|
||
describe('CreateOrEditSearchConfigDialogComponent', () => { | ||
let component: CreateOrEditSearchConfigDialogComponent | ||
let fixture: ComponentFixture<CreateOrEditSearchConfigDialogComponent> | ||
let translateService: TranslateService | ||
let dialogHarness: CreateOrEditSearchConfigDialogHarness | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [CreateOrEditSearchConfigDialogComponent], | ||
imports: [ | ||
CheckboxModule, | ||
MockAuthModule, | ||
TranslateTestingModule.withTranslations({ | ||
en: require('./../../../../../assets/i18n/en.json'), | ||
de: require('./../../../../../assets/i18n/de.json'), | ||
}), | ||
HttpClientTestingModule, | ||
ReactiveFormsModule, | ||
InputTextModule, | ||
], | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(CreateOrEditSearchConfigDialogComponent) | ||
component = fixture.componentInstance | ||
|
||
translateService = TestBed.inject(TranslateService) | ||
translateService.setDefaultLang('en') | ||
translateService.use('en') | ||
|
||
fixture.detectChanges() | ||
dialogHarness = await TestbedHarnessEnvironment.harnessForFixture(fixture, CreateOrEditSearchConfigDialogHarness) | ||
}) | ||
|
||
it('should create the component', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('should load the CreateOrEditSearchConfigDialogHarness', async () => { | ||
expect(dialogHarness).toBeTruthy() | ||
}) | ||
|
||
it('should set the DialogResult of the saveInputValuesId checkbox to true when the saveInputValuesId checkbox is checked', async () => { | ||
const saveInputValuesCheckbox = await dialogHarness.getHarness( | ||
PCheckboxHarness.with({ inputid: 'saveInputValuesId' }) | ||
) | ||
await saveInputValuesCheckbox.click() | ||
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined } | ||
component.ocxDialogButtonClicked(_state) | ||
const dialogResult = { | ||
searchConfigName: '', | ||
saveInputValues: true, | ||
saveColumns: false, | ||
} | ||
expect(component.dialogResult).toEqual(dialogResult) | ||
}) | ||
|
||
it('should set the DialogResult of the saveColumnsId checkbox initially false', async () => { | ||
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined } | ||
await component.ocxDialogButtonClicked(_state) | ||
const dialogResult = { | ||
searchConfigName: '', | ||
saveInputValues: false, | ||
saveColumns: false, | ||
} | ||
expect(component.dialogResult).toEqual(dialogResult) | ||
}) | ||
|
||
it('should set the DialogResult of the searchConfig input Field to the entered value', async () => { | ||
await (await dialogHarness.getSearchConfigInputHarness()).setValue('search Config') | ||
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined } | ||
await component.ocxDialogButtonClicked(_state) | ||
const dialogResult = { | ||
searchConfigName: 'search Config', | ||
saveInputValues: false, | ||
saveColumns: false, | ||
} | ||
expect(component.dialogResult).toEqual(dialogResult) | ||
}) | ||
|
||
it('should set the saveColumnsId checkbox initially to unchecked', async () => { | ||
const saveInputValuesCheckbox = await dialogHarness.getSaveColumnsCheckboxHarness() | ||
const checked = await saveInputValuesCheckbox.isChecked() | ||
expect(checked).toBeFalsy() | ||
}) | ||
|
||
it('should set the saveInputValues checkbox initially to unchecked', async () => { | ||
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness() | ||
const checked = await saveInputValuesCheckbox.isChecked() | ||
expect(checked).toBeFalsy() | ||
}) | ||
|
||
it('should set the saveInputValues checkbox to true when it is clicked', async () => { | ||
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness() | ||
await saveInputValuesCheckbox.click() | ||
const checked = await saveInputValuesCheckbox.isChecked() | ||
expect(checked).toBeTruthy() | ||
}) | ||
|
||
it('should emit true when the searchConfig name is not an empty string and the saveColumnsCheckBox is clicked', async () => { | ||
let done: () => void | ||
const finished = new Promise<void>((resolve) => (done = resolve)) | ||
let enabled = false | ||
component.primaryButtonEnabled.subscribe((v) => { | ||
enabled = v | ||
done() | ||
}) | ||
|
||
const searchConfigInputHarness = await dialogHarness.getSearchConfigInputHarness() | ||
searchConfigInputHarness.setValue('test') | ||
const saveInputValuesCheckbox = await dialogHarness.getSaveColumnsCheckboxHarness() | ||
await saveInputValuesCheckbox.click() | ||
|
||
await finished | ||
expect(enabled).toEqual(true) | ||
}) | ||
|
||
it('emit true when the searchConfig Name is not an empty string and the saveInputValuesCheckbox is clicked', async () => { | ||
let done: () => void | ||
const finished = new Promise<void>((resolve) => (done = resolve)) | ||
let enabled = false | ||
component.primaryButtonEnabled.subscribe((v) => { | ||
enabled = v | ||
done() | ||
}) | ||
|
||
const searchConfigInputHarness = await dialogHarness.getSearchConfigInputHarness() | ||
searchConfigInputHarness.setValue('test') | ||
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness() | ||
await saveInputValuesCheckbox.click() | ||
|
||
await finished | ||
expect(enabled).toEqual(true) | ||
}) | ||
}) |
Oops, something went wrong.