Skip to content

Commit

Permalink
added e2e test for the change
Browse files Browse the repository at this point in the history
  • Loading branch information
Junjiequan committed Nov 28, 2024
1 parent 1501014 commit 351914a
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 2 deletions.
51 changes: 51 additions & 0 deletions cypress/e2e/datasets/datasets-general.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,55 @@ describe("Datasets general", () => {
cy.deleteProposal(proposalId);
});
});

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

cy.get(".user-button").click();

cy.get("[data-cy=logout-button]").click();

cy.finishedLoading();

cy.visit("/datasets");

cy.get('[data-cy="more-filters-button"]').click();

cy.get('[data-cy="add-scientific-condition-button"]').click();

cy.get('input[name="lhs"]').type("test");
cy.get('input[name="rhs"]').type("1");

cy.get('button[type="submit"]').click();

cy.get('[data-cy="add-scientific-condition-button"]').click();

cy.get('input[name="lhs"]').type("test");
cy.get('input[name="rhs"]').type("1");

cy.get('button[type="submit"]').click();

cy.get(".snackbar-warning")
.should("contain", "Condition already exists")
.contains("Close")
.click();

cy.get('[data-cy="scientific-condition-filter-list"').should(
"have.length",
1,
);

cy.get('[data-cy="add-scientific-condition-button"]').click();

cy.get('input[name="lhs"]').type("test");
cy.get('input[name="rhs"]').type("2");

cy.get('button[type="submit"]').click();

cy.get('[data-cy="scientific-condition-filter-list"]')
.find("input")
.should("have.length", 2);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@
</ng-container>
</ng-container>

<div class="section-container" *ngIf="appConfig.scienceSearchEnabled">
<div
class="section-container"
*ngIf="appConfig.scienceSearchEnabled"
data-cy="scientific-condition-filter-list"
>
<ng-container *ngFor="let condition of scientificConditions$ | async">
<ng-container
*ngComponentOutlet="ConditionFilterComponent; inputs: { condition }"
></ng-container>
</ng-container>
</div>

<div class="section-container">
<div class="section-container" data-cy="more-filters-button">
<button
mat-button
class="full-width-button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ <h2 mat-dialog-title>Configure Filters</h2>
color="primary"
*ngIf="appConfig.scienceSearchEnabled"
(click)="addCondition()"
data-cy="add-scientific-condition-button"
>
<mat-icon>add</mat-icon>
Add Conditions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export class DatasetsFilterSettingsComponent {
if (existingConditionIndex !== -1) {
this.snackBar.open("Condition already exists", "Close", {
duration: 2000,
panelClass: ["snackbar-warning"],
});
return;
}
Expand Down

0 comments on commit 351914a

Please sign in to comment.