oportunidades 3
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-10-09 15:00:37 +02:00
parent 9d6176f55b
commit e662230df7
32 changed files with 865 additions and 37 deletions
+2 -1
View File
@@ -95,6 +95,7 @@ foreach ($manifest as $name => $hash) {
$read->close();
$proof = ['restore_verified' => true, 'verified_at' => gmdate('c'), 'target' => $target, 'restored_target' => $restored,
'dump_path' => $dump, 'sha256' => hash_file('sha256', $dump), 'table_counts' => $counts, 'table_hashes' => $hashes,
'files_verified' => true, 'files_path' => $files, 'files_sha256' => hash_file('sha256', $files), 'file_hashes' => $manifest];
'files_verified' => true, 'files_path' => $files, 'files_sha256' => hash_file('sha256', $files), 'file_hashes' => $manifest,
'audit_event_ids' => $active->query('SELECT id FROM audit_events ORDER BY id')->fetchAll(PDO::FETCH_COLUMN)];
file_put_contents(storage_path('app/private/virtual-desk/backup-proof.json'), json_encode($proof, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
echo json_encode(['restore_verified' => true, 'tables' => count($tables), 'files' => count($manifest), 'restore_target' => $restored], JSON_THROW_ON_ERROR);
+1 -1
View File
@@ -8,5 +8,5 @@ const desktop=await session({width:1280,height:900}),page=desktop.page;await pag
await page.getByLabel('Título',{exact:true}).fill('QA production location');await page.getByLabel('Papel da localização',{exact:true}).selectOption('production');const provinceSelect=page.getByLabel('Província',{exact:true});await provinceSelect.locator('option').nth(1).waitFor({state:'attached'});const province=await provinceSelect.locator('option').nth(1).getAttribute('value');await provinceSelect.selectOption(province);const districtSelect=page.getByLabel('Distrito',{exact:true});await districtSelect.locator('option').nth(1).waitFor({state:'attached'});const district=await districtSelect.locator('option').nth(1).getAttribute('value');await districtSelect.selectOption(district);await page.getByLabel('Distribuição (%)',{exact:true}).fill('60');await page.getByLabel('Localização principal',{exact:true}).check();await page.getByLabel('Motivo (20–1000 caracteres)').fill('Localização e distribuição declaradas em QA');await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();await page.locator('article').filter({hasText:'QA production location'}).waitFor();
await page.getByLabel('Título',{exact:true}).fill('QA market location');await page.getByLabel('Papel da localização',{exact:true}).selectOption('market');await provinceSelect.selectOption(province);await districtSelect.locator('option').nth(1).waitFor({state:'attached'});await districtSelect.selectOption(district);await page.getByLabel('Distribuição (%)',{exact:true}).fill('40');await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();await page.locator('article').filter({hasText:'QA market location'}).waitFor();assert.equal(await page.locator('article').count(),2);
await page.getByRole('button',{name:'Documentos',exact:true}).click();await page.getByLabel('Título',{exact:true}).fill('QA source document');await page.getByLabel('Original / substituir por nova versão').setInputFiles({name:'qa.pdf',mimeType:'application/pdf',buffer:Buffer.from('%PDF-1.7\nSynthetic QA document\n%%EOF')});await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();await page.locator('article').filter({hasText:'QA source document'}).waitFor();
await page.getByRole('button',{name:'Imagens',exact:true}).click();await page.getByLabel('Título',{exact:true}).fill('QA synthetic image');await page.getByLabel('Legenda',{exact:true}).fill('Synthetic image only used in isolated QA');await page.getByLabel('Texto alternativo',{exact:true}).fill('Black square generated for isolated QA');await page.getByLabel('Direitos de utilização',{exact:true}).selectOption('owned');await page.getByLabel('Original / substituir por nova versão').setInputFiles({name:'qa.png',mimeType:'image/png',buffer:png()});await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();const imageArticle=page.locator('article').filter({hasText:'QA synthetic image'});await imageArticle.waitFor();await imageArticle.getByRole('button',{name:'Ver / editar / restaurar'}).click();await page.getByRole('button',{name:'Preparar WebP e miniaturas'}).click();await page.getByText(/GD\/WebP não disponível neste processo|Scan do original pendente ou inseguro/).waitFor();assert.equal(await page.getByLabel('Título',{exact:true}).inputValue(),'QA synthetic image');await page.screenshot({path:dir+'opportunity-resources-desktop.png',fullPage:true});await desktop.context.close();
await page.getByRole('button',{name:'Imagens',exact:true}).click();await page.getByLabel('Título',{exact:true}).fill('QA synthetic image');await page.getByLabel('Legenda',{exact:true}).fill('Synthetic image only used in isolated QA');await page.getByLabel('Texto alternativo',{exact:true}).fill('Black square generated for isolated QA');await page.getByLabel('Direitos de utilização',{exact:true}).selectOption('owned');await page.getByLabel('Original / substituir por nova versão').setInputFiles({name:'qa.png',mimeType:'image/png',buffer:png()});await page.getByRole('button',{name:'Guardar recurso',exact:true}).click();const imageArticle=page.locator('article').filter({hasText:'QA synthetic image'});await imageArticle.waitFor();await imageArticle.getByRole('button',{name:'Ver / editar / restaurar'}).click();const prepareButton=page.getByRole('button',{name:'Preparar WebP e miniaturas'});if(await prepareButton.isDisabled()){await page.getByText(/Processamento de imagens indisponível/).waitFor();}else{await prepareButton.click();await page.getByText(/Scan do original pendente ou inseguro/).waitFor();}assert.equal(await page.getByLabel('Título',{exact:true}).inputValue(),'QA synthetic image');await page.screenshot({path:dir+'opportunity-resources-desktop.png',fullPage:true});await desktop.context.close();
const mobile=await session({width:390,height:844}),mp=mobile.page;await mp.goto(base+`/management/opportunities/${id}/resources`);await mp.evaluate(()=>localStorage.clear());await mp.reload();assert.equal(await mp.locator('article').count(),2);await mp.getByRole('button',{name:'Imagens',exact:true}).click();const mi=mp.locator('article').filter({hasText:'QA synthetic image'});await mi.getByRole('button',{name:'Ver / editar / restaurar'}).click();assert.equal(await mp.getByLabel('Texto alternativo',{exact:true}).inputValue(),'Black square generated for isolated QA');await mp.getByLabel('Motivo (20–1000 caracteres)').fill('Exclusão lógica de imagem somente no ensaio QA');await mp.getByLabel('Confirmar exclusão lógica / restauração').check();await mp.getByRole('button',{name:'Excluir recurso logicamente'}).click();await mp.getByText('eliminado logicamente',{exact:false}).first().waitFor();await mi.getByRole('button',{name:'Ver / editar / restaurar'}).click();await mp.getByLabel('Confirmar exclusão lógica / restauração').check();await mp.getByRole('button',{name:'Restaurar recurso'}).click();await mi.getByText(/rascunho/).waitFor();await mp.screenshot({path:dir+'opportunity-resources-mobile.png',fullPage:true});assert(await mp.evaluate(()=>document.documentElement.scrollWidth<=innerWidth+1));assert.deepEqual(errors,[]);const proof={recorded_at:new Date().toISOString(),id,desktop:true,mobile:true,new_session_recovery:true,multiple_locations:true,documents:true,images:true,scan_failure_visible:true,soft_delete_restore:true,errors,active_writes:0};fs.writeFileSync(dir+'opportunity-resources-browser.json',JSON.stringify(proof,null,2));console.log(JSON.stringify(proof));await browser.close();})().catch(e=>{console.error(e);process.exit(1)});
@@ -0,0 +1,30 @@
<?php
// Read-only installation readiness; never applies migrations or authenticates an actor.
require dirname(__DIR__).'/vendor/autoload.php';
$app = require dirname(__DIR__).'/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
$db = $app->make('db')->connection();
$db->beginTransaction();
try {
$db->statement('SET TRANSACTION READ ONLY');
$preview = $app->make(\App\Services\OpportunityResourceInstallation::class)->preview();
$proofPath = storage_path('app/private/investmoz-v2/opportunity-resources-activation-proof.json');
$proof = is_file($proofPath) ? json_decode(file_get_contents($proofPath), true, 512, JSON_THROW_ON_ERROR) : [];
$result = [
'captured_at' => gmdate('c'),
'read_only' => $db->selectOne("SELECT current_setting('transaction_read_only') AS value")->value,
'installed' => $preview['installed'],
'ready' => $preview['ready'],
'target' => $preview['target'],
'current_code_hash' => $preview['code_hash'],
'proof_code_hash' => $proof['code_hash'] ?? null,
'code_matches_proof' => ($proof['code_hash'] ?? '') === $preview['code_hash'],
'backup_date' => $preview['backupDate'],
'active_writes' => 0,
];
file_put_contents(storage_path('app/private/investmoz-v2/opportunity-resources-readiness.json'), json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;
} finally {
$db->rollBack();
}
+5
View File
@@ -66,6 +66,11 @@ if (PHP_SAPI === 'cli' && ($argv[1] ?? '') === 'verify') {
foreach (['opportunities', 'opportunity_projects', 'opportunity_clusters', 'opportunity_locations', 'geo_locations', 'documents', 'opportunity_favourites', 'interest_requests', 'interest_submission_receipts', 'investment_messages', 'tasks', 'project_locations', 'cluster_projects', 'audit_events'] as $table) {
$key = '"public"."'.$table.'"';
$query = $table === 'opportunities' ? '(SELECT '.$projection.' FROM opportunities WHERE management_creation_key IS NULL)' : ($table === 'audit_events' ? "(SELECT * FROM audit_events WHERE source_system IS DISTINCT FROM 'opportunity-resources' AND source_system IS DISTINCT FROM 'opportunity-management')" : $key);
if ($table === 'audit_events' && isset($backup['audit_event_ids'])) {
// Compare every original event by identity; new QA actions must not hide or replace history.
$originalIds = array_map(fn ($id) => DB::connection()->getPdo()->quote($id), $backup['audit_event_ids']);
$query = '(SELECT * FROM audit_events WHERE id IN ('.($originalIds ? implode(',', $originalIds) : 'NULL').'))';
}
if ($table === 'documents') {
$oldDocumentColumns = array_diff(array_keys((array) DB::selectOne('SELECT * FROM documents LIMIT 1')), ['storage_encryption']);
$documentProjection = implode(',', array_map(fn ($column) => '"'.$column.'"', $oldDocumentColumns));
@@ -0,0 +1,51 @@
const {chromium} = require('C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
const fs = require('node:fs'), assert = require('node:assert/strict');
const base = 'http://127.0.0.1:18096';
(async () => {
const browser = await chromium.launch({headless:true, executablePath:'C:/Users/macbook/AppData/Local/ms-playwright/chromium-1243/chrome-win64/chrome.exe'});
const errors = [], results = [];
async function login(width) {
const context = await browser.newContext({viewport:{width,height:900}});
await context.route('**/*', route => route.request().url().startsWith(base) || route.request().url().startsWith('data:') ? route.continue() : route.abort());
const page = await context.newPage(); page.on('pageerror', e => errors.push(e.message));
await page.goto(base+'/login');
assert.match((await page.request.get(base+'/login')).headers()['x-investmoz-qa-target'], /_test:55441$/);
await page.getByLabel('Email address').fill('opportunity-manager@example.invalid');
await page.getByLabel('Password',{exact:true}).fill('Opportunity-QA-2026!');
await page.getByRole('button',{name:'Log in',exact:true}).click(); await page.waitForURL('**/dashboard');
return {page,context};
}
const desktop = await login(1280), p = desktop.page;
await p.goto(base+'/investidor/profile');
await p.locator('#residence_country_codeaccount').selectOption('PT');
const saved = p.waitForResponse(r => r.request().method() === 'PUT' && r.url().endsWith('/investidor/profile'));
await p.getByRole('button',{name:'Guardar perfil de investimento',exact:true}).click();
const response = await saved;
assert([200, 302, 303].includes(response.status()), `Guardar perfil: HTTP ${response.status()}`);
await p.getByText('Perfil de investimento guardado.', {exact:true}).waitFor();
await p.reload(); assert.equal(await p.locator('#residence_country_codeaccount').inputValue(),'PT');
results.push({route:'/investidor/profile',action:'guardar residência',http:response.status(),visibleResult:true,recovered:true});
await desktop.context.close();
const mobile = await login(390), m = mobile.page;
await m.goto(base+'/investidor/profile'); await m.evaluate(()=>localStorage.clear()); await m.reload();
assert.equal(await m.locator('#residence_country_codeaccount').inputValue(),'PT');
const search = m.getByRole('textbox',{name:'Pesquisar país'}).first(); await search.fill('portugal');
assert.equal(await m.locator('#residence_country_codeaccount option').count(),2);
assert(await m.evaluate(()=>document.documentElement.scrollWidth <= innerWidth+1));
await m.screenshot({path:'storage/app/private/investmoz-v2/functional-country-mobile.png',fullPage:true});
results.push({route:'/investidor/profile',action:'nova sessão móvel e pesquisa',serverRecovery:true,localStorage:false});
await m.goto(base+'/oportunidades?dimension=cluster');
assert.equal(await m.getByText('ZEE',{exact:true}).count(),0);
await m.getByRole('textbox',{name:'Pesquisar Província'}).fill('Maputo');
await m.getByLabel('Província',{exact:true}).locator('option').nth(1).waitFor({state:'attached'});
assert(await m.getByLabel('Província',{exact:true}).locator('option').count()>1);
results.push({route:'/oportunidades?dimension=cluster',action:'filtros contextuais e pesquisa provincial',visible:true});
await m.goto(base+'/oportunidades?view=map');
await m.getByRole('region', {name:'Estruturas territoriais consultáveis'}).waitFor();
assert(await m.getByRole('region', {name:'Estruturas territoriais consultáveis'}).getByRole('link').count() > 0);
results.push({route:'/oportunidades?view=map',action:'consultar estruturas sem inventar coordenadas',visible:true});
assert.deepEqual(errors,[]);
const proof={captured_at:new Date().toISOString(),results,errors,active_writes:0,scope:'country profile and catalogue filters only; not full portal acceptance'};
fs.writeFileSync('storage/app/private/investmoz-v2/functional-country-browser.json',JSON.stringify(proof,null,2));
console.log(JSON.stringify(proof)); await browser.close();
})().catch(e=>{console.error(e);process.exit(1)});