feat(mobile): add Android development client and scoped IDE companion
This commit is contained in:
1 parent
3332458708
commit
9f9f3226a1
84 files changed
+4371
-4
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { app, safeStorage } from 'electron'
|
||||
import { mkdtemp, readFile, writeFile } from 'node:fs/promises'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { resolve, join } from 'node:path'
|
||||
import assert from 'node:assert/strict'
|
||||
import { createMobileWindow } from '../../desktop/electron/mobile-host.mjs'
|
||||
import { MobileVault } from '../../desktop/electron/mobile-secrets.mjs'
|
||||
const directory = await mkdtemp(join(tmpdir(), 'aiturk-mobile-electron-'))
|
||||
app.setPath('userData', join(directory, 'electron-profile'))
|
||||
void app.whenReady().then(async () => {
|
||||
let window
|
||||
try {
|
||||
assert.ok(safeStorage.isEncryptionAvailable(), 'Windows encryption unavailable')
|
||||
window = createMobileWindow({ directory, assets: resolve('apps/desktop/dist'), show: false,
|
||||
resolveBackend: async () => { throw new Error('No live backend in vault smoke test') } })
|
||||
await new Promise(resolve => window.webContents.once('did-finish-load', resolve))
|
||||
const result = await window.webContents.executeJavaScript(`(async () => {
|
||||
const before = await mobileHost.call('setup');
|
||||
await mobileHost.call('account.save', {token:'local-fake-account-for-encryption-test'});
|
||||
const after = await mobileHost.call('setup');
|
||||
return {before,after,heading:document.querySelector('h1').textContent};
|
||||
})()`)
|
||||
assert.equal(result.before.hasAccount, false); assert.equal(result.after.hasAccount, true)
|
||||
const blob = await readFile(join(directory, 'mobile', 'mobile-secrets.bin'))
|
||||
assert.ok(!blob.includes(Buffer.from('local-fake-account-for-encryption-test')))
|
||||
const vault = new MobileVault(join(directory, 'mobile'), safeStorage)
|
||||
assert.equal((await vault.load()).accountToken, 'local-fake-account-for-encryption-test')
|
||||
await vault.save({})
|
||||
const receipt = { realElectronIpc: 'passed', windowsSafeStorage: 'passed', heading: result.heading, checkedAt: new Date().toISOString() }
|
||||
await writeFile('apps/mobile/test-results/electron-smoke.json', JSON.stringify(receipt))
|
||||
console.log(JSON.stringify(receipt))
|
||||
window.destroy(); app.exit(0)
|
||||
} catch (error) { console.error(error); window?.destroy(); app.exit(1) }
|
||||
})
|
||||
Reference in new issue
Block a user