-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend datamap table with custom fields (#4579)
Co-authored-by: Adrian Galvan <[email protected]>
- Loading branch information
1 parent
9d5e760
commit 1ec5c12
Showing
6 changed files
with
1,274 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
stubPlus, | ||
stubSystemCrud, | ||
stubTaxonomyEntities, | ||
} from "cypress/support/stubs"; | ||
|
||
import { REPORTING_DATAMAP_ROUTE } from "~/features/common/nav/v2/routes"; | ||
import { | ||
AllowedTypes, | ||
CustomFieldDefinition, | ||
ResourceTypes, | ||
} from "~/types/api"; | ||
|
||
const mockCustomField = (overrides?: Partial<CustomFieldDefinition>) => { | ||
const base = { | ||
name: "Prime number", | ||
description: null, | ||
field_type: "string", | ||
allow_list_id: "id-allow-list-prime-numbers", | ||
resource_type: "system", | ||
field_definition: null, | ||
active: true, | ||
id: "id-custom-field-definition-prime-number", | ||
}; | ||
if (overrides) { | ||
return { ...base, ...overrides }; | ||
} | ||
return base; | ||
}; | ||
|
||
describe("Datamap table and spatial view", () => { | ||
beforeEach(() => { | ||
cy.login(); | ||
stubPlus(true); | ||
stubSystemCrud(); | ||
stubTaxonomyEntities(); | ||
cy.intercept("GET", "/api/v1/plus/datamap/minimal*", { | ||
fixture: "datamap/minimal.json", | ||
}).as("getDatamapMinimal"); | ||
cy.intercept( | ||
"GET", | ||
"/api/v1/plus/custom-metadata/custom-field-definition", | ||
{ | ||
body: [ | ||
mockCustomField({ name: "Starter pokemon" }), | ||
mockCustomField({ | ||
name: "Pokemon party", | ||
// eslint-disable-next-line no-underscore-dangle | ||
field_type: AllowedTypes.STRING_, | ||
}), | ||
mockCustomField({ | ||
name: "color", | ||
resource_type: ResourceTypes.DATA_USE, | ||
}), | ||
], | ||
} | ||
); | ||
cy.visit(REPORTING_DATAMAP_ROUTE); | ||
}); | ||
|
||
it("can render custom fields", () => { | ||
// Should render the custom fields as columns | ||
cy.getByTestId("column-system_starter_pokemon").contains("Starter pokemon"); | ||
cy.getByTestId("column-system_pokemon_party").contains("Pokemon party"); | ||
cy.getByTestId("column-privacy_declaration_color").contains("Color"); | ||
|
||
// Pokemon party is multi-select, so we should have a menu to allow grouping/displaying all | ||
cy.getByTestId("row-0-col-system_pokemon_party").contains("3"); | ||
cy.getByTestId("system_pokemon_party-header-menu").click(); | ||
cy.getByTestId("system_pokemon_party-header-menu-list").within(() => { | ||
cy.get("button").contains("Display all").click(); | ||
}); | ||
["eevee", "pikachu", "articuno"].forEach((pokemon) => { | ||
cy.getByTestId("row-0-col-system_pokemon_party").contains(pokemon); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.