@@ -1,49 +1,204 @@
|
||||
const {chromium}=require('C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
||||
const fs=require('node:fs');const assert=require('node:assert/strict');
|
||||
const dir='storage/app/private/anchor-project-reconciliation/';
|
||||
const fixture=JSON.parse(fs.readFileSync(dir+'qa-browser-fixture.json'));
|
||||
const base='http://127.0.0.1:18086';
|
||||
(async()=>{
|
||||
const browser=await chromium.launch({headless:true,executablePath:'C:/Users/macbook/AppData/Local/ms-playwright/chromium-1243/chrome-win64/chrome.exe'});
|
||||
try {
|
||||
const context=await browser.newContext();
|
||||
await context.route('**/*',route=>route.request().url().startsWith(base)||route.request().url().startsWith('data:')?route.continue():route.abort());
|
||||
const page=await context.newPage();const errors=[];page.on('pageerror',e=>errors.push(e.message));
|
||||
const response=await page.goto(base+'/carteira/'+fixture.project_dossier,{waitUntil:'networkidle'});
|
||||
assert.equal(response.headers()['x-investmoz-qa-target'],fixture.target);assert.equal(response.status(),200);
|
||||
await page.getByRole('heading',{name:'Localização documentada do projecto',exact:true}).waitFor();
|
||||
for(const text of ['QA province','QA district','QA admin_post','QA locality','32.5'])assert((await page.locator('body').innerText()).includes(text),text);
|
||||
await page.getByRole('link',{name:'Synthetic QA linked opportunity',exact:true}).click();
|
||||
await page.getByRole('link',{name:'Voltar ao dossier: Synthetic QA anchor 1',exact:true}).waitFor();
|
||||
await page.getByRole('link',{name:'Voltar ao dossier: Synthetic QA anchor 1',exact:true}).click();
|
||||
await page.getByRole('heading',{name:'Localização documentada do projecto',exact:true}).waitFor();
|
||||
await page.getByRole('link',{name:'Synthetic QA multi-site cluster',exact:true}).first().click();
|
||||
const geography=page.locator(`[aria-labelledby="documented-geography-${fixture.cluster_dossier}"]`);
|
||||
await geography.getByText('Não existe um ponto único atribuído ao cluster.',{exact:false}).waitFor();
|
||||
assert((await geography.innerText()).includes('2 investimentos com coordenadas disponíveis.'));
|
||||
assert((await geography.innerText()).includes('QA production'));
|
||||
assert((await geography.innerText()).includes('QA processing'));
|
||||
assert.equal(await geography.getByRole('link',{name:/QA-ANCHOR-/}).count(),2);
|
||||
for(const width of [1440,390]){
|
||||
await page.setViewportSize({width,height:1000});
|
||||
assert(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth));
|
||||
await page.screenshot({path:`docs/investmoz/relationships/cluster-${width}.png`,fullPage:true});
|
||||
}
|
||||
const map=await context.request.get(base+'/api/v1/investment/map?province_id='+fixture.province_id);assert.equal(map.headers()['x-investmoz-qa-target'],fixture.target);
|
||||
const data=await map.json();assert.equal(data.matched_count,1);assert.equal(data.georeferenced_count,1);assert.equal(data.features[0].properties.location_basis,'linked_project_site');
|
||||
const detail=await context.request.get(base+'/api/v1/investment/opportunities/'+fixture.opportunity_slug);
|
||||
assert(detail.ok());const json=await detail.json();assert.equal(json.context.projects.length,1);assert.equal(json.context.clusters.length,1);
|
||||
await page.goto(base+'/login',{waitUntil:'networkidle'});
|
||||
await page.locator('input[type=email]').fill('relationship-qa@example.invalid');await page.locator('input[type=password]').fill('QA-Relationship-2026!');
|
||||
await page.locator('button[type=submit]').click();await page.waitForURL(url=>!url.pathname.startsWith('/login'));
|
||||
await page.goto(base+'/management/relationship-repair',{waitUntil:'networkidle'});
|
||||
await page.getByRole('heading',{name:'Localizações: 28',exact:true}).waitFor();
|
||||
await page.getByRole('button',{name:'Aplicar associações fundamentadas',exact:true}).click();
|
||||
await page.getByText(/Associações documentadas aplicadas\.|Este plano já foi aplicado; nenhum duplicado criado\./).waitFor();
|
||||
await page.getByRole('button',{name:'Aplicar associações fundamentadas',exact:true}).click();
|
||||
await page.getByText('Este plano já foi aplicado; nenhum duplicado criado.',{exact:true}).waitFor();
|
||||
assert.deepEqual(errors,[]);
|
||||
fs.writeFileSync('docs/investmoz/relationships/browser-qa.json',JSON.stringify({target:fixture.target,project:fixture.project_dossier,cluster:fixture.cluster_dossier,passed:true,publicNavigation:true,administrativeHierarchy:true,clusterMemberSites:2,clusterSinglePoint:false,territorialMap:true,chainLinks:true,authenticatedPlanApplied:true,replayWithoutDuplicates:true,viewports:[1440,390],errors},null,2));
|
||||
console.log('QA browser passed: public project/cluster/opportunity navigation, hierarchy, two member sites, chains, filters, authenticated 28-location repair and idempotent replay.');
|
||||
}finally{await browser.close();}
|
||||
})().catch(error=>{console.error(error);process.exitCode=1;});
|
||||
const {
|
||||
chromium,
|
||||
} = require('C:/Users/macbook/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
||||
const fs = require('node:fs');
|
||||
const assert = require('node:assert/strict');
|
||||
const dir = 'storage/app/private/anchor-project-reconciliation/';
|
||||
const fixture = JSON.parse(fs.readFileSync(dir + 'qa-browser-fixture.json'));
|
||||
const base = 'http://127.0.0.1:18086';
|
||||
(async () => {
|
||||
const browser = await chromium.launch({
|
||||
headless: true,
|
||||
executablePath:
|
||||
'C:/Users/macbook/AppData/Local/ms-playwright/chromium-1243/chrome-win64/chrome.exe',
|
||||
});
|
||||
try {
|
||||
const context = await browser.newContext();
|
||||
await context.route('**/*', (route) =>
|
||||
route.request().url().startsWith(base) ||
|
||||
route.request().url().startsWith('data:')
|
||||
? route.continue()
|
||||
: route.abort(),
|
||||
);
|
||||
const page = await context.newPage();
|
||||
const errors = [];
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
const response = await page.goto(
|
||||
base + '/carteira/' + fixture.project_dossier,
|
||||
{ waitUntil: 'networkidle' },
|
||||
);
|
||||
assert.equal(
|
||||
response.headers()['x-investmoz-qa-target'],
|
||||
fixture.target,
|
||||
);
|
||||
assert.equal(response.status(), 200);
|
||||
await page
|
||||
.getByRole('heading', {
|
||||
name: 'Localização documentada do projecto',
|
||||
exact: true,
|
||||
})
|
||||
.waitFor();
|
||||
for (const text of [
|
||||
'QA province',
|
||||
'QA district',
|
||||
'QA admin_post',
|
||||
'QA locality',
|
||||
'32.5',
|
||||
])
|
||||
assert(
|
||||
(await page.locator('body').innerText()).includes(text),
|
||||
text,
|
||||
);
|
||||
await page
|
||||
.getByRole('link', {
|
||||
name: 'Synthetic QA linked opportunity',
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await page
|
||||
.getByRole('link', {
|
||||
name: 'Voltar ao dossier: Synthetic QA anchor 1',
|
||||
exact: true,
|
||||
})
|
||||
.waitFor();
|
||||
await page
|
||||
.getByRole('link', {
|
||||
name: 'Voltar ao dossier: Synthetic QA anchor 1',
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await page
|
||||
.getByRole('heading', {
|
||||
name: 'Localização documentada do projecto',
|
||||
exact: true,
|
||||
})
|
||||
.waitFor();
|
||||
await page
|
||||
.getByRole('link', {
|
||||
name: 'Synthetic QA multi-site cluster',
|
||||
exact: true,
|
||||
})
|
||||
.first()
|
||||
.click();
|
||||
const geography = page.locator(
|
||||
`[aria-labelledby="documented-geography-${fixture.cluster_dossier}"]`,
|
||||
);
|
||||
await geography
|
||||
.getByText('Não existe um ponto único atribuído ao cluster.', {
|
||||
exact: false,
|
||||
})
|
||||
.waitFor();
|
||||
assert(
|
||||
(await geography.innerText()).includes(
|
||||
'2 investimentos com coordenadas disponíveis.',
|
||||
),
|
||||
);
|
||||
assert((await geography.innerText()).includes('QA production'));
|
||||
assert((await geography.innerText()).includes('QA processing'));
|
||||
assert.equal(
|
||||
await geography.getByRole('link', { name: /QA-ANCHOR-/ }).count(),
|
||||
2,
|
||||
);
|
||||
for (const width of [1440, 390]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
assert(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= innerWidth,
|
||||
),
|
||||
);
|
||||
await page.screenshot({
|
||||
path: `docs/investmoz/relationships/cluster-${width}.png`,
|
||||
fullPage: true,
|
||||
});
|
||||
}
|
||||
const map = await context.request.get(
|
||||
base + '/api/v1/investment/map?province_id=' + fixture.province_id,
|
||||
);
|
||||
assert.equal(map.headers()['x-investmoz-qa-target'], fixture.target);
|
||||
const data = await map.json();
|
||||
assert.equal(data.matched_count, 1);
|
||||
assert.equal(data.georeferenced_count, 1);
|
||||
assert.equal(
|
||||
data.features[0].properties.location_basis,
|
||||
'linked_project_site',
|
||||
);
|
||||
const detail = await context.request.get(
|
||||
base +
|
||||
'/api/v1/investment/opportunities/' +
|
||||
fixture.opportunity_slug,
|
||||
);
|
||||
assert(detail.ok());
|
||||
const json = await detail.json();
|
||||
assert.equal(json.context.projects.length, 1);
|
||||
assert.equal(json.context.clusters.length, 1);
|
||||
await page.goto(base + '/login', { waitUntil: 'networkidle' });
|
||||
await page
|
||||
.locator('input[type=email]')
|
||||
.fill('relationship-qa@example.invalid');
|
||||
await page
|
||||
.locator('input[type=password]')
|
||||
.fill('QA-Relationship-2026!');
|
||||
await page.locator('button[type=submit]').click();
|
||||
await page.waitForURL((url) => !url.pathname.startsWith('/login'));
|
||||
await page.goto(base + '/management/relationship-repair', {
|
||||
waitUntil: 'networkidle',
|
||||
});
|
||||
await page
|
||||
.getByRole('heading', { name: 'Localizações: 28', exact: true })
|
||||
.waitFor();
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'Aplicar associações fundamentadas',
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await page
|
||||
.getByText(
|
||||
/Associações documentadas aplicadas\.|Este plano já foi aplicado; nenhum duplicado criado\./,
|
||||
)
|
||||
.waitFor();
|
||||
await page
|
||||
.getByRole('button', {
|
||||
name: 'Aplicar associações fundamentadas',
|
||||
exact: true,
|
||||
})
|
||||
.click();
|
||||
await page
|
||||
.getByText('Este plano já foi aplicado; nenhum duplicado criado.', {
|
||||
exact: true,
|
||||
})
|
||||
.waitFor();
|
||||
assert.deepEqual(errors, []);
|
||||
fs.writeFileSync(
|
||||
'docs/investmoz/relationships/browser-qa.json',
|
||||
JSON.stringify(
|
||||
{
|
||||
target: fixture.target,
|
||||
project: fixture.project_dossier,
|
||||
cluster: fixture.cluster_dossier,
|
||||
passed: true,
|
||||
publicNavigation: true,
|
||||
administrativeHierarchy: true,
|
||||
clusterMemberSites: 2,
|
||||
clusterSinglePoint: false,
|
||||
territorialMap: true,
|
||||
chainLinks: true,
|
||||
authenticatedPlanApplied: true,
|
||||
replayWithoutDuplicates: true,
|
||||
viewports: [1440, 390],
|
||||
errors,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
console.log(
|
||||
'QA browser passed: public project/cluster/opportunity navigation, hierarchy, two member sites, chains, filters, authenticated 28-location repair and idempotent replay.',
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
})().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user