Add page visit Telegram notifications
Some checks failed
Tests / Laravel tests (pull_request) Failing after 6m57s
Some checks failed
Tests / Laravel tests (pull_request) Failing after 6m57s
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\NotifyTelegramAboutContactMessage;
|
||||
use App\Jobs\NotifyTelegramAboutPageVisit;
|
||||
use App\Jobs\NotifyTelegramAboutPersonaliaClick;
|
||||
use App\Models\Education;
|
||||
use App\Models\Personalia;
|
||||
@@ -99,3 +100,55 @@ test('a contact message requires a name and message', function () {
|
||||
|
||||
Queue::assertNotPushed(NotifyTelegramAboutContactMessage::class);
|
||||
});
|
||||
|
||||
test('a page visit can be submitted and is queued for notification', function () {
|
||||
Queue::fake();
|
||||
|
||||
$this->withHeaders([
|
||||
'User-Agent' => 'Pest Browser',
|
||||
'Accept-Language' => 'nl-NL,nl;q=0.9',
|
||||
])->postJson(route('page-visits.store'), [
|
||||
'visitor_id' => 'visitor-123',
|
||||
'url' => 'https://cv.robert.ooo/',
|
||||
'path' => '/',
|
||||
'title' => 'CV Roberto',
|
||||
'referrer' => 'https://example.com',
|
||||
'language' => 'nl-NL',
|
||||
'timezone' => 'Europe/Amsterdam',
|
||||
'screen' => [
|
||||
'width' => 1920,
|
||||
'height' => 1080,
|
||||
],
|
||||
'viewport' => [
|
||||
'width' => 1440,
|
||||
'height' => 900,
|
||||
],
|
||||
'device_pixel_ratio' => 1,
|
||||
'color_depth' => 24,
|
||||
'platform' => 'Linux x86_64',
|
||||
'vendor' => 'Google Inc.',
|
||||
'hardware_concurrency' => 8,
|
||||
'device_memory' => 8,
|
||||
'cookies_enabled' => true,
|
||||
'online' => true,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJson([
|
||||
'status' => 'queued',
|
||||
]);
|
||||
|
||||
Queue::assertPushed(NotifyTelegramAboutPageVisit::class);
|
||||
});
|
||||
|
||||
test('a page visit requires a visitor id and valid url', function () {
|
||||
Queue::fake();
|
||||
|
||||
$this->postJson(route('page-visits.store'), [
|
||||
'visitor_id' => '',
|
||||
'url' => 'not-a-url',
|
||||
])
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors(['visitor_id', 'url']);
|
||||
|
||||
Queue::assertNotPushed(NotifyTelegramAboutPageVisit::class);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user