Mock both configured proxies in UI integration fixture
This commit is contained in:
parent
4f518b3663
commit
43219c49a1
@ -127,14 +127,19 @@ test('full app stays stable across settings, menu, calendar and delayed backgrou
|
||||
await page.route('https://**',r=>r.abort());
|
||||
const handle=async route=>{
|
||||
const url=new URL(route.request().url()),path=url.searchParams.get('__caterium_path')||url.pathname;
|
||||
const headers={'access-control-allow-origin':'*','access-control-allow-headers':'authorization,apikey,content-type,x-client-info','access-control-allow-methods':'GET,POST,OPTIONS'};
|
||||
if(route.request().method()==='OPTIONS')return route.fulfill({status:204,headers});
|
||||
let data=null;
|
||||
if(path==='/auth/v1/user')data=user;
|
||||
else if(path.endsWith('/sun_my_workspaces'))data=[{id:'22222222-2222-4222-8222-222222222222',name:'Тестовая компания',role:'admin',is_active:true,permissions:{}}];
|
||||
else if(path.endsWith('/sun_is_platform_admin'))data=false;
|
||||
else if(path.endsWith('/sun_subscription_snapshot'))data={plan_id:'full',plan_name:'Полный',status:'active',access_mode:'full',features:Object.fromEntries('orders calendar clients catalog_view catalog_edit production shopping stock routes mailings money stats_basic stats_advanced team suppliers print settings branding client_offers offer_templates backups audit users_manage'.split(' ').map(k=>[k,true]))};
|
||||
else if(path.endsWith('/sun_fetch_app_state'))data=url.searchParams.get('select')==='revision'?{revision:1}:[{revision:1,payload:{format:'sun-cloud-v2',version:2,storage:{sunOrders:{t:'j',v:[]},sunBoxes:{t:'j',v:[]}}}}];
|
||||
return route.fulfill({contentType:'application/json',body:JSON.stringify(data)});
|
||||
return route.fulfill({contentType:'application/json',body:JSON.stringify(data),headers});
|
||||
};
|
||||
// The real transport can use either configured proxy while the first document
|
||||
// reloads after workspace discovery. Both belong to this local server fixture.
|
||||
await page.route('**://api.caterium.ru/**',handle);
|
||||
await page.route('**/api/index.php?**',handle);
|
||||
await page.goto('/index.html',{waitUntil:'domcontentloaded'});
|
||||
await expect(page.locator('body > header')).toBeVisible({timeout:20000});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user