Skip to content

Commit 0107798

Browse files
authored
Merge pull request #132 from iMattPro/fixes
2 parents 5774c73 + 06ad184 commit 0107798

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

styles/all/template/webpush.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ function PhpbbWebpush() {
541541
})
542542
.catch(error => {
543543
loadingIndicator.fadeOut(phpbb.alertTime);
544-
phpbb.alert(ajaxErrorTitle, error);
544+
phpbb.alert(ajaxErrorTitle, error.message || error);
545545
});
546546
}
547547

tests/controller/controller_webpush_test.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,46 @@ public function test_subscribe_invalid_endpoint(string $endpoint): void
547547
$this->controller->subscribe($symfony_request);
548548
}
549549

550+
public function data_subscribe_missing_endpoint(): array
551+
{
552+
return [
553+
'missing_endpoint' => [[
554+
'expiration_time' => 0,
555+
'keys' => ['p256dh' => 'test_p256dh', 'auth' => 'test_auth'],
556+
]],
557+
'null_endpoint' => [[
558+
'endpoint' => null,
559+
'expiration_time' => 0,
560+
'keys' => ['p256dh' => 'test_p256dh', 'auth' => 'test_auth'],
561+
]],
562+
'array_endpoint' => [[
563+
'endpoint' => ['https://fcm.googleapis.com/fcm/send/test_endpoint'],
564+
'expiration_time' => 0,
565+
'keys' => ['p256dh' => 'test_p256dh', 'auth' => 'test_auth'],
566+
]],
567+
];
568+
}
569+
570+
/**
571+
* @dataProvider data_subscribe_missing_endpoint
572+
*/
573+
public function test_subscribe_missing_endpoint(array $payload): void
574+
{
575+
$this->form_helper->method('check_form_tokens')->willReturn(true);
576+
$this->request->method('is_ajax')->willReturn(true);
577+
$this->user->data['user_id'] = 2;
578+
$this->user->data['is_bot'] = false;
579+
$this->user->data['user_type'] = USER_NORMAL;
580+
581+
$symfony_request = $this->createMock(\phpbb\symfony_request::class);
582+
$symfony_request->method('get')->willReturn(json_encode($payload));
583+
584+
$this->expectException(http_exception::class);
585+
$this->expectExceptionMessage('WEBPUSH_INVALID_ENDPOINT');
586+
587+
$this->controller->subscribe($symfony_request);
588+
}
589+
550590
public function data_is_valid_endpoint(): array
551591
{
552592
return [

0 commit comments

Comments
 (0)