feat(sandbox): default Network Sandbox to off and add settings toggle switch (#304)

This commit is contained in:
Yiling-J
2026-08-13 20:50:34 +08:00
committed by GitHub
parent 7f185ca23c
commit 9d50301a43
28 changed files with 372 additions and 39 deletions
+7 -2
View File
@@ -296,31 +296,36 @@ describe('TeamService', () => {
name: 'Settings Team',
})
// Should have default settings
// Should have default settings (networkSandboxEnabled is false by default for new teams)
const settings = await teamService.getSandboxSettings(team.id)
expect(settings.networkSandboxEnabled).toBe(false)
expect(settings.allowedDomains).toContain('github.com')
expect(settings.pendingDomains).toEqual([])
// Should update settings
const updated = await teamService.updateSandboxSettings(team.id, {
networkSandboxEnabled: true,
allowedDomains: ['example.com'],
pendingDomains: ['pending.com'],
})
expect(updated.networkSandboxEnabled).toBe(true)
expect(updated.allowedDomains).toEqual(['example.com'])
expect(updated.pendingDomains).toEqual(['pending.com'])
// Should persist to DB
const persisted = await teamService.getSandboxSettings(team.id)
expect(persisted.networkSandboxEnabled).toBe(true)
expect(persisted.allowedDomains).toEqual(['example.com'])
expect(persisted.pendingDomains).toEqual(['pending.com'])
})
it('should return empty allowedDomains if sandbox is missing for old team', async () => {
it('should return default settings if sandbox is missing for old team', async () => {
const team = await prisma.team.create({
data: { name: 'Old Team' },
})
const settings = await teamService.getSandboxSettings(team.id)
expect(settings.networkSandboxEnabled).toBe(false)
expect(settings.allowedDomains).toEqual([])
expect(settings.pendingDomains).toEqual([])
})