Skip to content

Commit

Permalink
feat: handle nom_cite + fix frontend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edelclaux committed Jan 17, 2025
1 parent 13154b8 commit cf824c1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
13 changes: 7 additions & 6 deletions frontend/cypress/e2e/synthese-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ describe('Tests gn_synthese', () => {
cy.get('[data-qa="synthese-obs-detail-ca"]').invoke('text').should('not.equal', '');
// vérification de la présence de l'onglet taxonomie
cy.get('.mat-mdc-tab').contains('Taxonomie').click({ force: true });
cy.get('[data-qa="synthese-obs-detail-taxo-classe"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="synthese-obs-detail-taxo-ordre"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="synthese-obs-detail-taxo-famille"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="synthese-obs-detail-taxo-cd_nom"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="synthese-obs-detail-taxo-lb_nom"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="synthese-obs-detail-taxo-cd_ref"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-classe"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-ordre"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-famille"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-cd_nom"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-lb_nom"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-cd_ref"]').invoke('text').should('not.equal', '');
cy.get('[data-qa="taxonomy-detail-taxo-nom_cite"]').invoke('text').should('not.equal', '');

// vérification de la présence de l'onglet zonage
cy.get('.mat-mdc-tab').contains('Zonage').click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Location } from '@angular/common';
import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component';

export interface ObservedTaxon extends Taxon {
nom_cite?: string;
}

@Component({
selector: 'pnx-synthese-info-obs',
templateUrl: 'synthese-info-obs.component.html',
Expand All @@ -32,7 +36,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {

public selectedObs: any;
public validationHistory: Array<any> = [];
public selectedObsTaxonDetail: Taxon;
public selectedObsTaxonDetail: ObservedTaxon;
@ViewChild('tabGroup') tabGroup;
public selectedGeom;
// public chartType = 'line';
Expand Down Expand Up @@ -198,11 +202,11 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
if (this.selectedObs['unique_id_sinp']) {
this.loadValidationHistory(this.selectedObs['unique_id_sinp']);
}
let cdNom = this.selectedObs['cd_nom'];
let areasStatus = this.selectedObs['areas'].map((area) => area.id_area);
const cdNom = this.selectedObs['cd_nom'];
const areasStatus = this.selectedObs['areas'].map((area) => area.id_area);
const taxhubFields = ['attributs', 'attributs.bib_attribut.label_attribut', 'status'];
this._gnDataService.getTaxonInfo(cdNom, taxhubFields, areasStatus).subscribe((taxInfo) => {
this.selectedObsTaxonDetail = taxInfo;
this.selectedObsTaxonDetail = { ...taxInfo, nom_cite: this.selectedObs.nom_cite };
// filter attributs
this.selectedObsTaxonDetail.attributs = taxInfo['attributs'].filter((v) =>
this.config.SYNTHESE.ID_ATTRIBUT_TAXHUB.includes(v.id_attribut)
Expand All @@ -225,6 +229,7 @@ export class SyntheseInfoObsComponent implements OnInit, OnChanges {
this.filterTabs();
this.selectedTab = this.selectedTab ? this.selectedTab : this.defaultTab;
this.selectTab(this.selectedTab);
console.log(this.selectedObs);
});

this._gnDataService.getProfileConsistancyData(this.idSynthese).subscribe((dataChecks) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ <h5 class="Taxonomy__subtitle">Classification</h5>
class="Classification font-xs table table-striped table-sm"
>
<tbody>
<tr *ngFor="let information of INFORMATIONS">
<td class="Classification__name">{{ information.label }}</td>
<tr *ngFor="let information of informationsFiltered">
<td class="Classification__name">
{{ information.label }}
</td>
<td
class="Classification__value"
[data-qa]="'synthese-obs-detail-taxo-' + taxon.field"
[attr.data-qa]="'taxonomy-detail-taxo-' + taxon.field"
>
{{ taxon[information.field] }}
</td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Component, Input, OnInit } from '@angular/core';
import { Taxon } from '@geonature_common/form/taxonomy/taxonomy.component';
import { ObservedTaxon } from '../synthese-info-obs.component';

interface TaxonInformation {
label: string;
field: keyof Taxon;
field: keyof ObservedTaxon;
}

@Component({
Expand All @@ -13,7 +13,7 @@ interface TaxonInformation {
})
export class TaxonomyComponent {
@Input()
taxon: Taxon | null = null;
taxon: ObservedTaxon | null = null;

@Input()
hideLocalAttributesOnEmpty: boolean = false;
Expand Down Expand Up @@ -47,7 +47,11 @@ export class TaxonomyComponent {
},
{
label: 'Nom cite',
field: 'nom_complet',
field: 'nom_cite',
},
];

get informationsFiltered() {
return this.INFORMATIONS.filter((information) => this.taxon[information.field]);
}
}

0 comments on commit cf824c1

Please sign in to comment.