8 lines
2.6 KiB
PHP
8 lines
2.6 KiB
PHP
<?php
|
|
use Illuminate\Support\Facades\DB;
|
|
$s=json_decode(file_get_contents(getenv('RECEIPT_COMPOSITION_STATE')),true);$out=$s['root'].'/supplier-search-demo.json';if(!($s['supplierSearch']??false)||is_file($out)||!is_file($s['root'].'/supplier-search-seed.json'))throw new LogicException('Prepared selector demonstration required');require $s['app'].'/vendor/autoload.php';$app=require $s['app'].'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();$n=json_decode(file_get_contents($s['root'].'/native-fixture.json'),true);config(['database.connections.selector_demo'=>$s['nativeConnection']]);$db=DB::connection('selector_demo');$checks=[];$ok=function($v,$name)use(&$checks){if(!$v)throw new RuntimeException($name);$checks[]=$name;};
|
|
$before=hash('sha256',json_encode([$db->table('requisitions')->orderBy('id')->get(),$db->table('quotations')->get(),$db->table('audit_logs')->orderBy('id')->get(),DB::table('geo_locations')->get()]));$ok($db->table('requisitions')->where('tenant_id',$n['tenant'])->count()===0&&$db->table('quotations')->count()===0,'new live demo starts before source request and proposal');
|
|
$client=new GuzzleHttp\Client(['base_uri'=>'http://127.0.0.1:8073','http_errors'=>false,'timeout'=>25]);$jar=new GuzzleHttp\Cookie\CookieJar;$r=$client->get('/qa/enter/actor',['cookies'=>$jar]);$v=json_decode((string)$r->getBody(),true);$o=['cookies'=>$jar,'headers'=>['Accept'=>'application/json','X-SGF-Context'=>$v['context']]];$r=$client->get('/purchasing/sourcing',$o);$ok($r->getStatusCode()===200&&str_contains((string)$r->getBody(),'sourcing-workspace.mjs'),'sourcing screen serves in new composition');$r=$client->get('/purchasing/workspace',$o);$ok($r->getStatusCode()===200&&str_contains((string)$r->getBody(),'href="/purchasing/sourcing"'),'common integrated navigation preserved');
|
|
foreach(['sourcing-workspace.mjs','supplier-picker-model.mjs']as$file){$r=$client->get('/'.$file);$ok($r->getStatusCode()===200&&hash('sha256',(string)$r->getBody())===hash_file('sha256',$s['app'].'/public/'.$file),'served selector source matches '.$file);}
|
|
$after=hash('sha256',json_encode([$db->table('requisitions')->orderBy('id')->get(),$db->table('quotations')->get(),$db->table('audit_logs')->orderBy('id')->get(),DB::table('geo_locations')->get()]));$ok($before===$after,'live screen and source checks leave operations and locations intact');file_put_contents($out,json_encode(['passed'=>true,'checks'=>$checks,'before'=>$before,'after'=>$after,'visual_review'=>false],JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR));echo count($checks)." supplier selector demo checks passed.\n";
|