Files
fotospiel-app/resources/js/admin/mobile/lib/installPrompt.test.ts
Codex Agent d5f038d098 Added onboarding + a lightweight install banner to both the mobile login screen and the settings screen, with Android/Chromium
install prompt support and iOS “Share → Add to Home Screen” guidance. Also added a small helper + tests to decide
  when/which banner variant should show, and shared copy in common.json.
2025-12-28 18:26:17 +01:00

28 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { isIosDevice, resolveStandaloneDisplayMode } from './installPrompt';
describe('isIosDevice', () => {
it('detects iOS user agents', () => {
expect(isIosDevice('Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1')).toBe(true);
expect(isIosDevice('Mozilla/5.0 (iPad; CPU OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1')).toBe(true);
});
it('returns false for non-iOS user agents', () => {
expect(isIosDevice('Mozilla/5.0 (Linux; Android 14; Pixel 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36')).toBe(false);
});
});
describe('resolveStandaloneDisplayMode', () => {
it('returns true when matchMedia says standalone', () => {
expect(resolveStandaloneDisplayMode(true, false)).toBe(true);
});
it('returns true when navigator.standalone is true', () => {
expect(resolveStandaloneDisplayMode(false, true)).toBe(true);
});
it('returns false when both are false', () => {
expect(resolveStandaloneDisplayMode(false, false)).toBe(false);
});
});