"TypeError: element.elements is not iterable" error

Hello, I am currently trying to fix one of our ModulF tests. In this test we provide a document model and a tree model to the general store and try to select the engine state. The selecting of the uiState and dataState work as expected but when the “TreeEngineSelectors.engineState” tries to call “modelsState” it gets the error “TypeError: element.elements is not iterable error”. The cause is the “_fillCachePathById” method of the DocumentModelSearchServiceImpl.ts file from kernel. This method gets “this.documentModel.content.modelRoot” as element but our TreeModel has “rootGroups” under “modelRoot” which causes it to fail because it expects a group directly. We use a document model of version 27.0.2 and a tree model of version 8.3.0 as well as the 2023.06 ext4 versions. What am I doing wrong here?

Hi,
this sounds like you are using the serialized form of the document model.

The content of a serialized document model looks like this:
content: { modelRoot: { rootGroups: [], ... }, ... }

However, the deserialized model should look like this:
content: { modelRoot: { id: "1", ..., elements: [...] } } (the modelRoot itself is a group)

You can find some code examples on how to deserialize a document model in Java and TypeScript in the Kernel documentation here

I hope this will help you to fix your problem