Skip to content
Snippets Groups Projects
Commit 1f1c7eb8 authored by Tadeusz Miesiąc's avatar Tadeusz Miesiąc
Browse files

fix(submaps tabs): fixed duplicated mainmap tab on app init

parent 8dcd4e5f
No related branches found
No related tags found
2 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!66fix(submaps tabs): fixed duplicated mainmap tab on app init
Pipeline #82271 passed
......@@ -5,7 +5,13 @@ import { BACKGROUNDS_MOCK, BACKGROUND_INITIAL_STATE_MOCK } from '../backgrounds/
import { RootState } from '../store';
import { INITIAL_STORE_STATE_MOCK } from '../root/root.fixtures';
import { MODELS_INITIAL_STATE_MOCK } from '../models/models.mock';
import { getBackgroundId, getInitMapPosition, getInitMapSizeAndModelId } from './map.thunks';
import {
getBackgroundId,
getInitMapPosition,
getInitMapSizeAndModelId,
getOpenedMaps,
} from './map.thunks';
import { initialMapDataFixture, initialMapStateFixture } from './map.fixtures';
const EMPTY_QUERY_DATA: QueryData = {
modelId: undefined,
......@@ -112,4 +118,42 @@ describe('map thunks - utils', () => {
});
});
});
describe('getOpenedMaps ', () => {
it('should return main map only', () => {
const openedMaps = getOpenedMaps(
{
...STATE_WITH_MODELS,
map: { ...initialMapStateFixture, data: { ...initialMapDataFixture, modelId: 5053 } },
},
EMPTY_QUERY_DATA,
);
expect(openedMaps).toEqual([
{ lastPosition: { x: 0, y: 0, z: 0 }, modelId: 5053, modelName: 'Main map' },
]);
});
it('should return main map and opened submap', () => {
const openedMaps = getOpenedMaps(
{
...STATE_WITH_MODELS,
map: { ...initialMapStateFixture, data: { ...initialMapDataFixture, modelId: 5054 } },
},
EMPTY_QUERY_DATA,
);
expect(openedMaps).toEqual([
{ lastPosition: { x: 0, y: 0, z: 0 }, modelId: 5053, modelName: 'Main map' },
{
lastPosition: {
x: 0,
y: 0,
z: 0,
},
modelId: 5054,
modelName: 'PRKN substrates',
},
]);
});
});
});
......@@ -94,7 +94,9 @@ export const getOpenedMaps = (state: RootState, queryData: QueryData): OppenedMa
{ modelId: mainMapId, modelName: MAIN_MAP, lastPosition: DEFAULT_POSITION },
];
if (queryData.modelId !== mainMapId) {
const isMainMapSetAsCurrentModel = currentModel?.idObject !== mainMapId;
if (isMainMapSetAsCurrentModel) {
openedMaps.push({
modelId: currentModel?.idObject || ZERO,
modelName: currentModel?.name || '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment