Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: swap 4462 proposal metadata and label localization #1717

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e226497
changed localization configuration to be used across different compon…
nitrosx Jan 22, 2025
85d1b05
first draft of proposal with metadata and localization
nitrosx Jan 23, 2025
3ed96b1
remove metadata edit for proposals
nitrosx Jan 24, 2025
15b008a
fixed proposal unit test
nitrosx Jan 24, 2025
afe32b8
added metadata editing
nitrosx Feb 3, 2025
209c17c
Merge branch 'master' into swap-4462-proposal-metadata
nitrosx Feb 3, 2025
dafe4b8
solving test failing
nitrosx Feb 3, 2025
f299a11
added custom translate pipe to localize per componeent
nitrosx Feb 4, 2025
d79d7e9
Solved conflicts from merging with master
nitrosx Feb 4, 2025
e314d45
more conflicts solved
nitrosx Feb 4, 2025
1dd83b3
remove metadata edit for proposals
nitrosx Jan 24, 2025
bcce2a5
fixed proposal unit test
nitrosx Jan 24, 2025
6f23139
added metadata editing
nitrosx Feb 3, 2025
3de0803
solving test failing
nitrosx Feb 3, 2025
7cd383b
more conflicts
nitrosx Feb 4, 2025
c21bc99
wip before merge with master
nitrosx Feb 4, 2025
1c1b212
change translate to use the current config
nitrosx Feb 4, 2025
42932f2
Fixed conflicts
nitrosx Feb 4, 2025
c2efb92
sloved latest conflicts
nitrosx Feb 4, 2025
7783fc3
forgot latest changes
nitrosx Feb 4, 2025
07723d5
another one forgotten
nitrosx Feb 4, 2025
e3de60e
remove metadata edit for proposals
nitrosx Jan 24, 2025
d5e5741
added metadata editing
nitrosx Feb 3, 2025
146e2e0
fix unit test
Junjiequan Feb 4, 2025
443a365
fix e2e test
Junjiequan Feb 4, 2025
2ddfa7d
e2e test for proposal
Junjiequan Feb 4, 2025
53edef6
fix e2e
Junjiequan Feb 4, 2025
d70575d
remove .only from cypress
Junjiequan Feb 4, 2025
f3c3b27
reviewing latest changes
nitrosx Feb 6, 2025
03cf696
reverting back changes to translator loader
nitrosx Feb 6, 2025
56010a6
fix electron error
Junjiequan Feb 6, 2025
8d14680
partial-fix-e2e
Junjiequan Feb 6, 2025
8474741
enable cypress video
Junjiequan Feb 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions CI/e2e/frontend.config.e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"files": "all",
"mat_icon": "download",
"type": "form",
"url": "https://www.scicat.info/download/all",
"url": "http://localhost:4200/download/all",
"target": "_blank",
"enabled": "#SizeLimit",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand All @@ -77,7 +77,7 @@
"files": "selected",
"mat_icon": "download",
"type": "form",
"url": "https://www.scicat.info/download/selected",
"url": "http://localhost:4200/download/selected",
"target": "_blank",
"enabled": "#Selected && #SizeLimit",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand All @@ -89,7 +89,7 @@
"files": "all",
"icon": "/assets/icons/jupyter_logo.png",
"type": "form",
"url": "https://www.scicat.info/notebook/all",
"url": "http://localhost:4200/notebook/all",
"target": "_blank",
"authorization": ["#datasetAccess", "#datasetPublic"]
},
Expand All @@ -100,7 +100,7 @@
"files": "selected",
"icon": "/assets/icons/jupyter_logo.png",
"type": "form",
"url": "https://www.scicat.info/notebook/selected",
"url": "http://localhost:4200/notebook/selected",
"target": "_blank",
"enabled": "#Selected",
"authorization": ["#datasetAccess", "#datasetPublic"]
Expand Down Expand Up @@ -208,5 +208,7 @@
{ "TextFilter": true }
],
"conditions": []
}
},
"labelLocalization": {},
"datasetDetailComponent": {}
}
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from "cypress";

export default defineConfig({
video: true,
env: {
baseUrl: "http://localhost:3000/api/v3",
loginEndpoint: "/auth/login",
Expand Down
22 changes: 13 additions & 9 deletions cypress/e2e/datasets/datasets-datafiles.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
describe("Dataset datafiles", () => {
beforeEach(() => {
cy.login(Cypress.env("username"), Cypress.env("password"));
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
cy.intercept("GET", "**/admin/config", baseConfig).as(
"getFrontendConfig",
);
});
cy.intercept("PATCH", "/api/v3/datasets/**/*").as("change");
cy.intercept("GET", "*").as("fetch");
cy.login(Cypress.env("username"), Cypress.env("password"));

cy.visit("/");
cy.wait("@getFrontendConfig");
});

after(() => {
Expand All @@ -11,16 +19,14 @@ describe("Dataset datafiles", () => {

describe("Datafiles action test", () => {
const actionUrl = {
downloadSelected: "https://www.scicat.info/download/selected",
downloadAll: "https://www.scicat.info/download/all",
notebookSelected: "https://www.scicat.info/notebook/selected",
notebookAll: "https://www.scicat.info/notebook/all",
downloadSelected: "http://localhost:4200/download/selected",
downloadAll: "http://localhost:4200/download/all",
notebookSelected: "http://localhost:4200/notebook/selected",
notebookAll: "http://localhost:4200/notebook/all",
};
it("Should be able to download/notebook with selected/all", () => {
cy.createDataset("raw", undefined, "small");

cy.visit("/datasets");

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

cy.finishedLoading();
Expand Down Expand Up @@ -70,9 +76,7 @@ describe("Dataset datafiles", () => {

it("Should not be able to download selected/all file that is exceeding size limit", () => {
cy.createDataset("raw", undefined, "large");

cy.visit("/datasets");

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

cy.finishedLoading();
Expand Down
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",
},
},
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scicat-frontend",
"version": "4.5.0",
"version": "local.dev",
"license": "BSD-3-Clause",
"scripts": {
"ng": "ng",
Expand Down
4 changes: 2 additions & 2 deletions src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { timeout } from "rxjs/operators";
import {
DatasetDetailComponentConfig,
DatasetDetailViewLabelOption,
DatasetsListSettings,
LabelMaps,
LabelsLocalization,
TableColumn,
} from "state-management/models";

Expand Down Expand Up @@ -44,7 +44,7 @@
datasetReduceEnabled: boolean;
datasetDetailsShowMissingProposalId: boolean;
datafilesActionsEnabled: boolean;
datafilesActions: any[];

Check warning on line 47 in src/app/app-config.service.ts

View workflow job for this annotation

GitHub Actions / eslint

Unexpected any. Specify a different type
editDatasetSampleEnabled: boolean;
editMetadataEnabled: boolean;
editPublishedData: boolean;
Expand Down Expand Up @@ -103,8 +103,8 @@
labelMaps: LabelMaps;
thumbnailFetchLimitPerPage: number;
maxFileUploadSizeInMb?: string;
datasetDetailViewLabelOption?: DatasetDetailViewLabelOption;
datasetDetailComponent?: DatasetDetailComponentConfig;
labelsLocalization?: LabelsLocalization;
}

@Injectable()
Expand All @@ -120,12 +120,12 @@
.pipe(timeout(2000))
.toPromise();
this.appConfig = Object.assign({}, this.appConfig, config);
} catch (err) {

Check warning on line 123 in src/app/app-config.service.ts

View workflow job for this annotation

GitHub Actions / eslint

'err' is defined but never used
console.log("No config available in backend, trying with local config.");
try {
const config = await this.http.get("/assets/config.json").toPromise();
this.appConfig = Object.assign({}, this.appConfig, config);
} catch (err) {

Check warning on line 128 in src/app/app-config.service.ts

View workflow job for this annotation

GitHub Actions / eslint

'err' is defined but never used
console.error("No config provided.");
}
}
Expand Down
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.datasetDetailViewLabelOption?.currentLabelSet,
);
this.translateService.use("datasetDefault");
}

ngOnInit() {
Expand Down
Loading
Loading