Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cf820ef49 | ||
|
|
210b7d273b | ||
|
|
be49f4c39c | ||
|
|
9b3c20fc2a | ||
|
|
de061b81aa | ||
|
|
6e439def02 | ||
|
|
74b081e93e | ||
|
|
9d148ca241 | ||
|
|
02d4e6b2fd |
@@ -5,15 +5,24 @@ namespace App\Console\Commands;
|
|||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Schema;
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Sleep;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class CheckDevelopmentEnvironment extends Command
|
class CheckDevelopmentEnvironment extends Command
|
||||||
{
|
{
|
||||||
protected $signature = 'portal:dev-check';
|
protected $signature = 'portal:dev-check {--wait=0 : Segundos para aguardar uma falha transitória do PostgreSQL}';
|
||||||
|
|
||||||
protected $description = 'Verifica o arranque local sem alterar dados ou mostrar credenciais';
|
protected $description = 'Verifica o arranque local sem alterar dados ou mostrar credenciais';
|
||||||
|
|
||||||
public function handle(): int
|
public function handle(): int
|
||||||
{
|
{
|
||||||
|
$wait = filter_var($this->option('wait'), FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'max_range' => 3600]]);
|
||||||
|
if ($wait === false) {
|
||||||
|
$this->error('--wait deve ser um inteiro entre 0 e 3600 segundos.');
|
||||||
|
|
||||||
|
return self::INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
$checks = [
|
$checks = [
|
||||||
'PHP >= 8.4.1' => version_compare(PHP_VERSION, '8.4.1', '>='),
|
'PHP >= 8.4.1' => version_compare(PHP_VERSION, '8.4.1', '>='),
|
||||||
'Driver PostgreSQL activo' => extension_loaded('pdo_pgsql'),
|
'Driver PostgreSQL activo' => extension_loaded('pdo_pgsql'),
|
||||||
@@ -25,14 +34,17 @@ class CheckDevelopmentEnvironment extends Command
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($checks['Driver PostgreSQL activo'] && $checks['Base PostgreSQL configurada']) {
|
if ($checks['Driver PostgreSQL activo'] && $checks['Base PostgreSQL configurada']) {
|
||||||
|
$checks['Ligação à base de dados'] = $this->checkConnection($wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($checks['Ligação à base de dados'] ?? false) {
|
||||||
try {
|
try {
|
||||||
DB::selectOne('SELECT 1');
|
|
||||||
$checks['Ligação à base de dados'] = true;
|
|
||||||
$checks['Extensão PostGIS instalada'] = (bool) DB::selectOne("SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'postgis') AS installed")->installed;
|
$checks['Extensão PostGIS instalada'] = (bool) DB::selectOne("SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = 'postgis') AS installed")->installed;
|
||||||
$checks['Tabelas principais instaladas'] = collect(['migrations', 'users', 'sectors', 'opportunities', 'sessions', 'cache', 'jobs'])
|
$checks['Tabelas principais instaladas'] = collect(['migrations', 'users', 'sectors', 'opportunities', 'sessions', 'cache', 'jobs'])
|
||||||
->every(fn (string $table): bool => Schema::hasTable($table));
|
->every(fn (string $table): bool => Schema::hasTable($table));
|
||||||
} catch (\Throwable) {
|
} catch (Throwable) {
|
||||||
$checks['Ligação à base de dados'] = false;
|
$checks['Esquema da base de dados verificável'] = false;
|
||||||
|
$this->warn('A ligação foi estabelecida, mas a verificação do esquema falhou. Verifique as permissões e a preparação QA.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,4 +60,61 @@ class CheckDevelopmentEnvironment extends Command
|
|||||||
|
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkConnection(int $wait): bool
|
||||||
|
{
|
||||||
|
$deadline = microtime(true) + $wait;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
try {
|
||||||
|
DB::selectOne('SELECT 1');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (Throwable $error) {
|
||||||
|
[$reason, $retryable] = $this->connectionFailure($error);
|
||||||
|
$remaining = $deadline - microtime(true);
|
||||||
|
if (! $retryable || $remaining <= 0) {
|
||||||
|
$this->warn($reason);
|
||||||
|
if ($retryable) {
|
||||||
|
$this->warn('Inicie Docker Desktop e execute ./deploy/local/start.ps1. Consulte os registos com docker compose --env-file .env -f deploy/local/compose.yaml logs --tail 40 postgres.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->line('[AGUARDA] '.$reason.' Nova tentativa; prazo restante: '.(int) ceil($remaining).' s.');
|
||||||
|
DB::purge();
|
||||||
|
Sleep::for(min(5, $remaining))->seconds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array{string, bool} */
|
||||||
|
private function connectionFailure(Throwable $error): array
|
||||||
|
{
|
||||||
|
// Inspect the chain internally; never print exception messages, DSNs or credentials.
|
||||||
|
$messages = '';
|
||||||
|
do {
|
||||||
|
$messages .= ' '.strtolower($error->getMessage()).' '.strtolower((string) $error->getCode());
|
||||||
|
$error = $error->getPrevious();
|
||||||
|
} while ($error !== null);
|
||||||
|
|
||||||
|
if (str_contains($messages, '28p01') || str_contains($messages, '28000')
|
||||||
|
|| str_contains($messages, 'password authentication failed') || str_contains($messages, 'no pg_hba.conf entry')) {
|
||||||
|
return ['Autenticação PostgreSQL recusada. Verifique as credenciais e as regras de acesso; aguardar não corrige este erro.', false];
|
||||||
|
}
|
||||||
|
if (str_contains($messages, '3d000') || preg_match('/database .* does not exist/', $messages)) {
|
||||||
|
return ['A base PostgreSQL configurada não existe. Verifique a configuração e a preparação QA.', false];
|
||||||
|
}
|
||||||
|
if (str_contains($messages, '57p03') || str_contains($messages, 'recovery mode')
|
||||||
|
|| str_contains($messages, 'not yet accepting connections') || str_contains($messages, 'database system is starting up')) {
|
||||||
|
return ['PostgreSQL em arranque ou recuperação; aguarde a conclusão sem remover o volume.', true];
|
||||||
|
}
|
||||||
|
if (preg_match('/\b08[0-9a-z]{3}\b/', $messages) || str_contains($messages, 'connection refused')
|
||||||
|
|| str_contains($messages, '57p01') || str_contains($messages, '57p02')) {
|
||||||
|
return ['PostgreSQL indisponível. Verifique se Docker Desktop e o contentor local estão iniciados.', true];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['Falha PostgreSQL não transitória. Verifique a configuração e os registos do servidor.', false];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,10 @@ class Delivery:
|
|||||||
self.run(['npm','run','build'],cwd=release,env=env)
|
self.run(['npm','run','build'],cwd=release,env=env)
|
||||||
self.run(['npm','run','types:check'],cwd=release,env=env)
|
self.run(['npm','run','types:check'],cwd=release,env=env)
|
||||||
self.run([self.c['php'],'tools/portal-diagnostics-deployment-guard.php'],cwd=release,env=env)
|
self.run([self.c['php'],'tools/portal-diagnostics-deployment-guard.php'],cwd=release,env=env)
|
||||||
self.run([self.c['php'],'vendor/bin/phpunit','--configuration=phpunit.xml','--testsuite','Unit','--do-not-cache-result'],cwd=release,env=env)
|
# Unit fixtures mock DB/mail and select their own feature settings.
|
||||||
|
# Do not inject the destination's enabled-module flags into those mocks.
|
||||||
|
unit_env={k:v for k,v in env.items() if not k.startswith(('PORTAL_','INVESTMOZ_'))}
|
||||||
|
self.run([self.c['php'],'vendor/bin/phpunit','--configuration=phpunit.xml','--testsuite','Unit','--do-not-cache-result'],cwd=release,env=unit_env)
|
||||||
tests=sorted((release/'tests/frontend').glob('*.test.mjs'))
|
tests=sorted((release/'tests/frontend').glob('*.test.mjs'))
|
||||||
self.run(['node','--test',*tests],cwd=release,env=env)
|
self.run(['node','--test',*tests],cwd=release,env=env)
|
||||||
# Final production vendor from the same lock, before linking any real configuration.
|
# Final production vendor from the same lock, before linking any real configuration.
|
||||||
@@ -253,12 +256,17 @@ class Delivery:
|
|||||||
return {'status':'already_installed','commit':target}
|
return {'status':'already_installed','commit':target}
|
||||||
refuse_drift(self.current.resolve(),installed['hashes'])
|
refuse_drift(self.current.resolve(),installed['hashes'])
|
||||||
self.releases.mkdir(parents=True,exist_ok=True)
|
self.releases.mkdir(parents=True,exist_ok=True)
|
||||||
|
if shutil.disk_usage(self.releases).free < 5 * 1024**3:
|
||||||
|
raise RuntimeError('Insufficient free space for an isolated build; active release preserved')
|
||||||
release=self.releases/(target+'-'+uuid.uuid4().hex[:8]);release.mkdir(mode=0o750)
|
release=self.releases/(target+'-'+uuid.uuid4().hex[:8]);release.mkdir(mode=0o750)
|
||||||
self.build(target,release)
|
self.build(target,release)
|
||||||
if self.latest()!=target:
|
if self.latest()!=target:
|
||||||
latest=self.git('rev-parse','refs/heads/delivery-target')
|
latest=self.git('rev-parse','refs/heads/delivery-target')
|
||||||
write_json(self.state/'requests'/(latest+'.json'),{'commit':latest,'reason':'newer integration during build'})
|
write_json(self.state/'requests'/(latest+'.json'),{'commit':latest,'reason':'newer integration during build'})
|
||||||
return {'status':'superseded','commit':target,'newer_commit':latest}
|
return {'status':'superseded','commit':target,'newer_commit':latest}
|
||||||
|
# A programmer may have edited the served release while CI was running.
|
||||||
|
# Recheck immediately before the atomic switch, preserving that work.
|
||||||
|
refuse_drift(self.current.resolve(),installed['hashes'])
|
||||||
previous=promote(self.current,release,lambda:self.health(target))
|
previous=promote(self.current,release,lambda:self.health(target))
|
||||||
try:
|
try:
|
||||||
self.run([self.c['php'],str(release/'artisan'),'queue:restart'],cwd=release)
|
self.run([self.c['php'],str(release/'artisan'),'queue:restart'],cwd=release)
|
||||||
@@ -271,15 +279,16 @@ class Delivery:
|
|||||||
raise
|
raise
|
||||||
return {key:value for key,value in info.items() if key!='hashes'}
|
return {key:value for key,value in info.items() if key!='hashes'}
|
||||||
|
|
||||||
def process(self) -> None:
|
def process(self) -> bool:
|
||||||
import fcntl
|
import fcntl
|
||||||
self.state.mkdir(parents=True,exist_ok=True)
|
self.state.mkdir(parents=True,exist_ok=True)
|
||||||
for directory in ['reports','logs','processed','qa-runtime']: (self.state/directory).mkdir(exist_ok=True)
|
for directory in ['reports','logs','processed','qa-runtime']: (self.state/directory).mkdir(exist_ok=True)
|
||||||
with (self.state/'delivery.lock').open('a') as lock:
|
with (self.state/'delivery.lock').open('a') as lock:
|
||||||
fcntl.flock(lock,fcntl.LOCK_EX)
|
fcntl.flock(lock,fcntl.LOCK_EX)
|
||||||
|
succeeded=True
|
||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
requests=sorted((self.state/'requests').glob('*.json'))
|
requests=sorted((self.state/'requests').glob('*.json'))
|
||||||
if not requests:return
|
if not requests:return succeeded
|
||||||
for path in requests:
|
for path in requests:
|
||||||
if not SHA.fullmatch(path.stem):raise RuntimeError('Unexpected queue entry')
|
if not SHA.fullmatch(path.stem):raise RuntimeError('Unexpected queue entry')
|
||||||
path.rename(self.state/'processed'/(path.stem+'-'+uuid.uuid4().hex[:8]+'.json'))
|
path.rename(self.state/'processed'/(path.stem+'-'+uuid.uuid4().hex[:8]+'.json'))
|
||||||
@@ -288,11 +297,13 @@ class Delivery:
|
|||||||
try:
|
try:
|
||||||
target=self.latest();report=self.deliver(target)
|
target=self.latest();report=self.deliver(target)
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
|
succeeded=False
|
||||||
report={'status':'failed','commit':target,'error':str(error),'active_release_preserved':True}
|
report={'status':'failed','commit':target,'error':str(error),'active_release_preserved':True}
|
||||||
finally:self.log=None
|
finally:self.log=None
|
||||||
report.update(requested_commits=[p.stem for p in requests],finished_at=datetime.datetime.now(datetime.timezone.utc).isoformat())
|
report.update(requested_commits=[p.stem for p in requests],finished_at=datetime.datetime.now(datetime.timezone.utc).isoformat())
|
||||||
write_json(self.state/'reports'/((target or 'fetch-failed')+'-'+str(time.time_ns())+'.json'),report)
|
write_json(self.state/'reports'/((target or 'fetch-failed')+'-'+str(time.time_ns())+'.json'),report)
|
||||||
print(json.dumps(report),flush=True)
|
print(json.dumps(report),flush=True)
|
||||||
|
return succeeded
|
||||||
|
|
||||||
def rollback(self) -> dict:
|
def rollback(self) -> dict:
|
||||||
import fcntl
|
import fcntl
|
||||||
@@ -326,6 +337,6 @@ def main():
|
|||||||
if Path(config['legacy_root']).resolve()!=Path('/var/www/html/teste-investidor.tempo.co.mz'):raise SystemExit('Unexpected persistent application target')
|
if Path(config['legacy_root']).resolve()!=Path('/var/www/html/teste-investidor.tempo.co.mz'):raise SystemExit('Unexpected persistent application target')
|
||||||
runner=Delivery(config)
|
runner=Delivery(config)
|
||||||
if args.rollback:print(json.dumps(runner.rollback()),flush=True)
|
if args.rollback:print(json.dumps(runner.rollback()),flush=True)
|
||||||
else:runner.process()
|
else:raise SystemExit(0 if runner.process() else 1)
|
||||||
|
|
||||||
if __name__=='__main__':main()
|
if __name__=='__main__':main()
|
||||||
|
|||||||
@@ -433,6 +433,10 @@
|
|||||||
"existing_diagnostic_source_preserved": [
|
"existing_diagnostic_source_preserved": [
|
||||||
"app/Console/Commands/CheckDevelopmentEnvironment.php"
|
"app/Console/Commands/CheckDevelopmentEnvironment.php"
|
||||||
],
|
],
|
||||||
|
"subsequent_diagnostic_resolution": {
|
||||||
|
"commit": "9d148ca2419d2243489731287dc8019cfe117bd9",
|
||||||
|
"decision": "Retain the newer origin/main implementation, including --wait and safe transient-failure diagnostics. The installed older implementation has no unique behaviour to discard. The reconciled baseline commit remains preserved in history."
|
||||||
|
},
|
||||||
"generated_helper_not_committed": [
|
"generated_helper_not_committed": [
|
||||||
{
|
{
|
||||||
"path": "resources/js/wayfinder/index.ts",
|
"path": "resources/js/wayfinder/index.ts",
|
||||||
|
|||||||
+62
-10
@@ -301,23 +301,42 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-width: 1280px) {
|
@media (min-width: 1280px) {
|
||||||
.tempo-header-inner {
|
/* Shared columns keep each portal area below its institutional link. */
|
||||||
display: flex;
|
.tempo-header-layout {
|
||||||
min-height: 88px;
|
display: grid;
|
||||||
gap: 0.75rem;
|
grid-template-columns: auto repeat(4, max-content) minmax(0, 1fr) auto;
|
||||||
|
column-gap: 0.25rem;
|
||||||
|
max-width: 1440px;
|
||||||
|
margin-inline: auto;
|
||||||
padding-inline: 2rem;
|
padding-inline: 2rem;
|
||||||
}
|
}
|
||||||
|
.tempo-header-inner {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
min-height: 88px;
|
||||||
|
column-gap: normal;
|
||||||
|
max-width: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.tempo-logo-link {
|
||||||
|
margin-right: 0.75rem;
|
||||||
|
}
|
||||||
.tempo-header-logo {
|
.tempo-header-logo {
|
||||||
height: 64px;
|
height: 64px;
|
||||||
}
|
}
|
||||||
|
.tempo-header[data-expanded] .tempo-primary-navigation,
|
||||||
.tempo-primary-navigation {
|
.tempo-primary-navigation {
|
||||||
display: block;
|
display: grid;
|
||||||
flex: 1;
|
grid-area: 1 / 2 / 2 / 6;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
.tempo-primary-navigation > ul {
|
.tempo-primary-navigation > ul {
|
||||||
justify-content: center;
|
display: grid;
|
||||||
gap: 0.25rem;
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
gap: normal;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
.tempo-nav-trigger {
|
.tempo-nav-trigger {
|
||||||
@@ -332,6 +351,8 @@
|
|||||||
}
|
}
|
||||||
.tempo-header-extras {
|
.tempo-header-extras {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
grid-area: 1 / 6;
|
||||||
|
justify-self: end;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
padding: 0 0.75rem;
|
padding: 0 0.75rem;
|
||||||
border-top: 0;
|
border-top: 0;
|
||||||
@@ -347,16 +368,47 @@
|
|||||||
.tempo-header-toggle {
|
.tempo-header-toggle {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
.tempo-header-actions {
|
||||||
|
grid-area: 1 / 7;
|
||||||
|
}
|
||||||
|
.tempo-section-bar {
|
||||||
|
display: grid;
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
}
|
||||||
.tempo-section-inner {
|
.tempo-section-inner {
|
||||||
padding-inline: 2rem;
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
gap: normal;
|
||||||
|
max-width: none;
|
||||||
|
margin: 0;
|
||||||
|
padding-inline: 0;
|
||||||
|
}
|
||||||
|
.tempo-section-navigation {
|
||||||
|
display: grid;
|
||||||
|
grid-area: 1 / 2 / 2 / 5;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
}
|
||||||
|
.tempo-section-navigation > ul {
|
||||||
|
display: grid;
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: subgrid;
|
||||||
|
gap: normal;
|
||||||
}
|
}
|
||||||
.tempo-section-navigation .tempo-nav-trigger {
|
.tempo-section-navigation .tempo-nav-trigger {
|
||||||
padding-inline: 1.25rem;
|
padding-inline: 0.625rem;
|
||||||
|
}
|
||||||
|
.tempo-primary-navigation .tempo-nav-trigger,
|
||||||
|
.tempo-section-navigation .tempo-nav-trigger {
|
||||||
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
.tempo-interest-button {
|
.tempo-interest-button {
|
||||||
padding-inline: 0.85rem;
|
padding-inline: 0.85rem;
|
||||||
font-size: 0.8125rem;
|
font-size: 0.8125rem;
|
||||||
}
|
}
|
||||||
|
.tempo-section-inner .tempo-interest-button {
|
||||||
|
grid-area: 1 / 6 / 2 / -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.tempo-header :is(a, button):focus-visible {
|
.tempo-header :is(a, button):focus-visible {
|
||||||
outline: 2px solid #fff;
|
outline: 2px solid #fff;
|
||||||
|
|||||||
@@ -127,223 +127,237 @@ export function PortalGroupedMenu() {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className="tempo-header-inner">
|
<div className="tempo-header-layout">
|
||||||
<Link
|
<div className="tempo-header-inner">
|
||||||
href="/"
|
<Link
|
||||||
aria-label="InvesteMoz — início"
|
href="/"
|
||||||
className="tempo-logo-link"
|
aria-label="InvesteMoz — início"
|
||||||
>
|
className="tempo-logo-link"
|
||||||
<PortalProductIdentity />
|
>
|
||||||
</Link>
|
<PortalProductIdentity />
|
||||||
<nav
|
</Link>
|
||||||
id={institutionalId}
|
<nav
|
||||||
aria-label="Navegação institucional"
|
id={institutionalId}
|
||||||
className="tempo-primary-navigation"
|
aria-label="Navegação institucional"
|
||||||
>
|
className="tempo-primary-navigation"
|
||||||
<ul>
|
>
|
||||||
<li>
|
<ul>
|
||||||
<Link
|
<li>
|
||||||
href="/"
|
|
||||||
className="tempo-nav-trigger"
|
|
||||||
aria-current={
|
|
||||||
url.split('?')[0] === '/'
|
|
||||||
? 'page'
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
data-current-group={
|
|
||||||
url.split('?')[0] === '/' || undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t('Início')}
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a
|
|
||||||
href="https://revista.tempo.co.mz/"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
className="tempo-nav-trigger"
|
|
||||||
aria-label={`${t('Revista Tempo')} — ${t('Abre num novo separador')}`}
|
|
||||||
>
|
|
||||||
{t('Revista Tempo')}
|
|
||||||
<ArrowUpRight size={14} aria-hidden="true" />
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
{[
|
|
||||||
['/sobre', 'Sobre nós'],
|
|
||||||
['/contacto', 'Contacto'],
|
|
||||||
].map(([href, label]) => (
|
|
||||||
<li key={href}>
|
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href="/"
|
||||||
className="tempo-nav-trigger"
|
className="tempo-nav-trigger"
|
||||||
aria-current={
|
aria-current={
|
||||||
url.split('?')[0] === href
|
url.split('?')[0] === '/'
|
||||||
? 'page'
|
? 'page'
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
data-current-group={
|
data-current-group={
|
||||||
url.split('?')[0] === href || undefined
|
url.split('?')[0] === '/' || undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{t(label)}
|
{t('Início')}
|
||||||
</Link>
|
</Link>
|
||||||
</li>
|
</li>
|
||||||
))}
|
<li>
|
||||||
</ul>
|
<a
|
||||||
</nav>
|
href="https://revista.tempo.co.mz/"
|
||||||
<div id={toolsId} className="tempo-header-extras">
|
target="_blank"
|
||||||
<div className="tempo-header-utilities">
|
rel="noopener noreferrer"
|
||||||
<div className="flex items-center gap-1">
|
className="tempo-nav-trigger"
|
||||||
<TempoWeather />
|
aria-label={`${t('Revista Tempo')} — ${t('Abre num novo separador')}`}
|
||||||
<TempoLanguageSelector />
|
|
||||||
</div>
|
|
||||||
<TempoSocialLinks />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="tempo-header-actions">
|
|
||||||
{props.auth?.user ? (
|
|
||||||
<DropdownMenu modal={false}>
|
|
||||||
<DropdownMenuTrigger className="tempo-login-button">
|
|
||||||
<UserRound size={16} aria-hidden="true" />
|
|
||||||
<span className="max-w-24 truncate">
|
|
||||||
{props.auth.user.name || t('A minha área')}
|
|
||||||
</span>
|
|
||||||
<ChevronDown size={12} aria-hidden="true" />
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent
|
|
||||||
align="end"
|
|
||||||
sideOffset={12}
|
|
||||||
collisionPadding={12}
|
|
||||||
className="tempo-dropdown max-h-[75vh] w-72 max-w-[calc(100vw-1.5rem)] overflow-y-auto p-2"
|
|
||||||
>
|
|
||||||
<DropdownMenuLabel className="truncate text-xs text-slate-500">
|
|
||||||
{props.auth.user.email}
|
|
||||||
</DropdownMenuLabel>
|
|
||||||
{items(accountGroups)}
|
|
||||||
<DropdownMenuSeparator />
|
|
||||||
<DropdownMenuItem
|
|
||||||
asChild
|
|
||||||
className="tempo-menu-item text-red-700"
|
|
||||||
>
|
>
|
||||||
|
{t('Revista Tempo')}
|
||||||
|
<ArrowUpRight
|
||||||
|
size={14}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{[
|
||||||
|
['/sobre', 'Sobre nós'],
|
||||||
|
['/contacto', 'Contacto'],
|
||||||
|
].map(([href, label]) => (
|
||||||
|
<li key={href}>
|
||||||
<Link
|
<Link
|
||||||
href={logout()}
|
href={href}
|
||||||
as="button"
|
className="tempo-nav-trigger"
|
||||||
type="button"
|
aria-current={
|
||||||
disabled={loggingOut}
|
url.split('?')[0] === href
|
||||||
data-test="portal-logout-button"
|
? 'page'
|
||||||
onClick={() => router.flushAll()}
|
: undefined
|
||||||
onStart={() => setLoggingOut(true)}
|
}
|
||||||
onFinish={() => setLoggingOut(false)}
|
data-current-group={
|
||||||
|
url.split('?')[0] === href ||
|
||||||
|
undefined
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<LogOut size={16} aria-hidden="true" />
|
{t(label)}
|
||||||
{loggingOut
|
|
||||||
? 'A terminar sessão…'
|
|
||||||
: t('Terminar sessão')}
|
|
||||||
</Link>
|
</Link>
|
||||||
</DropdownMenuItem>
|
</li>
|
||||||
</DropdownMenuContent>
|
))}
|
||||||
</DropdownMenu>
|
|
||||||
) : (
|
|
||||||
<Link href="/login" className="tempo-login-button">
|
|
||||||
<UserRound size={15} aria-hidden="true" />
|
|
||||||
{t('Entrar')}
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
ref={toggle}
|
|
||||||
type="button"
|
|
||||||
className="tempo-header-toggle"
|
|
||||||
aria-label={
|
|
||||||
expanded
|
|
||||||
? 'Fechar menu e ferramentas'
|
|
||||||
: 'Abrir menu e ferramentas'
|
|
||||||
}
|
|
||||||
aria-expanded={expanded}
|
|
||||||
aria-controls={`${institutionalId} ${toolsId}`}
|
|
||||||
onClick={() => setExpanded(!expanded)}
|
|
||||||
>
|
|
||||||
{expanded ? (
|
|
||||||
<X size={22} aria-hidden="true" />
|
|
||||||
) : (
|
|
||||||
<Menu size={22} aria-hidden="true" />
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="tempo-section-bar">
|
|
||||||
<div className="tempo-section-inner">
|
|
||||||
<Link
|
|
||||||
href="/investidor/manifestacoes"
|
|
||||||
className="tempo-panel-summary"
|
|
||||||
>
|
|
||||||
<span>{t('O meu painel')}</span>
|
|
||||||
<span
|
|
||||||
className="tempo-panel-count"
|
|
||||||
aria-live="polite"
|
|
||||||
aria-atomic="true"
|
|
||||||
>
|
|
||||||
{requestCount}{' '}
|
|
||||||
{t(
|
|
||||||
requestCount === 1
|
|
||||||
? 'pedido recebido'
|
|
||||||
: 'pedidos recebidos',
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
</Link>
|
|
||||||
<nav
|
|
||||||
aria-label="Áreas do portal"
|
|
||||||
className="tempo-section-navigation"
|
|
||||||
>
|
|
||||||
<ul>
|
|
||||||
{groups
|
|
||||||
.filter((group) =>
|
|
||||||
[
|
|
||||||
'discovery',
|
|
||||||
'realization',
|
|
||||||
'support',
|
|
||||||
].includes(group.id),
|
|
||||||
)
|
|
||||||
.map((group) => (
|
|
||||||
<li key={group.id}>
|
|
||||||
<DropdownMenu modal={false}>
|
|
||||||
<DropdownMenuTrigger
|
|
||||||
className="tempo-nav-trigger"
|
|
||||||
data-current-group={
|
|
||||||
current === group.id ||
|
|
||||||
undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{t(group.label)}
|
|
||||||
<ChevronDown
|
|
||||||
size={14}
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
{current === group.id && (
|
|
||||||
<span className="sr-only">
|
|
||||||
Grupo actual
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent
|
|
||||||
align="start"
|
|
||||||
sideOffset={8}
|
|
||||||
collisionPadding={12}
|
|
||||||
className="tempo-dropdown max-h-[min(75vh,36rem)] w-72 max-w-[calc(100vw-1.5rem)] overflow-y-auto p-2"
|
|
||||||
>
|
|
||||||
{items(group.children ?? [])}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<Link
|
<div id={toolsId} className="tempo-header-extras">
|
||||||
href="/manifestar-interesse"
|
<div className="tempo-header-utilities">
|
||||||
className="tempo-interest-button"
|
<div className="flex items-center gap-1">
|
||||||
|
<TempoWeather />
|
||||||
|
<TempoLanguageSelector />
|
||||||
|
</div>
|
||||||
|
<TempoSocialLinks />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="tempo-header-actions">
|
||||||
|
{props.auth?.user ? (
|
||||||
|
<DropdownMenu modal={false}>
|
||||||
|
<DropdownMenuTrigger className="tempo-login-button">
|
||||||
|
<UserRound size={16} aria-hidden="true" />
|
||||||
|
<span className="max-w-24 truncate">
|
||||||
|
{props.auth.user.name ||
|
||||||
|
t('A minha área')}
|
||||||
|
</span>
|
||||||
|
<ChevronDown size={12} aria-hidden="true" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent
|
||||||
|
align="end"
|
||||||
|
sideOffset={12}
|
||||||
|
collisionPadding={12}
|
||||||
|
className="tempo-dropdown max-h-[75vh] w-72 max-w-[calc(100vw-1.5rem)] overflow-y-auto p-2"
|
||||||
|
>
|
||||||
|
<DropdownMenuLabel className="truncate text-xs text-slate-500">
|
||||||
|
{props.auth.user.email}
|
||||||
|
</DropdownMenuLabel>
|
||||||
|
{items(accountGroups)}
|
||||||
|
<DropdownMenuSeparator />
|
||||||
|
<DropdownMenuItem
|
||||||
|
asChild
|
||||||
|
className="tempo-menu-item text-red-700"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
href={logout()}
|
||||||
|
as="button"
|
||||||
|
type="button"
|
||||||
|
disabled={loggingOut}
|
||||||
|
data-test="portal-logout-button"
|
||||||
|
onClick={() => router.flushAll()}
|
||||||
|
onStart={() => setLoggingOut(true)}
|
||||||
|
onFinish={() =>
|
||||||
|
setLoggingOut(false)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<LogOut
|
||||||
|
size={16}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{loggingOut
|
||||||
|
? 'A terminar sessão…'
|
||||||
|
: t('Terminar sessão')}
|
||||||
|
</Link>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
) : (
|
||||||
|
<Link href="/login" className="tempo-login-button">
|
||||||
|
<UserRound size={15} aria-hidden="true" />
|
||||||
|
{t('Entrar')}
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
ref={toggle}
|
||||||
|
type="button"
|
||||||
|
className="tempo-header-toggle"
|
||||||
|
aria-label={
|
||||||
|
expanded
|
||||||
|
? 'Fechar menu e ferramentas'
|
||||||
|
: 'Abrir menu e ferramentas'
|
||||||
|
}
|
||||||
|
aria-expanded={expanded}
|
||||||
|
aria-controls={`${institutionalId} ${toolsId}`}
|
||||||
|
onClick={() => setExpanded(!expanded)}
|
||||||
>
|
>
|
||||||
{t('Manifestar interesse')}
|
{expanded ? (
|
||||||
</Link>
|
<X size={22} aria-hidden="true" />
|
||||||
|
) : (
|
||||||
|
<Menu size={22} aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="tempo-section-bar">
|
||||||
|
<div className="tempo-section-inner">
|
||||||
|
<Link
|
||||||
|
href="/investidor/manifestacoes"
|
||||||
|
className="tempo-panel-summary"
|
||||||
|
>
|
||||||
|
<span>{t('O meu painel')}</span>
|
||||||
|
<span
|
||||||
|
className="tempo-panel-count"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-atomic="true"
|
||||||
|
>
|
||||||
|
{requestCount}{' '}
|
||||||
|
{t(
|
||||||
|
requestCount === 1
|
||||||
|
? 'pedido recebido'
|
||||||
|
: 'pedidos recebidos',
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
<nav
|
||||||
|
aria-label="Áreas do portal"
|
||||||
|
className="tempo-section-navigation"
|
||||||
|
>
|
||||||
|
<ul>
|
||||||
|
{groups
|
||||||
|
.filter((group) =>
|
||||||
|
[
|
||||||
|
'discovery',
|
||||||
|
'realization',
|
||||||
|
'support',
|
||||||
|
].includes(group.id),
|
||||||
|
)
|
||||||
|
.map((group) => (
|
||||||
|
<li key={group.id}>
|
||||||
|
<DropdownMenu modal={false}>
|
||||||
|
<DropdownMenuTrigger
|
||||||
|
className="tempo-nav-trigger"
|
||||||
|
data-current-group={
|
||||||
|
current === group.id ||
|
||||||
|
undefined
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t(group.label)}
|
||||||
|
<ChevronDown
|
||||||
|
size={14}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{current === group.id && (
|
||||||
|
<span className="sr-only">
|
||||||
|
Grupo actual
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent
|
||||||
|
align="start"
|
||||||
|
sideOffset={8}
|
||||||
|
collisionPadding={12}
|
||||||
|
className="tempo-dropdown max-h-[min(75vh,36rem)] w-72 max-w-[calc(100vw-1.5rem)] overflow-y-auto p-2"
|
||||||
|
>
|
||||||
|
{items(
|
||||||
|
group.children ?? [],
|
||||||
|
)}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<Link
|
||||||
|
href="/manifestar-interesse"
|
||||||
|
className="tempo-interest-button"
|
||||||
|
>
|
||||||
|
{t('Manifestar interesse')}
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export async function portalRequest<T>(
|
|||||||
const headers = new Headers(options.headers);
|
const headers = new Headers(options.headers);
|
||||||
headers.set('Accept', 'application/json');
|
headers.set('Accept', 'application/json');
|
||||||
if (options.method && !['GET', 'HEAD'].includes(options.method.toUpperCase())) {
|
if (options.method && !['GET', 'HEAD'].includes(options.method.toUpperCase())) {
|
||||||
const token = document.cookie.split('; ').find(value => value.startsWith('XSRF-TOKEN='))?.slice(11);
|
const token = typeof document === 'undefined' ? undefined : document.cookie.split('; ').find(value => value.startsWith('XSRF-TOKEN='))?.slice(11);
|
||||||
if (token) headers.set('X-XSRF-TOKEN', decodeURIComponent(token));
|
if (token) headers.set('X-XSRF-TOKEN', decodeURIComponent(token));
|
||||||
}
|
}
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ function Hero({
|
|||||||
onClick={() => onNavigate('opportunities')}
|
onClick={() => onNavigate('opportunities')}
|
||||||
className="inline-flex items-center gap-2 rounded-lg bg-amber-400 px-5 py-3 font-bold text-[#0B2038] hover:bg-amber-300"
|
className="inline-flex items-center gap-2 rounded-lg bg-amber-400 px-5 py-3 font-bold text-[#0B2038] hover:bg-amber-300"
|
||||||
>
|
>
|
||||||
Explorar oportunidades <ArrowRight size={16} />
|
Consultar oportunidades <ArrowRight size={16} />
|
||||||
</button>
|
</button>
|
||||||
<a
|
<a
|
||||||
href="/simulador-fiscal"
|
href="/simulador-fiscal"
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { AboutStory } from '@/components/institutional-source/AboutStory';
|
|||||||
import { MissionVision } from '@/components/institutional-source/MissionVision';
|
import { MissionVision } from '@/components/institutional-source/MissionVision';
|
||||||
import { CompanyValues } from '@/components/institutional-source/CompanyValues';
|
import { CompanyValues } from '@/components/institutional-source/CompanyValues';
|
||||||
import BackButton from '@/components/institutional-source/BackButton';
|
import BackButton from '@/components/institutional-source/BackButton';
|
||||||
import { AdvertisementSlot } from '@/components/institutional-source/source-advertisement-slot';
|
|
||||||
|
|
||||||
const AboutPage: React.FC = () => {
|
const AboutPage: React.FC = () => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
@@ -45,29 +44,11 @@ const AboutPage: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<AdvertisementSlot
|
|
||||||
page="about"
|
|
||||||
position="top"
|
|
||||||
slot="about_top"
|
|
||||||
limit={1}
|
|
||||||
fallbackToUnslotted
|
|
||||||
className=""
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="text-white">
|
<div className="text-white">
|
||||||
<AboutStory />
|
<AboutStory />
|
||||||
<MissionVision />
|
<MissionVision />
|
||||||
<CompanyValues />
|
<CompanyValues />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AdvertisementSlot
|
|
||||||
page="about"
|
|
||||||
position="bottom"
|
|
||||||
slot="about_bottom"
|
|
||||||
limit={2}
|
|
||||||
fallbackToUnslotted
|
|
||||||
className="py-4"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,13 +2,10 @@
|
|||||||
|
|
||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
class ExampleTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
public function test_that_true_is_true()
|
public function test_that_true_is_true()
|
||||||
{
|
{
|
||||||
$this->assertTrue(true);
|
$this->assertTrue(true);
|
||||||
|
|||||||
@@ -144,6 +144,21 @@ await test('fetch accepts a real server confirmation', async (t) => {
|
|||||||
assert.equal(response.data.reference, 'IR-SERVER-001');
|
assert.equal(response.data.reference, 'IR-SERVER-001');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await test('browser writes preserve the CSRF cookie header', async (t) => {
|
||||||
|
const previous = Object.getOwnPropertyDescriptor(globalThis, 'document');
|
||||||
|
Object.defineProperty(globalThis, 'document', { configurable: true, value: { cookie: 'other=x; XSRF-TOKEN=qa%2Ftoken' } });
|
||||||
|
try {
|
||||||
|
t.mock.method(globalThis, 'fetch', async (_url, options) => {
|
||||||
|
assert.equal(options.headers.get('X-XSRF-TOKEN'), 'qa/token');
|
||||||
|
return new Response('{"success":true}', { status: 201 });
|
||||||
|
});
|
||||||
|
await portalRequest('/api/v1/interest-requests', { method: 'POST' });
|
||||||
|
} finally {
|
||||||
|
if (previous) Object.defineProperty(globalThis, 'document', previous);
|
||||||
|
else delete globalThis.document;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
for (const status of [422, 429, 500]) {
|
for (const status of [422, 429, 500]) {
|
||||||
await test(`HTTP ${status} never becomes a successful confirmation`, async (t) => {
|
await test(`HTTP ${status} never becomes a successful confirmation`, async (t) => {
|
||||||
t.mock.method(
|
t.mock.method(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
|
|||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import {
|
import {
|
||||||
portalNavigation,
|
portalNavigation,
|
||||||
|
legacyPortalNavigation,
|
||||||
currentNavigationGroup,
|
currentNavigationGroup,
|
||||||
currentNavigationItem,
|
currentNavigationItem,
|
||||||
} from '../../resources/js/lib/portal-navigation.ts';
|
} from '../../resources/js/lib/portal-navigation.ts';
|
||||||
@@ -15,7 +16,7 @@ void test('public and authenticated navigation share groups without revealing ma
|
|||||||
assert.deepEqual(publicGroups.slice(0, 3), investor.slice(0, 3));
|
assert.deepEqual(publicGroups.slice(0, 3), investor.slice(0, 3));
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
publicGroups.map((g) => g.id),
|
publicGroups.map((g) => g.id),
|
||||||
['explore', 'prepare', 'support', 'partnerships', 'account'],
|
['discovery', 'realization', 'support', 'account'],
|
||||||
);
|
);
|
||||||
const hrefs = JSON.stringify(investor);
|
const hrefs = JSON.stringify(investor);
|
||||||
assert.equal(hrefs.includes('/management/'), false);
|
assert.equal(hrefs.includes('/management/'), false);
|
||||||
@@ -32,7 +33,7 @@ void test('management and optional modules follow permissions and feature flags'
|
|||||||
education: true,
|
education: true,
|
||||||
ai: true,
|
ai: true,
|
||||||
});
|
});
|
||||||
assert.equal(groups.at(-1).id, 'management');
|
assert.ok(groups.some((group) => group.id === 'management'));
|
||||||
assert.equal(JSON.stringify(groups).includes('/investidor/negocios'), true);
|
assert.equal(JSON.stringify(groups).includes('/investidor/negocios'), true);
|
||||||
assert.equal(JSON.stringify(groups).includes('/management/ai'), true);
|
assert.equal(JSON.stringify(groups).includes('/management/ai'), true);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@@ -48,7 +49,9 @@ void test('management and optional modules follow permissions and feature flags'
|
|||||||
});
|
});
|
||||||
|
|
||||||
void test('detail URLs and filtered catalogue pages retain the current group', () => {
|
void test('detail URLs and filtered catalogue pages retain the current group', () => {
|
||||||
const groups = portalNavigation({ authenticated: true, manager: true });
|
// Preserve the retained catalogue's detail/filter matching independently
|
||||||
|
// of the reconciled shell's new grouping names.
|
||||||
|
const groups = legacyPortalNavigation({ authenticated: true, manager: true });
|
||||||
for (const url of [
|
for (const url of [
|
||||||
'/carteira/project/fixture',
|
'/carteira/project/fixture',
|
||||||
'/zonas?category=zee',
|
'/zonas?category=zee',
|
||||||
@@ -81,3 +84,11 @@ void test('detail URLs and filtered catalogue pages retain the current group', (
|
|||||||
'zee',
|
'zee',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
void test('reconciled navigation selects discovery, realization and private support correctly', () => {
|
||||||
|
const groups = portalNavigation({ authenticated: false, manager: false });
|
||||||
|
assert.equal(currentNavigationGroup(groups, '/oportunidades/fixture'), 'discovery');
|
||||||
|
assert.equal(currentNavigationGroup(groups, '/simulador-fiscal'), 'realization');
|
||||||
|
assert.equal(currentNavigationGroup(groups, '/balcao-virtual/dossiers/fixture'), 'support');
|
||||||
|
assert.equal(currentNavigationGroup(groups, '/management/crm/leads'), null);
|
||||||
|
});
|
||||||
|
|||||||
@@ -114,16 +114,21 @@ void test('business plan values in the dossier equal the existing simulator fore
|
|||||||
const finance = report.sections.find((section) => section.id === 'finance');
|
const finance = report.sections.find((section) => section.id === 'finance');
|
||||||
const row = (field) =>
|
const row = (field) =>
|
||||||
finance.rows.find((item) => item.field === field).value;
|
finance.rows.find((item) => item.field === field).value;
|
||||||
|
const numeric = (value) => {
|
||||||
|
assert.match(value, /MZN$/);
|
||||||
|
return value.replace(/\s|MZN/g, '').replace(',', '.');
|
||||||
|
};
|
||||||
assert.equal(
|
assert.equal(
|
||||||
row('Facturação no horizonte'),
|
numeric(row('Facturação no horizonte')),
|
||||||
`${expected.totalRevenue} MZN`,
|
expected.totalRevenue,
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
row('Resultado antes de impostos'),
|
numeric(row('Resultado antes de impostos')),
|
||||||
`${expected.totalProfitBeforeTax} MZN`,
|
expected.totalProfitBeforeTax,
|
||||||
);
|
);
|
||||||
assert.equal(row('Caixa final projectada'), `${expected.endingCash} MZN`);
|
assert.equal(numeric(row('Caixa final projectada')), expected.endingCash);
|
||||||
assert.equal(row('Reconciliação do financiamento'), expected.fundingStatus);
|
assert.equal(expected.fundingStatus, 'surplus');
|
||||||
|
assert.equal(row('Reconciliação do financiamento'), 'Fontes superiores aos usos previstos');
|
||||||
});
|
});
|
||||||
|
|
||||||
void test('an attached simulator execution keeps its exact snapshot result, explanation and version', () => {
|
void test('an attached simulator execution keeps its exact snapshot result, explanation and version', () => {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ void test('portal home hero exposes a direct public simulator link', () => {
|
|||||||
void test('completed simulator result keeps public interest submission independent', () => {
|
void test('completed simulator result keeps public interest submission independent', () => {
|
||||||
assert.match(simulator, /href="\/manifestar-interesse"/);
|
assert.match(simulator, /href="\/manifestar-interesse"/);
|
||||||
assert.match(
|
assert.match(
|
||||||
simulator,
|
simulator.replace(/\s+/g, ' '),
|
||||||
/Manifestar interesse sem partilhar\s+esta simulação/,
|
/Manifestar interesse sem partilhar esta simulação/,
|
||||||
);
|
);
|
||||||
assert.match(simulator, /sem\s+partilhar os dados desta simulação/);
|
assert.match(simulator.replace(/\s+/g, ' '), /sem partilhar os dados desta simulação/);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user