| 130 | base_branch: 'feature/parent', |
| 131 | base_sha: baseSha, |
| 132 | sidebar_position: 'a0', |
| 133 | }), |
| 134 | ]); |
| 135 | }); |
| 136 | |
| 137 | it('defaults user settings to manual order and no overrides, with one row per user', async () => { |
| 138 | const settings = await schemaTestDb.db |
| 139 | .insert(schema.cloud_agent_user_settings) |
| 140 | .values([{ kilo_user_id: userId }, { kilo_user_id: otherUserId, workspace_order: 'created' }]) |
| 141 | .returning(); |
| 142 | expect(settings).toEqual([ |
| 143 | expect.objectContaining({ workspace_order: 'manual', builtin_agents: {} }), |
| 144 | expect.objectContaining({ workspace_order: 'created', builtin_agents: {} }), |
| 145 | ]); |
| 146 | await expect( |
| 147 | schemaTestDb.db.insert(schema.cloud_agent_user_settings).values({ kilo_user_id: userId }) |
| 148 | ).rejects.toMatchObject({ cause: { code: '23505' } }); |
| 149 | await expect( |
| 150 | schemaTestDb.db.execute(sql` |
| 151 | UPDATE cloud_agent_user_settings SET workspace_order = 'invalid' |
| 152 | WHERE kilo_user_id = ${userId} |
| 153 | `) |
| 154 | ).rejects.toMatchObject({ |