EV3-414 Verzióváltott teszt - Külső user készlet módosítás

This commit is contained in:
E98Developer 2026-05-07 03:02:06 +02:00
parent 4e4c7ebb40
commit de1eb871b9
7 changed files with 36 additions and 21 deletions

View File

@ -40,21 +40,21 @@ public function Producer(): BelongsTo
public function Price(?string $deliveryDate = null)
{
$price = $this->belongsToMany(PriceList::class, 'price_list_prices', 'product_id', 'price_list_id')->select('id')
$query = $this->belongsToMany(PriceList::class, 'price_list_prices', 'product_id', 'price_list_id')->select('id')
// ->withTimestamps()
->withPivot(['price']);
if (! $deliveryDate) {
$deliveryDate = Carbon::today()->format('Y-m-d');
}
$price->where('available', '<=', $deliveryDate);
$price->orderBy('available', 'desc')->orderBy('id', 'asc');
$price->first();
if ($price = $price->get()->toArray()) {
$price = $price[0]['pivot']['price'];
$query->where('available', '<=', $deliveryDate);
$query->orderBy('available', 'desc')->orderBy('id', 'asc');
if ($priceRecord = $query->first()) {
return $priceRecord->pivot->price;
}
return $price;
return null;
}
public function setAttributePrice(?string $deliveryDate = null)

View File

@ -31,7 +31,7 @@ class AppServiceProvider extends ServiceProvider
public function register(): void
{
if ($this->app->environment('local', 'testing')) {
if ($this->app->environment('local')) {
$this->app->register(\Laravel\Dusk\DuskServiceProvider::class);
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"/js/app.js": "/js/app.js?id=bfd5b3c87b1ce7a5f3cf9f87cfc03bc6",
"/js/app.js": "/js/app.js?id=788435874adbbf8e5ddc27cc9d18e00e",
"/js/admin.js": "/js/admin.js?id=ba79095db4031ff8fcb2db67804629a7",
"/js/module.js": "/js/module.js?id=5ce18ae01fbbb5024dd3040821c906f2",
"/js/module.js": "/js/module.js?id=9c0dac011c39d558ee1b3f201202a8a4",
"/js/components.js": "/js/components.js?id=34668cee8ac371c98657beffcff579b8",
"/css/app.css": "/css/app.css?id=883a2d68194f1a6064f55eaedb17e768",
"/fonts/vendor/bootstrap-icons/bootstrap-icons.woff2?92ea18a81d737146ff044ddb52010366": "/fonts/vendor/bootstrap-icons/bootstrap-icons.woff2?92ea18a81d737146ff044ddb52010366?id=9ad5aa740d7d5e6a0191b309b9b1986c",

View File

@ -202,6 +202,15 @@ window.ajaxErrorHandler= function (xhr, ajaxOptions, thrownError){
console.error(ajaxOptions);
console.error(thrownError);
// Biztonsági ellenőrzés ha nincs responseJSON (pl. HTML válasz), megpróbáljuk parszolni
if (!xhr.responseJSON && xhr.responseText) {
try {
xhr.responseJSON = JSON.parse(xhr.responseText);
} catch (e) {
console.error("Nem sikerült a responseText JSON parszolása");
}
}
// Biztonsági ellenőrzés ha nincs responseJSON (pl. HTML válasz)
if (!xhr.responseJSON) {
ajaxErrorFieldHandler({'detail': 'Váratlan szerverhiba. Kérjük próbálja újra később.'});

View File

@ -12,18 +12,24 @@ protected function setUp(): void
$this->refreshApplication();
}
// Kényszerítsük a teszt adatbázist, ha valamiért nem az lenne (pl. cache-elt config)
// Használjuk az env() függvényt, mert a config() a cache miatt csalhat
if (env('APP_ENV') === 'testing') {
config(['database.connections.mysql.database' => 'd2dTest']);
}
$currentDb = config('database.connections.mysql.database');
$currentEnv = env('APP_ENV');
// Szigorú ellenőrzés a d2d (élő/helyi) adatbázis ellen
if (strtolower($currentDb) === 'd2d' && $currentEnv === 'testing') {
throw new \Exception('STOP!!! KRITIKUS HIBA: A tesztek az ÉLŐ (d2d) adatbázison akarnak futni! A folyamat leállítva a RefreshDatabase lefutása előtt. Kérlek futtasd a "php artisan config:clear" parancsot!');
// SZIGORÚ ELLENŐRZÉS: A 'd2d' adatbázist SOHA nem szabad teszthez használni!
// Akkor is védünk, ha a config cache-elve van vagy az APP_ENV nem 'testing'.
if (strtolower($currentDb) === 'd2d') {
echo "\n\n!!! KRITIKUS BIZTONSÁGI HIBA !!!\n";
echo "A tesztek az ÉLŐ (d2d) adatbázishoz kapcsolódnak!\n";
echo "Ez az adatbázis törléséhez (RefreshDatabase) vezetne.\n";
echo "A folyamat azonnal leállítva a biztonság érdekében.\n";
echo "Megoldás: Futtasd a 'php artisan config:clear' parancsot és ellenőrizd a .env.testing fájlt!\n\n";
exit(1);
}
// Kényszerítsük a teszt adatbázist, ha testing környezetben vagyunk és nem d2d
if ($currentEnv === 'testing' && strtolower($currentDb) !== 'd2dtest') {
config(['database.connections.mysql.database' => 'd2dTest']);
$currentDb = 'd2dTest';
}
// Általános ellenőrzés, hogy a teszt adatbázis legyen használva