Skip to content

Commit

Permalink
reviewing latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrosx committed Feb 6, 2025
2 parents 07723d5 + d70575d commit f3c3b27
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 49 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/datasets/datasets-detail-dynamic.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mergeConfig } from "../../support/utils";
describe("Datasets Detail View Dynamic", () => {
const dynamicComponentConfig = testConfig.dynamicDetialViewComponent;
const customizedLabelSets =
dynamicComponentConfig.datasetDetailViewLabelOption.labelSets.test;
dynamicComponentConfig.labelsLocalization.datasetCustom;
const customizedComponents =
dynamicComponentConfig.datasetDetailComponent.customization;

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("Datasets general", () => {
});
});

describe.only("Dataset page filter and scientific condition UI test", () => {
describe("Dataset page filter and scientific condition UI test", () => {
it("should not be able to add duplicated conditions ", () => {
cy.visit("/datasets");

Expand Down
56 changes: 56 additions & 0 deletions cypress/e2e/proposals/proposals-general.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { testData } from "../../fixtures/testData";
import { testConfig } from "../../fixtures/testData";
import { mergeConfig } from "../../support/utils";

describe("Proposals general", () => {
let proposal;
const proposalLabelsConfig = testConfig.proposalViewCustomLabels;
beforeEach(() => {
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
const mergedConfig = mergeConfig(baseConfig, proposalLabelsConfig);
cy.intercept("GET", "**/admin/config", mergedConfig).as(
"getFrontendConfig",
);
});
cy.login(Cypress.env("username"), Cypress.env("password"));
});

Expand Down Expand Up @@ -210,4 +219,51 @@ describe("Proposals general", () => {
.click();
});
});

describe("Proposal view details labelization", () => {
it("should load proposal with fallback labels when no custom labels are available", () => {
const fallbackLabelsToCheck = ["Main proposer", "Proposal Type"];
const customizedLabelsToCheck = [
"Test Proposal Title",
"Test Abstract",
"Test Proposal Id",
];

proposal = {
...testData.proposal,
title: "Cypress test parent proposal",
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
};
cy.createProposal(proposal);

cy.visit("/proposals");

cy.get("mat-table mat-header-row").should("exist");

cy.finishedLoading();

cy.get("mat-table mat-row").should("contain", proposal.proposalId);

cy.get("mat-row")
.contains(proposal.proposalId)
.parent()
.contains(proposal.title)
.click();

cy.url().should("include", `/proposals/${proposal.proposalId}`);

cy.contains(proposal.title);

cy.wrap([...fallbackLabelsToCheck, ...customizedLabelsToCheck]).each(
(value) => {
cy.get("mat-card").should(($matCards) => {
const matchFound = [...$matCards].some((card) =>
card.innerText.includes(value),
);
expect(matchFound).to.be.true;
});
},
);
});
});
});
58 changes: 31 additions & 27 deletions cypress/fixtures/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,18 @@ export const testData = {

export const testConfig = {
dynamicDetialViewComponent: {
datasetDetailViewLabelOption: {
currentLabelSet: "test",
labelSets: {
test: {
datasetName: "Test String",
description: "Test Copy",
ownerEmail: "Test Linky",
keywords: "Test Tag",
"Section Label Regular": "Test Section Regular",
"Section Label Attachments": "Test Section Attachments",
"Section Label Metadata JSON": "Test Section Metadata JSON",
"Section Label Metadata TABLE": "Test Section Metadata TABLE",
"Section Label Metadata TREE": "Test Section Metadata TREE",
"Section Label Dataset JsonView": "Test Section Dataset JsonView",
},
labelsLocalization: {
datasetCustom: {
datasetName: "Test String",
description: "Test Copy",
ownerEmail: "Test Linky",
keywords: "Test Tag",
"Section Label Regular": "Test Section Regular",
"Section Label Attachments": "Test Section Attachments",
"Section Label Metadata JSON": "Test Section Metadata JSON",
"Section Label Metadata TABLE": "Test Section Metadata TABLE",
"Section Label Metadata TREE": "Test Section Metadata TREE",
"Section Label Dataset JsonView": "Test Section Dataset JsonView",
},
},
datasetDetailComponent: {
Expand Down Expand Up @@ -235,23 +232,30 @@ export const testConfig = {
},
},
defaultDetailViewComponent: {
datasetDetailViewLabelOption: {
currentLabelSet: "test",
labelSets: {
test: {
"Dataset Name": "Test Dataset name",
Description: "Test Description",
"Creation time": "Test Creation time",
Pid: "Test Pid",
Type: "Test Type",
"General Information": "Test General Information",
"Creator Information": "Creator Information",
},
labelsLocalization: {
datasetDefault: {
"Dataset Name": "Test Dataset name",
Description: "Test Description",
"Creation time": "Test Creation time",
Pid: "Test Pid",
Type: "Test Type",
"General Information": "Test General Information",
"Creator Information": "Creator Information",
},
},
datasetDetailComponent: {
enableCustomizedComponent: false,
customization: [],
},
},
proposalViewCustomLabels: {
labelsLocalization: {
proposalDefault: {
"General Information": "Test Proposal Information",
Title: "Test Proposal Title",
Abstract: "Test Abstract",
"Proposal Id": "Test Proposal Id",
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ describe("DatasetDetailDynamicComponent", () => {
navigateByUrl: jasmine.createSpy("navigateByUrl"),
};

const getConfig = () => ({
datasetDetailViewLabelOption: {
currentLabel: "test",
},
});
const getConfig = () => ({});

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class DatasetDetailDynamicComponent implements OnInit {
private store: Store,
private fb: FormBuilder,
) {
this.translateService.use(
this.appConfig.datasetDetailViewLabelOption?.currentLabelSet,
);
this.translateService.use("datasetCustom");
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ describe("DatasetDetailComponent", () => {
navigateByUrl: jasmine.createSpy("navigateByUrl"),
};

const getConfig = () => ({
datasetDetailViewLabelOption: {
currentLabel: "test",
},
});
const getConfig = () => ({});

let store: MockStore;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ export class DatasetDetailComponent implements OnInit, OnDestroy {
private router: Router,
private fb: FormBuilder,
) {
this.translateService.use(
this.appConfig.labelsLocalization?.currentLabelSet["dataset-default"],
);
this.translateService.use("datasetDefault");
}

ngOnInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<mat-card-content>
<table>
<tr>
<th>{{ "Main proposer" | translate }}</th>
<th>{{ "Main proposer" | translate }}</th>
<td *ngIf="proposal.firstname && proposal.lastname; else noName">
<a href="mailto:{{ proposal.email }}"
>{{ proposal.firstname }} {{ proposal.lastname }}</a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
private store: Store,
private translateService: TranslateService,
) {
this.translateService.use(
this.appConfig.labelsLocalization?.currentLabelSet,
);
this.translateService.use("proposalDefault");
}

ngOnInit() {
Expand Down

0 comments on commit f3c3b27

Please sign in to comment.