Skip to content

Commit

Permalink
Try fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sanioooook committed Dec 25, 2023
1 parent 8729a59 commit 00c556a
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 42 deletions.
12 changes: 8 additions & 4 deletions eform-client/e2e/Page objects/Sites.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,14 @@ export class SitesRowObject {
this.siteId = +(await this.element.$('#siteUUId')).getText();
this.units = await (await this.element.$('#units')).getText();
this.siteName = await (await this.element.$('#siteName')).getText();
const list = (await (await this.element
.$('mat-chip-list'))
.$$('mat-chip > span'));
this.tags = await Promise.all(list.map(element => element.getText()));
let list = [];
try {
list = (await (await this.element.$('#tags')).$$('span'));
}catch (e) {
}
if(list) {
this.tags = await Promise.all(list.map(element => element.getText()));
}
// .map((element) => element.getText());
this.editBtn = await this.element.$('#editSiteBtn');
this.deleteBtn = await this.element.$('#deleteSiteBtn');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
<app-entity-list-elements
[entityItemModels]="entityGroupEditModel.entityItemModels"
(entityItemModelsChanged)="entityGroupEditModel.entityItemModels = $event"
(openEditNameModal)="onOpenEditNameModal($event)"
(openEditNameModal)="openEditNameModal($event)"
>
</app-entity-list-elements>
</mat-card-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class EntityEditCreateComponent implements OnInit, OnDestroy{
selectedGroupId: number;
edit: boolean;

items = [];
activateRouteDataSub$: Subscription;
activateRouteParamsSub$: Subscription;
getEntitySelectableGroupSub$: Subscription;
Expand All @@ -46,8 +45,8 @@ export class EntityEditCreateComponent implements OnInit, OnDestroy{
createEntitySearchableGroupSub$: Subscription;
updateEntitySelectableGroupSub$: Subscription;
updateEntitySearchableGroupSub$: Subscription;
entitySearchImportListComponentAfterClosedSub$: Subscription;
entityItemEditNameComponentAfterClosedSub$: Subscription;
entitySearchImportListComponentImportStringSubmitSub$: Subscription;
entityItemEditNameComponentChangedSub$: Subscription;

get title(): string {
return `${this.edit ? 'Edit' : 'Create'} ${this.header} list`
Expand Down Expand Up @@ -219,16 +218,23 @@ export class EntityEditCreateComponent implements OnInit, OnDestroy{
}
}

onOpenEditNameModal(model: EntityItemModel) {
this.entityItemEditNameComponentAfterClosedSub$ = this.dialog.open(EntityItemEditNameComponent,
{...dialogConfigHelper(this.overlay, model), minWidth: 500})
.afterClosed().subscribe(data => data.result ? this.onItemUpdated(data.data) : undefined);
openEditNameModal(model: EntityItemModel) {
const modal = this.dialog.open(EntityItemEditNameComponent,
{...dialogConfigHelper(this.overlay, model), minWidth: 500});
if(this.entityItemEditNameComponentChangedSub$) {
this.entityItemEditNameComponentChangedSub$.unsubscribe(); // unsub before create new sub
}
this.entityItemEditNameComponentChangedSub$ = modal.componentInstance.changedEntityItem.subscribe(x => this.onItemUpdated(x));
}

openImportEntityGroup() {
this.entitySearchImportListComponentAfterClosedSub$ = this.dialog.open(EntityImportListComponent,
{...dialogConfigHelper(this.overlay), minWidth: 500})
.afterClosed().subscribe(data => data.result ? this.importEntityGroup(data.data) : undefined);
const modal = this.dialog.open(EntityImportListComponent,
{...dialogConfigHelper(this.overlay), minWidth: 500});
if(this.entitySearchImportListComponentImportStringSubmitSub$) {
this.entitySearchImportListComponentImportStringSubmitSub$.unsubscribe(); // unsub before create new sub
}
this.entitySearchImportListComponentImportStringSubmitSub$ = modal.componentInstance.importStringSubmit
.subscribe(x => this.importEntityGroup(x));
}

getRandId(): number{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, OnInit} from '@angular/core';
import {Component, EventEmitter, OnInit} from '@angular/core';
import {MatDialogRef} from '@angular/material/dialog';

@Component({
Expand All @@ -8,19 +8,19 @@ import {MatDialogRef} from '@angular/material/dialog';
})
export class EntityImportListComponent implements OnInit {
importString = '';

public importStringSubmit: EventEmitter<string> = new EventEmitter<string>();
constructor(public dialogRef: MatDialogRef<EntityImportListComponent>,) { }

ngOnInit() {
}


hide(result = false) {
this.dialogRef.close({result, data: result ? this.importString : ''});
hide() {
this.dialogRef.close();
}

submitImport() {
this.hide(true);
this.importStringSubmit.emit(this.importString);
this.hide();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h3 mat-dialog-title>{{ 'Edit element' | translate}}</h3>
<button
mat-raised-button
color="accent"
(click)="hide(true)"
(click)="emitValue(); hide()"
id="entityItemSaveBtn"
>
{{'Save' | translate}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Inject, OnInit} from '@angular/core';
import {Component, EventEmitter, Inject, OnInit} from '@angular/core';
import {EntityItemModel} from 'src/app/common/models';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';

Expand All @@ -9,6 +9,7 @@ import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
})
export class EntityItemEditNameComponent implements OnInit {
public selectedEntityItemModel: EntityItemModel = new EntityItemModel();
public changedEntityItem: EventEmitter<EntityItemModel> = new EventEmitter<EntityItemModel>();
constructor(
public dialogRef: MatDialogRef<EntityItemEditNameComponent>,
@Inject(MAT_DIALOG_DATA) selectedEntityItemModel: EntityItemModel = new EntityItemModel()
Expand All @@ -19,8 +20,12 @@ export class EntityItemEditNameComponent implements OnInit {
ngOnInit() {
}

hide(result = false) {
this.dialogRef.close({result, data: result ? this.selectedEntityItemModel : null});
hide() {
this.dialogRef.close();
this.selectedEntityItemModel = new EntityItemModel();
}

emitValue() {
this.changedEntityItem.emit(this.selectedEntityItemModel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
</ng-template>
<ng-template #tagsTpl let-row>
<div id="tags">
<mat-chip-listbox>
<mat-chip *ngFor="let tag of row.tags" color="primary">
<mat-icon>discount</mat-icon>
<span>{{ getTagName(tag) }}</span>
</mat-chip>
</mat-chip-listbox>
<app-eform-tag [tags]="getTagsBySiteDto(row)"/>
</div>
</ng-template>
<ng-template #actionsTpl let-row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import {
SiteNameDto,
CommonDictionaryModel,
} from 'src/app/common/models';
import { EformsTagsComponent } from 'src/app/common/modules/eform-shared-tags/components';
import { EformTagService, SitesService } from 'src/app/common/services';
import { AuthStateService } from 'src/app/common/store';
import {EformsTagsComponent} from 'src/app/common/modules/eform-shared-tags/components';
import {EformTagService, SitesService} from 'src/app/common/services';
import {AuthStateService} from 'src/app/common/store';
import {MtxGridColumn} from '@ng-matero/extensions/grid';
import {dialogConfigHelper} from 'src/app/common/helpers';
import {MatDialog} from '@angular/material/dialog';
import {Overlay} from '@angular/cdk/overlay';
import {SiteDeleteComponent, SiteEditComponent} from 'src/app/modules/advanced/components';
import { TranslateService } from '@ngx-translate/core';
import {TranslateService} from '@ngx-translate/core';
import {AutoUnsubscribe} from 'ngx-auto-unsubscribe';
import {Subscription} from 'rxjs';
import {Store} from "@ngrx/store";
import {selectCurrentUserClaimsSitesDelete, selectCurrentUserClaimsSitesUpdate} from "src/app/state/auth/auth.selector";
import {Store} from '@ngrx/store';
import {selectCurrentUserClaimsSitesDelete, selectCurrentUserClaimsSitesUpdate} from 'src/app/state/auth/auth.selector';

@AutoUnsubscribe()
@Component({
Expand All @@ -25,6 +25,7 @@ import {selectCurrentUserClaimsSitesDelete, selectCurrentUserClaimsSitesUpdate}
export class SitesComponent implements OnInit, OnDestroy {
private selectCurrentUserClaimsSitesUpdate$ = this.authStore.select(selectCurrentUserClaimsSitesUpdate);
private selectCurrentUserClaimsSitesDelete$ = this.authStore.select(selectCurrentUserClaimsSitesDelete);

constructor(
private authStore: Store,
private sitesService: SitesService,
Expand All @@ -33,8 +34,10 @@ export class SitesComponent implements OnInit, OnDestroy {
public dialog: MatDialog,
private overlay: Overlay,
private translateService: TranslateService,
) {}
@ViewChild('modalTags', { static: true }) modalSiteTags: EformsTagsComponent;
) {
}

@ViewChild('modalTags', {static: true}) modalSiteTags: EformsTagsComponent;
sitesDto: Array<SiteNameDto> = [];
availableTags: Array<CommonDictionaryModel> = [];
siteEditComponentAfterClosedSub$: Subscription;
Expand All @@ -43,9 +46,9 @@ export class SitesComponent implements OnInit, OnDestroy {
tableHeaders: MtxGridColumn[] = [
{header: this.translateService.stream('Microting UID'), field: 'siteUId'},
{header: this.translateService.stream('Name'), field: 'siteName'},
{ header: this.translateService.stream('Units'), field: 'units', },
{ header: this.translateService.stream('Tags'), field: 'tags', },
]
{header: this.translateService.stream('Units'), field: 'units',},
{header: this.translateService.stream('Tags'), field: 'tags',},
];

getTagName(tagId: number): string {
return this.availableTags.find((x) => x.id === tagId).name;
Expand Down Expand Up @@ -125,6 +128,10 @@ export class SitesComponent implements OnInit, OnDestroy {
});
}

getTagsBySiteDto(site: SiteNameDto): CommonDictionaryModel[] {
return this.availableTags.filter(x => site.tags.some(y => y === x.id));;
}

ngOnDestroy(): void {
}
}

0 comments on commit 00c556a

Please sign in to comment.