Skip to content

Commit

Permalink
Merge pull request #1661 from SciCatProject/SWAP-4299-proposal-type
Browse files Browse the repository at this point in the history
feat: add proposal type
  • Loading branch information
martin-trajanovski authored Nov 19, 2024
2 parents 47ea357 + 66f936a commit 2f46db8
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
1 change: 1 addition & 0 deletions CI/e2e/docker-compose.e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ services:
volumes:
- "./CI/e2e/.env.backend.e2e:/home/node/app/.env"
- "./CI/e2e/functionalAccounts.e2e.json:/home/node/app/functionalAccounts.json"
- "./CI/e2e/proposalTypes.e2e.json:/home/node/app/proposalTypes.json"
- "./CI/e2e/frontend.config.e2e.json:/home/node/app/dist/config/frontend.config.json"
depends_on:
mongodb:
Expand Down
4 changes: 4 additions & 0 deletions CI/e2e/proposalTypes.e2e.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"DOORProposal": "DOOR Proposal",
"Beamtime": "Beamtime"
}
33 changes: 33 additions & 0 deletions cypress/e2e/proposals/proposals-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,38 @@ describe("Proposals general", () => {

cy.get("mat-card").should("not.contain", newProposal.title);
});

it("proposal should have type", () => {
const defaultProposalType = "Default Proposal";
const newProposal = {
...testData.proposal,
proposalId: Math.floor(100000 + Math.random() * 900000).toString(),
};
cy.createProposal(newProposal);

cy.visit(`/proposals/${newProposal.proposalId}`);

cy.finishedLoading();

cy.contains(newProposal.title);

cy.finishedLoading();

cy.get('[data-cy="proposal-type"]').contains(defaultProposalType);

const newProposalType = "Beamtime";

cy.updateProposal(newProposal.proposalId, {
type: newProposalType,
});

cy.reload();

cy.finishedLoading();

cy.contains(newProposal.title);

cy.get('[data-cy="proposal-type"]').contains(newProposalType);
});
});
});
24 changes: 24 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,30 @@ Cypress.Commands.add("createProposal", (proposal) => {
});
});
});
Cypress.Commands.add("updateProposal", (proposalId, updateProposalDto) => {
return cy.getCookie("$LoopBackSDK$user").then((userCookie) => {
const user = JSON.parse(decodeURIComponent(userCookie.value));

cy.getCookie("$LoopBackSDK$id").then((idCookie) => {
const token = idCookie.value;
cy.log(
"Update proposal DTO: " + JSON.stringify(updateProposalDto, null, 2),
);
cy.log("User: " + JSON.stringify(user, null, 2));

cy.request({
method: "PATCH",
url: `${lbBaseUrl}/Proposals/${encodeURIComponent(proposalId)}`,
headers: {
Authorization: token,
Accept: "application/json",
"Content-Type": "application/json",
},
body: updateProposalDto,
});
});
});
});

Cypress.Commands.add("deleteProposal", (id) => {
cy.getCookie("$LoopBackSDK$id").then((idCookie) => {
Expand Down
12 changes: 11 additions & 1 deletion src/app/proposals/proposal-detail/proposal-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@
</tr>
</ng-template>
</ng-template>
<tr *ngIf="proposal['parentProposalId'] && parentProposal$ | async as parentProposal">
<tr data-cy="proposal-type">
<th>Type</th>
<!-- TODO: Change this to just proposal.type when new sdk is merged -->
<td>{{ proposal["type"] }}</td>
</tr>
<tr
*ngIf="
proposal['parentProposalId'] && parentProposal$
| async as parentProposal
"
>
<th>Parent proposal</th>
<td>
<a (click)="onClickProposal(parentProposal.proposalId)">{{
Expand Down

0 comments on commit 2f46db8

Please sign in to comment.