@@ -1799,6 +1799,108 @@ export default () => {
17991799 } ) ;
18001800 } ) ;
18011801 }
1802+
1803+ describe ( 'Reporting no running release' , ( ) => {
1804+ beforeEach ( async function ( ) {
1805+ await fakeDevice . patchState (
1806+ device ,
1807+ device . uuid ,
1808+ {
1809+ [ stateKey ] :
1810+ stateVersion === 'v2'
1811+ ? {
1812+ is_on__commit : release2 . commit ,
1813+ }
1814+ : {
1815+ apps : {
1816+ [ applicationUuid ] : {
1817+ release_uuid : release2 . commit ,
1818+ } ,
1819+ } ,
1820+ } ,
1821+ } ,
1822+ stateVersion ,
1823+ ) ;
1824+
1825+ await expectResourceToMatch ( pineUser , 'device' , device . id , {
1826+ is_running__release : { __id : release2 . id } ,
1827+ } ) ;
1828+ } ) ;
1829+ } ) ;
1830+
1831+ it ( 'should clear the current release when the device reports a null commit' , async ( ) => {
1832+ await fakeDevice . patchState (
1833+ device ,
1834+ device . uuid ,
1835+ {
1836+ [ stateKey ] :
1837+ stateVersion === 'v2'
1838+ ? {
1839+ is_on__commit : null ,
1840+ }
1841+ : {
1842+ apps : {
1843+ [ applicationUuid ] : {
1844+ release_uuid : null ,
1845+ } ,
1846+ } ,
1847+ } ,
1848+ } ,
1849+ stateVersion ,
1850+ ) ;
1851+
1852+ await expectResourceToMatch ( pineUser , 'device' , device . id , {
1853+ is_running__release : null ,
1854+ } ) ;
1855+ } ) ;
1856+
1857+ if ( stateVersion === 'v3' ) {
1858+ it ( 'should clear the current release when the device reports the currnet app w/o a release_uuid' , async ( ) => {
1859+ await fakeDevice . patchState (
1860+ device ,
1861+ device . uuid ,
1862+ {
1863+ [ stateKey ] : {
1864+ apps : {
1865+ [ applicationUuid ] : {
1866+ // This will be the case when first installing a release of an app until
1867+ // the release is fully installed. Eg device move or if the SV database is deleted
1868+ // *** release_uuid not included ***,
1869+ releases : {
1870+ [ release2 . commit ] : {
1871+ update_status : 'downloading' ,
1872+ } ,
1873+ } ,
1874+ } ,
1875+ } ,
1876+ } ,
1877+ } ,
1878+ stateVersion ,
1879+ ) ;
1880+
1881+ await expectResourceToMatch ( pineUser , 'device' , device . id , {
1882+ is_running__release : null ,
1883+ } ) ;
1884+ } ) ;
1885+
1886+ it ( 'should clear the current release when the device reports an empty current apps state' , async ( ) => {
1887+ await fakeDevice . patchState (
1888+ device ,
1889+ device . uuid ,
1890+ // running no release
1891+ {
1892+ [ stateKey ] : {
1893+ apps : { } ,
1894+ } ,
1895+ } ,
1896+ stateVersion ,
1897+ ) ;
1898+
1899+ await expectResourceToMatch ( pineUser , 'device' , device . id , {
1900+ is_running__release : null ,
1901+ } ) ;
1902+ } ) ;
1903+ }
18021904 } ) ;
18031905 } ) ;
18041906 } ) ;
0 commit comments