@@ -20,6 +20,7 @@ import io.kotest.assertions.ktor.client.shouldHaveStatus
20
20
import io.kotest.matchers.string.shouldContain
21
21
import io.ktor.client.call.body
22
22
import io.ktor.client.request.get
23
+ import io.ktor.client.request.parameter
23
24
import io.ktor.client.request.post
24
25
import io.ktor.client.request.setBody
25
26
import io.ktor.client.statement.bodyAsText
@@ -35,7 +36,10 @@ import org.jsoup.select.Evaluator
35
36
import org.modelix.model.api.IReferenceLink
36
37
import org.modelix.model.api.ITree
37
38
import org.modelix.model.api.NodeReferenceById
39
+ import org.modelix.model.api.PNodeAdapter
40
+ import org.modelix.model.api.addNewChild
38
41
import org.modelix.model.client.successful
42
+ import org.modelix.model.client2.ModelClientV2
39
43
import org.modelix.model.client2.runWrite
40
44
import org.modelix.model.lazy.CLVersion
41
45
import org.modelix.model.lazy.RepositoryId
@@ -140,6 +144,33 @@ class ContentExplorerTest {
140
144
assertTrue { root.childrenSize() > 0 }
141
145
}
142
146
147
+ @Test
148
+ fun `nodes can be expanded to` () = runTest {
149
+ val client = createHttpClient()
150
+ val branchRef = RepositoryId (" node-expand-to-test" ).getBranchReference(" master" )
151
+ client.post(" /v2/repositories/${branchRef.repositoryId} /init" )
152
+ val modelClient = ModelClientV2 .builder()
153
+ .client(client)
154
+ .url(" /v2" )
155
+ .build().also { it.init () }
156
+
157
+ modelClient.use {
158
+ val newestChild = modelClient.runWrite(branchRef) { rootNode ->
159
+ rootNode.addNewChild(null )
160
+ .addNewChild(null )
161
+ .addNewChild(null )
162
+ }
163
+ val versionHash = modelClient.pullHash(branchRef)
164
+ val expandToId = (newestChild as PNodeAdapter ).nodeId
165
+
166
+ val response = client.get(" /content/repositories/${branchRef.repositoryId} /versions/$versionHash /" ) {
167
+ parameter(" expandTo" , expandToId)
168
+ }
169
+ response shouldHaveStatus HttpStatusCode .OK
170
+ response.bodyAsText() shouldContain expandToId.toString()
171
+ }
172
+ }
173
+
143
174
@Test
144
175
fun `expanding to non-existing node leads to not found response` () = runTest {
145
176
val client = createHttpClient()
0 commit comments