Skip to content

Commit

Permalink
Regulated toggle bug (#4544)
Browse files Browse the repository at this point in the history
  • Loading branch information
allisonking committed Jan 3, 2024
1 parent 3d0eb86 commit 380463e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
13 changes: 13 additions & 0 deletions clients/admin-ui/cypress/e2e/locations.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ describe("Locations", () => {
cy.getByTestId("Venezuela-checkbox").should("not.exist");
});

// Toggle "regulated" in Africa which has no regulations
cy.getByTestId("picker-card-Africa").within(() => {
cy.getByTestId("Eritrea-checkbox");
cy.getByTestId("regulated-toggle").click();
cy.getByTestId("Eritrea-checkbox").should("not.exist");
cy.getByTestId("regulated-toggle").click();
cy.getByTestId("Eritrea-checkbox");
});

// North America should have stayed the same through all this
cy.getByTestId("picker-card-North America").within(() => {
assertIsChecked("Canada-checkbox", "unchecked");
Expand Down Expand Up @@ -196,6 +205,10 @@ describe("Locations", () => {
expect(body.regulations).to.eql([]);
// Check locations
expect(body.locations).to.eql([
{
id: "er",
selected: false,
},
{
id: "fr",
selected: true,
Expand Down
8 changes: 8 additions & 0 deletions clients/admin-ui/cypress/fixtures/locations/list.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"locations": [
{
"id": "er",
"selected": false,
"name": "Eritrea",
"continent": "Africa",
"belongs_to": [],
"regulation": []
},
{
"id": "fr",
"selected": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ const LocationPickerCard = ({
handleChange(Array.from(newSelected));
};

if (filteredLocations.length === 0) {
// Do not render the card if search ends up with no results
if (filteredLocations.length === 0 && search) {
return null;
}

Expand Down

0 comments on commit 380463e

Please sign in to comment.