7 class PwaManifestTest extends TestCase
9 public function test_manifest_access_and_format()
11 $this->setSettings(['app-color' => '#00ACED']);
13 $resp = $this->get('/manifest.json');
17 'name' => setting('app-name'),
19 'client_mode' => 'focus-existing'
21 'theme_color' => '#00ACED',
25 public function test_pwa_meta_tags_in_head()
27 $html = $this->asViewer()->withHtml($this->get('/'));
29 $html->assertElementExists('head link[rel="manifest"][href$="manifest.json"]');
30 $html->assertElementExists('head meta[name="mobile-web-app-capable"][content="yes"]');
33 public function test_manifest_uses_configured_icons_if_existing()
35 $this->beforeApplicationDestroyed(fn() => $this->files->resetAppFavicon());
37 $resp = $this->get('/manifest.json');
40 "src" => 'http://localhost/icon-32.png',
46 $galleryFile = $this->files->uploadedImage('my-app-icon.png');
47 $this->asAdmin()->call('POST', '/settings/customization', [], [], ['app_icon' => $galleryFile], []);
49 $customIconUrl = setting()->get('app-icon-32');
50 $this->assertStringContainsString('my-app-icon', $customIconUrl);
52 $resp = $this->get('/manifest.json');
55 "src" => $customIconUrl,
62 public function test_manifest_changes_to_user_preferences()
64 $lightUser = $this->users->viewer();
65 $darkUser = $this->users->editor();
66 setting()->putUser($darkUser, 'dark-mode-enabled', 'true');
68 $resp = $this->actingAs($lightUser)->get('/manifest.json');
69 $resp->assertJson(['background_color' => '#F2F2F2']);
71 $resp = $this->actingAs($darkUser)->get('/manifest.json');
72 $resp->assertJson(['background_color' => '#111111']);