From 73015c32a909de06f2e265429accc4d3fae5a69e Mon Sep 17 00:00:00 2001 From: Jacobe2169 Date: Tue, 12 Mar 2024 09:47:02 +0100 Subject: [PATCH] update dataset component test --- .../form/datasets/datasets.component.cy.ts | 21 +++++++++++-------- .../form/datasets/datasets.component.ts | 4 +++- .../dumb-select/dumb-select.component.cy.ts | 16 ++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 frontend/src/app/GN2CommonModule/form/dumb-select/dumb-select.component.cy.ts diff --git a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.cy.ts b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.cy.ts index 34d490a8fb..a7f036da0d 100644 --- a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.cy.ts +++ b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.cy.ts @@ -3,27 +3,30 @@ import { IterableDiffers, } from '@angular/core'; import { DataFormService } from "../data-form.service"; -import { EMPTY, Observable, from } from 'rxjs'; -import * as gerard from '../../GN2Common.module'; -import { UntypedFormControl } from "@angular/forms"; +import { from } from 'rxjs'; +import { FormControl, FormGroup } from "@angular/forms"; +import { NgSelectModule } from "@ng-select/ng-select"; export class DataFormServiceMock { constructor() { } getDatasets(params, queryStrings = {}, fields = []) { - console.log("pouet") - return from([{ dataset_name: "test" }]) + return from([{ dataset_name: "test", id_dataset: 1, id_acquisition_framework: 1 }]) } } describe("Dataset Component", () => { it("show component", () => { + let p = new FormGroup({ + id_dataset: new FormControl(null) + }) cy.mount(DatasetsComponent, { componentProperties: { - idAcquisitionFramework: 0, - displayOnlyActive: true, - parentFormControl: new UntypedFormControl() + parentFormControl: new FormControl(), + label: "Jeux de données", + //multiSelect: true, + idAcquisitionFramework: 1 }, - imports: [], + imports: [NgSelectModule], declarations: [DatasetsComponent], providers: [ IterableDiffers, diff --git a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.ts b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.ts index 988710c1ed..892baf0132 100644 --- a/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.ts +++ b/frontend/src/app/GN2CommonModule/form/datasets/datasets.component.ts @@ -10,6 +10,8 @@ import { import { DataFormService } from '../data-form.service'; import { GenericFormComponent } from '@geonature_common/form/genericForm.component'; import { Validators } from '@angular/forms'; +import { ContentObserver } from '@angular/cdk/observers'; +import { data } from 'cypress/types/jquery'; /** * Ce composant permet de créer un "input" de type "select" ou "multiselect" affichant l'ensemble des jeux de données sur lesquels l'utilisateur connecté a des droits (table ``gn_meta.t_datasets`` et ``gn_meta.cor_dataset_actor``) @@ -66,7 +68,6 @@ export class DatasetsComponent extends GenericFormComponent implements OnInit, O ngOnInit() { this.bindValue = this.bindAllItem ? null : this.bindValue; - console.log("pouetpouet") this.getDatasets(); } @@ -83,6 +84,7 @@ export class DatasetsComponent extends GenericFormComponent implements OnInit, O } this._dfs.getDatasets((params = filter_param)).subscribe((datasets) => { this.datasets = datasets; + console.log(datasets) this.valueLoaded.emit({ value: datasets }); if ( datasets.length == 1 && diff --git a/frontend/src/app/GN2CommonModule/form/dumb-select/dumb-select.component.cy.ts b/frontend/src/app/GN2CommonModule/form/dumb-select/dumb-select.component.cy.ts new file mode 100644 index 0000000000..fdb5b269b0 --- /dev/null +++ b/frontend/src/app/GN2CommonModule/form/dumb-select/dumb-select.component.cy.ts @@ -0,0 +1,16 @@ +import { DumbSelectComponent } from "./dumb-select.component" + +describe("Dumb Select Component", () => { + it("show component", () => { + cy.mount(DumbSelectComponent, { + componentProperties: { + items: "test", + comparedKey: "test", + titleKey: "test", + displayedKey: "test", + displayNullValue: true, + nullValueLabel: "test" + } + }) + }) +}) \ No newline at end of file