@davoodmehraban89 / Factor-easy / commits / 3f42dc3
Fork 0

سامانه صدور فاکتور و حسابداری

test: verify CSP-safe Pages bundle binds Commerce and Quick Create event handlers

davoodmehraban89 committed Oct 15, 2026 at 20:54 UTC 3f42dc353eaf4398e2a5dabcfe0cfd0145f36f6c
1 file changed +38
scripts/pages-artifact.spec.js
+38
@@ -142,3 +142,41 @@ test('A blocked required core Pages group prevents opening partial financial wor
142 expect(output.visible).toBe('flex');
143 expect(output.user).toBe(null);
144 });
145 +
146 +
147 +test('Published Pages CSP event bindings open Commerce and the top-bar sales invoice menu',async({page})=>{
148 + const pageErrors=[];
149 + page.on('pageerror',e=>pageErrors.push(e.message));
150 + await page.goto(base,{waitUntil:'domcontentloaded'});
151 + await page.waitForFunction(()=>window.FinoraLoginActionsBound===true&&
152 + typeof window.applyLicensedModuleUI==='function'&&
153 + window.FinoraStartupStatus?.extensionsReady===true,{timeout:20000});
154 + // Synthetic local only; no authenticated production session and no financial writes.
155 + await page.evaluate(()=>{
156 + currentUser={id:'qa-pages-navigation',role:'accountant',
157 + modules:['full_suite'],
158 + subscription:{type:'lifetime',status:'active',endDate:'2099-01-01'}};
159 + document.querySelector('#auth-screen').style.display='none';
160 + applyLicensedModuleUI();
161 + });
162 + const accounting=page.locator('#module-rail [data-module="accounting"]');
163 + const commerce=page.locator('#module-rail [data-module="commerce"]');
164 + await accounting.click();
165 + await expect(page.locator('#view-accounting-foundation')).toHaveClass(/active/);
166 + await commerce.click();
167 + await expect(page.locator('#view-invoices')).toHaveClass(/active/);
168 + await expect(page.locator('#module-panel-title')).toHaveText('بازرگانی');
169 + await expect(page.locator('#module-panel-links')).toContainText('فاکتورها');
170 + await expect(page.locator('#module-panel-links')).toContainText('کالا و خدمات');
171 + // On the hardened Pages build, onclick was replaced by generated CSP-safe handlers.
172 + // Testing raw source index.html alone cannot validate this event-wiring path.
173 + const quick=page.locator('#quick-create-toggle');
174 + await quick.click();
175 + await expect(quick).toHaveAttribute('aria-expanded','true');
176 + await expect(page.locator('#quick-create-menu')).toHaveClass(/open/);
177 + await page.locator('#quick-create-menu button').filter({hasText:'فاکتور فروش'}).click();
178 + await expect(page.locator('#view-invoices')).toHaveClass(/active/);
179 + await expect(page.locator('#quick-create-menu')).not.toHaveClass(/open/);
180 + await expect(quick).toHaveAttribute('aria-expanded','false');
181 + expect(pageErrors).toEqual([]);
182 +});