In-App-Update (!40) nachgeschaerft: Zeile nur mit APK-Asset, keine Installation ohne Pruefsumme, ein Release-Check pro App-Sitzung

This commit is contained in:
Duarte Santos committed 2026-09-05 14:27:28 +02:00
1 parent f7b664bcda
commit 067302fd16
17 files changed
+31 -8

No files matched your search

+2 -2
View File
@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(626)
expect(inherited).toHaveLength(612)
expect(inherited).toHaveLength(613)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d0483d2d3a56ac55054229234fe54481e2b5c539b5836bbdc9305230cb8dd475')
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('81d277306b3029090b7a2ba6cc19108ca207ea65d738487155123260b6e9525d')
})
test('does not leak European Portuguese UI terms', () => {
+8
View File
@@ -33,7 +33,15 @@ function compareSemver(a, b) {
* - apkUrl: direct download URL of the first .apk asset, or null
* - hashUrl: direct download URL of the .apk.sha256 hash file, or null
*/
// One request per app session: Settings is opened often, gitlab.com does not need to hear
// about it every time. The promise is cached, a failure is not.
let cached = null
export function resetUpdateCheck() { cached = null }
export async function checkForUpdate() {
if (!cached) cached = fetchLatest().catch(e => { cached = null; throw e })
return cached
}
async function fetchLatest() {
const res = await fetch(RELEASES_URL + '?per_page=1')
if (!res.ok) throw new Error(`GitLab API ${res.status}`)
const releases = await res.json()
+3 -3
View File
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { checkForUpdate, sha256 } from './update.js'
import { checkForUpdate, sha256, resetUpdateCheck } from './update.js'
// __APP_VERSION__ is defined at build time by vite.config.js (reads package.json).
// In the test environment vitest applies the same define, so it's available here.
@@ -28,7 +28,7 @@ describe('sha256', () => {
describe('checkForUpdate', () => {
let originalFetch
beforeEach(() => { originalFetch = globalThis.fetch })
beforeEach(() => { originalFetch = globalThis.fetch; resetUpdateCheck() })
afterEach(() => { globalThis.fetch = originalFetch })
function mockFetch(body, status = 200) {
@@ -231,7 +231,7 @@ describe('checkForUpdate', () => {
describe('semver comparison (via checkForUpdate behavior)', () => {
let originalFetch
beforeEach(() => { originalFetch = globalThis.fetch })
beforeEach(() => { originalFetch = globalThis.fetch; resetUpdateCheck() })
afterEach(() => { globalThis.fetch = originalFetch })
function mockRelease(tag) {