mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Tests: Fix Dusk tests after 13626 (#15057)
This commit is contained in:
@@ -32,24 +32,20 @@ class TimezoneController extends Controller
|
||||
{
|
||||
public function set(Request $request): string
|
||||
{
|
||||
session([
|
||||
'timezone_static' => $request->boolean('static'),
|
||||
]);
|
||||
$request->session()->put('preferences.timezone_static', $request->boolean('static'));
|
||||
|
||||
// laravel session
|
||||
if ($request->timezone) {
|
||||
// Only accept valid timezones
|
||||
if (! in_array($request->timezone, timezone_identifiers_list())) {
|
||||
return session('timezone');
|
||||
return session('preferences.timezone');
|
||||
}
|
||||
|
||||
session([
|
||||
'timezone' => $request->timezone,
|
||||
]);
|
||||
$request->session()->put('preferences.timezone', $request->timezone);
|
||||
|
||||
return $request->timezone;
|
||||
}
|
||||
|
||||
return session('timezone');
|
||||
return session('preferences.timezone');
|
||||
}
|
||||
}
|
||||
|
@@ -58,8 +58,8 @@ class LatencyController implements DeviceTab
|
||||
|
||||
public function data(Device $device): array
|
||||
{
|
||||
$from = Request::get('dtpickerfrom', Carbon::now(session('timezone'))->subDays(2)->format(Config::get('dateformat.byminute')));
|
||||
$to = Request::get('dtpickerto', Carbon::now(session('timezone'))->format(Config::get('dateformat.byminute')));
|
||||
$from = Request::get('dtpickerfrom', Carbon::now(session('preferences.timezone'))->subDays(2)->format(Config::get('dateformat.byminute')));
|
||||
$to = Request::get('dtpickerto', Carbon::now(session('preferences.timezone'))->format(Config::get('dateformat.byminute')));
|
||||
|
||||
$dbfrom = Carbon::createFromFormat(Config::get('dateformat.byminute'), $from)->setTimezone(date_default_timezone_get())->format(Config::get('dateformat.byminute'));
|
||||
$dbto = Carbon::createFromFormat(Config::get('dateformat.byminute'), $to)->setTimezone(date_default_timezone_get())->format(Config::get('dateformat.byminute'));
|
||||
@@ -94,7 +94,7 @@ class LatencyController implements DeviceTab
|
||||
return DB::table('device_perf')
|
||||
->where('device_id', $device->device_id)
|
||||
->whereBetween('timestamp', [$from, $to])
|
||||
->selectRaw("DATE_FORMAT(IFNULL(CONVERT_TZ(timestamp, @@global.time_zone, ?), timestamp), '%Y-%m-%d %H:%i') date,xmt,rcv,loss,min,max,avg", [session('timezone')])
|
||||
->selectRaw("DATE_FORMAT(IFNULL(CONVERT_TZ(timestamp, @@global.time_zone, ?), timestamp), '%Y-%m-%d %H:%i') date,xmt,rcv,loss,min,max,avg", [session('preferences.timezone')])
|
||||
->get();
|
||||
}
|
||||
|
||||
|
@@ -117,7 +117,7 @@ class EventlogController extends TableController
|
||||
$output = "<span class='alert-status ";
|
||||
$output .= $this->severityLabel($eventlog->severity);
|
||||
$output .= " eventlog-status'></span><span style='display:inline;'>";
|
||||
$output .= (new Carbon($eventlog->datetime))->setTimezone(session('timezone'))->format(Config::get('dateformat.compact'));
|
||||
$output .= (new Carbon($eventlog->datetime))->setTimezone(session('preferences.timezone'))->format(Config::get('dateformat.compact'));
|
||||
$output .= '</span>';
|
||||
|
||||
return $output;
|
||||
|
@@ -64,10 +64,10 @@ class OutagesController extends TableController
|
||||
return DeviceOutage::hasAccess($request->user())
|
||||
->with('device')
|
||||
->when($request->from, function ($query) use ($request) {
|
||||
$query->where('going_down', '>=', Carbon::parse($request->from, session('timezone'))->getTimestamp());
|
||||
$query->where('going_down', '>=', Carbon::parse($request->from, session('preferences.timezone'))->getTimestamp());
|
||||
})
|
||||
->when($request->to, function ($query) use ($request) {
|
||||
$query->where('going_down', '<=', Carbon::parse($request->to, session('timezone'))->getTimestamp());
|
||||
$query->where('going_down', '<=', Carbon::parse($request->to, session('preferences.timezone'))->getTimestamp());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ class OutagesController extends TableController
|
||||
}
|
||||
|
||||
$output = "<span style='display:inline;'>";
|
||||
$output .= Carbon::createFromTimestamp($timestamp, session('timezone'))->format(Config::get('dateformat.compact')); // Convert epoch to local time
|
||||
$output .= Carbon::createFromTimestamp($timestamp, session('preferences.timezone'))->format(Config::get('dateformat.compact')); // Convert epoch to local time
|
||||
$output .= '</span>';
|
||||
|
||||
return $output;
|
||||
|
@@ -39,7 +39,7 @@ use Session;
|
||||
|
||||
class UserPreferencesController extends Controller
|
||||
{
|
||||
private $cachedPreferences = ['locale', 'site_style'];
|
||||
private $cachedPreferences = ['locale', 'site_style', 'timezone'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ class LoadUserPreferences
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$preferences = ['locale', 'site_style'];
|
||||
$preferences = ['locale', 'site_style', 'timezone'];
|
||||
$this->loadPreferences($request, $preferences);
|
||||
|
||||
$this->setPreference($request, 'locale', function ($locale) {
|
||||
@@ -27,6 +27,10 @@ class LoadUserPreferences
|
||||
Config::set('applied_site_style', $style);
|
||||
});
|
||||
|
||||
$this->setPreference($request, 'timezone', function ($timezone) use ($request) {
|
||||
$request->session()->put('preferences.timezone_static', true);
|
||||
});
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,6 @@
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Models\UserPref;
|
||||
use DB;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Illuminate\Contracts\Auth\UserProvider;
|
||||
@@ -131,13 +130,6 @@ class LegacyUserProvider implements UserProvider
|
||||
throw new AuthenticationException();
|
||||
}
|
||||
|
||||
if ($tz = UserPref::getPref($user, 'timezone')) {
|
||||
session([
|
||||
'timezone' => $tz,
|
||||
'timezone_static' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (AuthenticationException $ae) {
|
||||
$auth_message = $ae->getMessage();
|
||||
|
@@ -35,8 +35,8 @@ $noagg = ! $graph_params->visible('aggregate');
|
||||
$rrd_options = '';
|
||||
$env = [];
|
||||
|
||||
if (session('timezone')) {
|
||||
$env['TZ'] = session('timezone');
|
||||
if (session('preferences.timezone')) {
|
||||
$env['TZ'] = session('preferences.timezone');
|
||||
}
|
||||
|
||||
require Config::get('install_dir') . "/includes/html/graphs/$type/auth.inc.php";
|
||||
|
@@ -78,7 +78,7 @@ $pagetitle[] = 'Outages';
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
},
|
||||
defaultDate: '<?php echo Carbon::now(session('timezone'))->subMonth()->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>'
|
||||
defaultDate: '<?php echo Carbon::now(session('preferences.timezone'))->subMonth()->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>'
|
||||
});
|
||||
$("#dtpickerfrom").on("dp.change", function (e) {
|
||||
$("#dtpickerto").data("DateTimePicker").minDate(e.date);
|
||||
@@ -95,7 +95,7 @@ $pagetitle[] = 'Outages';
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
},
|
||||
defaultDate: '<?php echo Carbon::now(session('timezone'))->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>'
|
||||
defaultDate: '<?php echo Carbon::now(session('preferences.timezone'))->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>'
|
||||
});
|
||||
$("#dtpickerto").on("dp.change", function (e) {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate(e.date);
|
||||
@@ -106,7 +106,7 @@ $pagetitle[] = 'Outages';
|
||||
if ($("#dtpickerto").val() != "") {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val());
|
||||
} else {
|
||||
$("#dtpickerto").data("DateTimePicker").maxDate('<?php echo Carbon::now(session('timezone'))->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>');
|
||||
$("#dtpickerto").data("DateTimePicker").maxDate('<?php echo Carbon::now(session('preferences.timezone'))->format(Config::get('dateformat.byminute', 'Y-m-d H:i')); ?>');
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -82,9 +82,9 @@ if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
if (session('timezone')) {
|
||||
if (session('preferences.timezone')) {
|
||||
$sql = "SELECT R.severity, D.device_id,name AS alert,rule_id,state,time_logged,DATE_FORMAT(IFNULL(CONVERT_TZ(time_logged, @@global.time_zone, ?),time_logged), '" . \LibreNMS\Config::get('dateformat.mysql.compact') . "') as humandate,details $sql";
|
||||
$param = array_merge([session('timezone')], $param);
|
||||
$param = array_merge([session('preferences.timezone')], $param);
|
||||
} else {
|
||||
$sql = "SELECT R.severity, D.device_id,name AS alert,rule_id,state,time_logged,DATE_FORMAT(time_logged, '" . \LibreNMS\Config::get('dateformat.mysql.compact') . "') as humandate,details $sql";
|
||||
}
|
||||
|
@@ -113,9 +113,9 @@ if ($rowCount != -1) {
|
||||
$sql .= " LIMIT $limit_low,$limit_high";
|
||||
}
|
||||
|
||||
if (session('timezone')) {
|
||||
if (session('preferences.timezone')) {
|
||||
$sql = "SELECT `alerts`.*, IFNULL(CONVERT_TZ(`alerts`.`timestamp`, @@global.time_zone, ?),`alerts`.`timestamp`) AS timestamp_display, `devices`.`hostname`, `devices`.`sysName`, `devices`.`display`, `devices`.`os`, `devices`.`hardware`, `locations`.`location`, `alert_rules`.`rule`, `alert_rules`.`name`, `alert_rules`.`severity` $sql";
|
||||
$param = array_merge([session('timezone')], $param);
|
||||
$param = array_merge([session('preferences.timezone')], $param);
|
||||
} else {
|
||||
$sql = "SELECT `alerts`.*, `alerts`.`timestamp` AS timestamp_display, `devices`.`hostname`, `devices`.`sysName`, `devices`.`display`, `devices`.`os`, `devices`.`hardware`, `locations`.`location`, `alert_rules`.`rule`, `alert_rules`.`name`, `alert_rules`.`severity` $sql";
|
||||
}
|
||||
|
@@ -354,8 +354,3 @@ parameters:
|
||||
message: "#^Parameter \\#1 \\$new_location of method App\\\\Models\\\\Device\\:\\:setLocation\\(\\) expects App\\\\Models\\\\Location\\|string, null given\\.$#"
|
||||
count: 1
|
||||
path: tests/Unit/LocationTest.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$user of static method App\\\\Models\\\\UserPref\\:\\:getPref\\(\\) expects App\\\\Models\\\\User, Illuminate\\\\Contracts\\\\Auth\\\\Authenticatable given\\.$#"
|
||||
count: 1
|
||||
path: app/Providers/LegacyUserProvider.php
|
||||
|
@@ -89,17 +89,15 @@
|
||||
document.documentElement.classList.remove('tw-dark')
|
||||
}
|
||||
</script>
|
||||
@if(session('timezone_static') == null || ! session('timezone_static'))
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
@auth
|
||||
@if(session('preferences.timezone_static') == null || ! session('preferences.timezone_static'))
|
||||
<script>
|
||||
var tz = window.Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
if(tz !== '{{ session('timezone') }}') {
|
||||
if(tz !== '{{ session('preferences.timezone') }}') {
|
||||
updateTimezone(tz, false);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endif
|
||||
@auth
|
||||
</script>
|
||||
@endif
|
||||
<script src="{{ asset('js/register-service-worker.js') }}" defer></script>
|
||||
@endauth
|
||||
@yield('javascript')
|
||||
|
5
tests/Browser/source/.gitignore
vendored
Normal file
5
tests/Browser/source/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
|
Reference in New Issue
Block a user