Skip to content

Commit

Permalink
EES-5542 map tests reflecting abstracting geoJson fetching outside ab…
Browse files Browse the repository at this point in the history
…ove map component
  • Loading branch information
bennettstuart committed Dec 20, 2024
1 parent 64f7683 commit 4a49443
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
meta={testFullTable.subjectMeta}
tableTitle="Table title"
Expand Down Expand Up @@ -71,7 +70,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
meta={testFullTable.subjectMeta}
tableTitle="Table title"
Expand Down Expand Up @@ -118,7 +116,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
meta={testFullTable.subjectMeta}
tableTitle="Table title"
Expand Down Expand Up @@ -197,7 +194,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
meta={testFullTable.subjectMeta}
tableTitle="Table title"
Expand Down Expand Up @@ -275,7 +271,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
meta={testFullTable.subjectMeta}
tableTitle="Table title"
Expand Down Expand Up @@ -366,8 +361,7 @@ describe('ChartBuilder', () => {

test('calls `onTableQueryUpdate` when change boundary level', async () => {
const testInitialChart: Chart = {
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
type: 'map',
boundaryLevel: 2,
map: {
Expand Down Expand Up @@ -417,7 +411,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
initialChart={testInitialChart}
meta={{
Expand Down Expand Up @@ -459,8 +452,7 @@ describe('ChartBuilder', () => {
describe('data groupings tab', () => {
const testInitialChart: Chart = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
boundaryLevel: 2,
map: {
dataSetConfigs: [
Expand Down Expand Up @@ -578,7 +570,6 @@ describe('ChartBuilder', () => {
<ChartBuilderFormsContextProvider initialForms={testFormState}>
<ChartBuilder
releaseId="release-1"
dataBlockParentId="dataBlockParent-1"
data={testFullTable.results}
initialChart={testInitialChart}
meta={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ describe('ChartBuilderPreview', () => {

const testMapChartRenderer: ChartRendererProps = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
data: [],
meta: testFullTableMeta.subjectMeta,
alt: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('ChartBuilderTabSection', () => {

const testChart: Chart = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
boundaryLevel: 2,
map: {
dataSetConfigs: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,7 @@ describe('chartBuilderReducer', () => {
test('has correct state with initial configuration for a map', () => {
const initialConfiguration: Chart = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
legend: {
position: 'top',
items: [],
Expand Down Expand Up @@ -1252,8 +1251,7 @@ describe('chartBuilderReducer', () => {
test('setting boundary levels does not change data groupings', () => {
const initialConfiguration: Chart = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
legend: {
position: 'top',
items: [],
Expand Down Expand Up @@ -1363,8 +1361,7 @@ describe('chartBuilderReducer', () => {
test('setting data groupings does not change boundary levels', () => {
const initialConfiguration: Chart = {
type: 'map',
releaseId: 'releaseId',
dataBlockParentId: 'dataBlockParentId',
onBoundaryLevelChange: () => {},
legend: {
position: 'top',
items: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,6 @@ describe('MapBlock', () => {
data: testFullTable.results,
height: 600,
width: 900,
map: {
dataSetConfigs: [
{
dataGrouping: { customGroups: [], type: 'EqualIntervals' },
dataSet: {
filters: ['characteristic-total', 'school-type-total'],
indicator: 'authorised-absence-rate',
timePeriod: '2016_AY',
},
},
{
dataGrouping: { customGroups: [], type: 'EqualIntervals' },
dataSet: {
filters: ['characteristic-total', 'school-type-total'],
indicator: 'overall-absence-rate',
timePeriod: '2016_AY',
},
boundaryLevel: 2,
},
],
},
onBoundaryLevelChange,
};

Expand Down Expand Up @@ -184,7 +163,6 @@ describe('MapBlock', () => {
expect(legendColours[4].style.backgroundColor).toBe('rgb(245, 164, 80)');
});

// EES-5718 name should be: 'selecting data set with different boundary level fetches and renders different boundary geo-JSON'
test('selecting data set with different boundary level calls onBoundaryLevelChange', async () => {
render(<MapBlock {...testBlockProps} />);

Expand All @@ -197,14 +175,11 @@ describe('MapBlock', () => {
// Selecting another data set with different boundary level
await userEvent.selectOptions(dataSetSelectInput, dataSetOptions[1]);

waitFor(() => {
// Fetching new geoJson
expect(screen.getByTestId('loadingSpinner')).toBeInTheDocument();
expect(onBoundaryLevelChange).toHaveBeenCalled();
await waitFor(() => {
// EES-4902 map containing spinner isn't currently rendered in tests
// expect(screen.getByTestId('loadingSpinner')).toBeInTheDocument();
});

// TODO: EES-5718
// test that returned location geo Json is actually renderred on the screen when 'selecting data set with different boundary level fetches different boundary geo-JSON'
expect(onBoundaryLevelChange).toHaveBeenCalledWith(2);
});

test.skip('changing selected location focuses the correct polygon', async () => {
Expand Down
Loading

0 comments on commit 4a49443

Please sign in to comment.