extractSerials($noteSingle); expect($serialsSingle)->toEqual(['8CG9454YMN']); $info = $service->extractProductInfo($noteSingle, 'AOB+I59600G5TSNBSWSW-R16'); expect($info['brand'])->toBe('HP') ->and($info['sku'])->toBe('AOB+I59600G5TSNBSWSW-R16') ->and($info['title'])->toContain('HP PROONE 600 G5'); $noteMulti = "ULTRABOOK TABLET PC 2 IN 1 PORTATILI // NOTEBOOK RICONDIZIONATO DELL LATITUDE 7200 2 IN 1 TOUCHSCREEN 12\" CORE I5-8365U RAM 16GB SSD 512GB WINDOWS 11 PRO GRADO B+ S/N: 5JRH633 , 6VCH633 ,"; $serialsMulti = $service->extractSerials($noteMulti); expect($serialsMulti)->toEqual(['5JRH633', '6VCH633']); }); test('seriali catalogo page mounts with default nethome supplier and filters imported serials', function () { $user = User::factory()->create(); $user->assignRole('super-admin'); Auth::login($user); $ncom = Fornitore::query()->where('partita_iva', '14001151001')->first(); if (! $ncom) { $ncom = Fornitore::query()->create([ 'partita_iva' => '14001151001', 'ragione_sociale' => 'NCOM SRL', 'codice_univoco' => 'NCOMSRL', 'amministratore_id' => 13, ]); } $nethome = Fornitore::query()->where('partita_iva', '10055221005')->first(); if (! $nethome) { $nethome = Fornitore::query()->create([ 'partita_iva' => '10055221005', 'ragione_sociale' => 'NETHOME sas di BARONE M. & C.', 'codice_univoco' => 'NETHOME', 'amministratore_id' => 13, 'operational_config'=> [ 'merged_supplier_ids' => [(int) $ncom->id], ], ]); } else { $cfg = (array) ($nethome->operational_config ?? []); $cfg['merged_supplier_ids'] = array_values(array_unique(array_merge((array) data_get($cfg, 'merged_supplier_ids', []), [(int) $ncom->id]))); $nethome->operational_config = $cfg; $nethome->save(); } $serial = ProductSerial::query()->where('serial_number', '8CG9454YMN')->first(); if (! $serial) { $product = Product::query()->firstOrCreate([ 'canonical_key' => 'hp-proone-600-g5-test', ], [ 'name' => 'HP ProOne 600 G5 Touchscreen', 'default_fornitore_id' => $ncom->id, 'brand' => 'HP', 'model' => 'PROONE 600 G5', ]); $serial = ProductSerial::query()->create([ 'fornitore_id' => (int) $ncom->id, 'product_id' => (int) $product->id, 'serial_number' => '8CG9454YMN', 'purchase_invoice_ref' => '3964', 'purchase_price' => 265.00, ]); } $page = new SerialiCatalogo(); $page->mount(); expect($page->missingAdminContext)->toBeFalse() ->and($page->fornitoreId)->toBe((int) $nethome->id); $page->search = '8CG9454YMN'; $page->updatedSearch(); expect(count($page->rows))->toBeGreaterThanOrEqual(1) ->and($page->rows[0]['serial_number'])->toBe('8CG9454YMN'); }); test('prodotti catalogo page mounts with default supplier without throwing missing admin context', function () { $user = User::factory()->create(); $user->assignRole('super-admin'); Auth::login($user); $nethome = Fornitore::query()->where('partita_iva', '10055221005')->first(); if (! $nethome) { Fornitore::query()->create([ 'partita_iva' => '10055221005', 'ragione_sociale' => 'NETHOME sas di BARONE M. & C.', 'codice_univoco' => 'NETHOME', 'amministratore_id' => 13, ]); } $page = new ProdottiCatalogo(); $page->mount(); expect($page->missingAdminContext)->toBeFalse() ->and($page->fornitoreId)->toBeGreaterThan(0); });