@@ -22,6 +22,13 @@ describe('Device API', async function () {
2222 /**
2323 * Create a device
2424 * @param {Object } options - Options for creating a device
25+ * @param {string } options.name - The name of the device
26+ * @param {string } options.type - The type of the device
27+ * @param {string } options.team - The team hashid to create the device in
28+ * @param {string } options.as - The user session to create the device as
29+ * @param {string } [options.agentVersion] - The agent version to set on the device
30+ * @param {string } [options.application] - The application hashid to assign the device to
31+ * @param {string } [options.instance] - The instance hashid to assign the device to
2532 * @returns {Promise<Object> } - The device object
2633 */
2734 async function createDevice ( options ) {
@@ -2296,6 +2303,67 @@ describe('Device API', async function () {
22962303 body . editor . should . have . property ( 'nodeRedVersion' , 'next' )
22972304 } )
22982305 } )
2306+ describe ( 'Assistant Settings' , function ( ) {
2307+ // these tests are run with a clean app since they change the app config
2308+ beforeEach ( async function ( ) {
2309+ // Close down the default app
2310+ if ( app ) {
2311+ await app . close ( )
2312+ }
2313+ app = null
2314+ } )
2315+ after ( async function ( ) {
2316+ // Once all done, create the clean app for later tests
2317+ await app . close ( )
2318+ await setupApp ( )
2319+ } )
2320+
2321+ it ( 'device downloads settings with assistant disabled' , async function ( ) {
2322+ app = await setup ( {
2323+ assistant : {
2324+ enabled : false ,
2325+ mcp : { enabled : false } ,
2326+ completions : { enabled : false }
2327+ }
2328+ } )
2329+ await login ( 'alice' , 'aaPassword' )
2330+ const device = await createDevice ( { name : 'AppDevice1' , type : 'AppDevice1_type' , team : app . team . hashid , as : TestObjects . tokens . alice } )
2331+ const dbDevice = await app . db . models . Device . byId ( device . id )
2332+ dbDevice . setApplication ( app . application )
2333+ await dbDevice . save ( )
2334+
2335+ const body = await getLiveSettings ( device )
2336+ body . should . have . property ( 'assistant' ) . and . be . an . Object ( )
2337+ body . assistant . should . have . property ( 'enabled' , false )
2338+ body . assistant . should . have . property ( 'mcp' ) . and . be . an . Object ( )
2339+ body . assistant . mcp . should . have . property ( 'enabled' , false )
2340+ body . assistant . should . have . property ( 'completions' ) . and . be . an . Object ( )
2341+ body . assistant . completions . should . have . property ( 'enabled' , false )
2342+ } )
2343+ it ( 'device downloads settings including assistant completions settings when enabled' , async function ( ) {
2344+ app = await setup ( {
2345+ assistant : {
2346+ enabled : true ,
2347+ requestTimeout : 12345
2348+ // mcp deliberately excluded to check it defaults to enabled
2349+ // completions deliberately excluded to check it defaults to enabled
2350+ }
2351+ } )
2352+ await login ( 'alice' , 'aaPassword' )
2353+ const device = await createDevice ( { name : 'AppDevice2' , type : 'AppDevice2_type' , team : app . team . hashid , as : TestObjects . tokens . alice } )
2354+ const dbDevice = await app . db . models . Device . byId ( device . id )
2355+ dbDevice . setApplication ( app . application )
2356+ await dbDevice . save ( )
2357+
2358+ const body = await getLiveSettings ( device )
2359+ body . should . have . property ( 'assistant' ) . and . be . an . Object ( )
2360+ body . assistant . should . have . property ( 'enabled' , true )
2361+ body . assistant . should . have . property ( 'mcp' ) . and . be . an . Object ( )
2362+ body . assistant . mcp . should . have . property ( 'enabled' , true ) // defaults to enabled
2363+ body . assistant . should . have . property ( 'completions' ) . and . be . an . Object ( )
2364+ body . assistant . completions . should . have . property ( 'enabled' , true ) // defaults to enabled
2365+ } )
2366+ } )
22992367
23002368 describe ( 'Device state' , function ( ) {
23012369 async function setupProjectWithSnapshot ( setActive ) {
0 commit comments