Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 34 additions & 2 deletions cypress/e2e/proposals/proposals-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,36 @@ describe("Proposals general", () => {
});
});

describe("Proposals details default tab coniguration", () => {
beforeEach(() => {
cy.login(Cypress.env("username"), Cypress.env("password"));

const newProposal = {
...testData.proposal,
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
};
cy.createProposal(newProposal);



cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
const testConfig = {
...baseConfig,
defaultTab: { proposal: "datasets" },
};

cy.intercept("GET", "**/admin/config", testConfig).as("getConfig");
});

cy.visit(`/proposals/${newProposal.proposalId}`);
cy.wait("@getConfig");
cy.finishedLoading();
});
it("should show datasets tab if defaultProposalTab is set to datasets", () => {
cy.get('mat-tab-group').invoke('attr', 'ng-reflect-selected-index').should('eq', '1');
});
});

describe("Proposal view details labelization", () => {
it("should load proposal with fallback labels when no custom labels are available", () => {
const fallbackLabelsToCheck = ["Main proposer", "Proposal Type"];
Expand Down Expand Up @@ -555,13 +585,15 @@ describe("Proposals general", () => {
cy.get('[data-cy="apply-button-filter"]').click();

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

});
});

describe("Proposals collapsible filters", () => {
beforeEach(() => {
cy.createProposal({ ...testData.proposal, proposalId: Math.floor(100000 + Math.random() * 900000).toString() });
cy.createProposal({
...testData.proposal,
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
});
cy.readFile("CI/e2e/frontend.config.e2e.json").then((baseConfig) => {
const testConfig = {
...baseConfig,
Expand Down
5 changes: 5 additions & 0 deletions src/app/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export class MetadataFloatFormat {
maxCutoff: number; // using scientific notation above this cutoff
}

export class DefaultTab {
proposal: string;
}

export interface AppConfigInterface {
allowConfigOverrides?: boolean;
skipSciCatLoginPageEnabled?: boolean;
Expand Down Expand Up @@ -162,6 +166,7 @@ export interface AppConfigInterface {
checkBoxFilterClickTrigger?: boolean;
hideEmptyMetadataTable?: boolean;
ingestorComponent?: IngestorComponentConfig;
defaultTab?: DefaultTab;
}

function isMainPageConfiguration(obj: any): obj is MainPageConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {

localization = "proposal";

readonly tabIndexMap: Record<string, number> = {
details: 0,
datasets: 1,
relatedProposals: 2,
logbook: 3,
};

constructor(
public appConfigService: AppConfigService,
private route: ActivatedRoute,
Expand Down Expand Up @@ -69,7 +76,8 @@ export class ViewProposalPageComponent implements OnInit, OnDestroy {
}

resetTabs(): void {
this.selectedTabIndex = 0;
const defaultTab = this.appConfig.defaultTab?.proposal || "details";
this.selectedTabIndex = this.tabIndexMap[defaultTab] || 0;
}

fetchProposalRelatedDocuments(): void {
Expand Down
Loading