@@ -0,0 +1,51 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const assert = require('node:assert/strict');
|
||||
const { chromium } = require(process.env.PLAYWRIGHT_MODULE || 'playwright');
|
||||
|
||||
// Read-only public navigation and login of the documented local demo account.
|
||||
// Receipts never include cookies, request bodies or credentials.
|
||||
(async () => {
|
||||
const base = 'http://127.0.0.1:8000';
|
||||
const directory = path.resolve(__dirname, '../outputs/local-startup-20261019');
|
||||
fs.mkdirSync(directory, { recursive: true });
|
||||
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||
const errors = [];
|
||||
const failures = [];
|
||||
const checks = [];
|
||||
try {
|
||||
const page = await browser.newPage({ viewport: { width: 1366, height: 900 } });
|
||||
page.on('pageerror', error => errors.push(error.message));
|
||||
page.on('response', response => {
|
||||
if (response.url().startsWith(base) && response.status() >= 500) {
|
||||
failures.push({ path: new URL(response.url()).pathname, status: response.status() });
|
||||
}
|
||||
});
|
||||
for (const route of ['/', '/oportunidades', '/sectores/agronegocio', '/login', '/register']) {
|
||||
const response = await page.goto(base + route, { waitUntil: 'networkidle', timeout: 90000 });
|
||||
assert.equal(response.status(), 200, route);
|
||||
await page.locator('#app').waitFor();
|
||||
assert.ok((await page.locator('body').innerText()).trim().length > 100, route);
|
||||
checks.push({ path: route, status: response.status(), rendered: true });
|
||||
if (route === '/') await page.screenshot({ path: path.join(directory, 'home.png'), fullPage: true });
|
||||
}
|
||||
await page.goto(base + '/login', { waitUntil: 'networkidle' });
|
||||
await page.locator('input[name=email]').fill('test@example.com');
|
||||
await page.locator('input[name=password]').fill('password');
|
||||
await Promise.all([
|
||||
page.waitForURL('**/dashboard', { timeout: 60000 }),
|
||||
page.locator('button[type=submit]').click(),
|
||||
]);
|
||||
await page.waitForLoadState('networkidle');
|
||||
assert.ok((await page.locator('body').innerText()).trim().length > 100);
|
||||
checks.push({ path: '/dashboard', authenticated: true, rendered: true });
|
||||
await page.screenshot({ path: path.join(directory, 'dashboard.png'), fullPage: true });
|
||||
assert.deepEqual(errors, []);
|
||||
assert.deepEqual(failures, []);
|
||||
const receipt = { at: new Date().toISOString(), checks, javascriptErrors: errors, serverErrors: failures };
|
||||
fs.writeFileSync(path.join(directory, 'browser.json'), JSON.stringify(receipt, null, 2));
|
||||
console.log(JSON.stringify(receipt));
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
// Technical setup for the explicitly authorised, disposable local demo only.
|
||||
// The production database and authenticated installation workflow remain separate.
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
||||
foreach (['APP_ENV' => 'testing', 'APP_CONFIG_CACHE' => dirname(__DIR__).'/storage/framework/cache/local-qa-config.php'] as $key => $value) {
|
||||
putenv($key.'='.$value);
|
||||
$_ENV[$key] = $_SERVER[$key] = $value;
|
||||
}
|
||||
|
||||
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
$connection = config('database.connections.pgsql');
|
||||
if (app()->configurationIsCached() || config('database.default') !== 'pgsql'
|
||||
|| $connection['host'] !== '127.0.0.1' || (string) $connection['port'] !== '55441'
|
||||
|| $connection['database'] !== 'investmoz_local_test' || ! empty($connection['url'])) {
|
||||
fwrite(STDERR, 'Refused: explicit isolated local QA database required.'.PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
$identity = DB::selectOne('SELECT current_database() AS database, inet_server_port() AS port');
|
||||
if ($identity->database !== 'investmoz_local_test' || (int) $identity->port !== 55441) {
|
||||
fwrite(STDERR, 'Refused: actual QA server identity differs.'.PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
$status = Artisan::call('migrate', ['--force' => true]);
|
||||
} catch (Throwable $error) {
|
||||
fwrite(STDERR, 'Local QA migration failed: '.$error->getMessage().PHP_EOL);
|
||||
exit(1);
|
||||
}
|
||||
echo Artisan::output();
|
||||
if ($status !== 0) {
|
||||
exit($status);
|
||||
}
|
||||
|
||||
// Never reset an account or overwrite an existing demo on a repeated setup.
|
||||
if (DB::table('sectors')->count() === 0 && DB::table('users')->count() === 0) {
|
||||
$status = Artisan::call('db:seed', ['--force' => true]);
|
||||
echo Artisan::output();
|
||||
exit($status);
|
||||
}
|
||||
echo 'Existing local demo preserved; seed skipped.'.PHP_EOL;
|
||||
Reference in New Issue
Block a user