<?php

namespace App\Browser\Jobs\Parameters;

use App\Browser\BrowserJob;
use App\Models\JobArtifact;
use App\Models\JobRun;
use App\Notification\Notifications\SimpleNotification;
use App\Notification\Providers\AllNotification;
use Laravel\Dusk\Browser;

class ParametersJob extends BrowserJob
{

    public function __construct()
    {
        parent::__construct(1);
    }

    /**
     * @inheritDoc
     */
    public function run(Browser $browser): ?JobRun
    {
        return null;
    }

    /**
     * @inheritDoc
     */
    public function runTest(Browser $browser): ?JobRun
    {
        try {
            AllNotification::send(new SimpleNotification($this->jobId, "Test", "Test des notifications"));
            AllNotification::send(new SimpleNotification($this->jobId, "Test", "Test des notifications d'erreur", true));
            return $this->makeSimpleJobRun(true, "Envoi de notification réussi", "Datboi a réussi à envoyer des notifications");
        } catch (\Throwable $e) {
            return $this->makeSimpleJobRun(false, "Envoi de notification échoué", "Datboi n'a pas réussi à envoyer des notifications :\n" . $e->getMessage());
        }
    }
}
