5 class PwaManifestTest extends TestCase
7 public function test_manifest_access_and_format()
9 $this->setSettings(['app-color' => '#00ACED']);
11 $resp = $this->get('/manifest.json');
15 'name' => setting('app-name'),
17 'client_mode' => 'focus-existing'
19 'theme_color' => '#00ACED',
23 public function test_pwa_meta_tags_in_head()
25 $html = $this->asViewer()->withHtml($this->get('/'));
27 // crossorigin attribute is required to send cookies with the manifest,
28 // so it can react correctly to user preferences (dark/light mode).
29 $html->assertElementExists('head link[rel="manifest"][href$="manifest.json"][crossorigin="use-credentials"]');
30 $html->assertElementExists('head meta[name="mobile-web-app-capable"][content="yes"]');
33 public function test_manifest_uses_configured_icons_if_existing()
35 $resp = $this->get('/manifest.json');
38 "src" => 'http://localhost/icon-32.png',
44 $galleryFile = $this->files->uploadedImage('my-app-icon.png');
45 $this->asAdmin()->call('POST', '/settings/customization', [], [], ['app_icon' => $galleryFile], []);
47 $customIconUrl = setting()->get('app-icon-32');
48 $this->assertStringContainsString('my-app-icon', $customIconUrl);
50 $resp = $this->get('/manifest.json');
53 "src" => $customIconUrl,
60 public function test_manifest_changes_to_user_preferences()
62 $lightUser = $this->users->viewer();
63 $darkUser = $this->users->editor();
64 setting()->putUser($darkUser, 'dark-mode-enabled', 'true');
66 $resp = $this->actingAs($lightUser)->get('/manifest.json');
67 $resp->assertJson(['background_color' => '#F2F2F2']);
69 $resp = $this->actingAs($darkUser)->get('/manifest.json');
70 $resp->assertJson(['background_color' => '#111111']);