mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:09:21 +00:00
fix(core): make version stack sort index lookup deterministic
When creating a version stack, the sortIndex was previously extracted by taking files[0] from the database query result. Because findMany without orderBy is non-deterministic, this resulted in flakiness where the sortIndex would sometimes be null (from file2) instead of 'abc' (from file1), causing tests to fail. We now look up the first file specifically based on the ordered fileIds array parameter.
This commit is contained in:
@@ -58,7 +58,7 @@ export class VersionStackService {
|
||||
throw new Error('parent not found')
|
||||
}
|
||||
|
||||
const firstFile = files[0]
|
||||
const firstFile = files.find((f) => f.id === fileIds[0])
|
||||
const sortIndex = firstFile?.sortIndex || null
|
||||
|
||||
const stack = await tx.asset.create({
|
||||
|
||||
Reference in New Issue
Block a user