فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A07): validate 10 real Tauri WebView2 routes and collect optional PNG evidence
davoodmehraban89 committed
Oct 16, 2026 at 18:56 UTC
80477cce70b3bdac677bb25181cbaf08b621cd74
1 file changed
+57
tests/windows-vm-native-routes.cjs
new
+57
@@ -0,0 +1,57 @@
1
+'use strict';
2
+// Native Windows WebView2 SPA route verification and screenshot evidence.
3
+// Runs only after prior functional matrix has created synthetic accounting data.
4
+const assert = require('node:assert/strict');
5
+const fs = require('node:fs');
6
+const path = require('node:path');
7
+
8
+async function inspectNativeRoutes() {
9
+ const ensure = (condition, message) => { if (!condition) throw Error(message); };
10
+ ensure(!document.getElementById('finoraAuthOverlay'), 'Unexpected authentication overlay');
11
+ const routes = [
12
+ 'dashboard', 'invoices', 'products', 'contacts', 'treasury',
13
+ 'cheques', 'expenses', 'reports', 'accounting', 'settings'
14
+ ];
15
+ const pages = [];
16
+ for (const route of routes) {
17
+ await FINORA.Router.go(route);
18
+ const node = document.getElementById('pageContent');
19
+ const content = (node?.textContent || '').trim();
20
+ ensure(FINORA.Router.current() === route, 'Router did not select ' + route);
21
+ ensure(content.length > 10, 'Blank page: ' + route);
22
+ ensure(!content.includes('خطا در بارگذاری صفحه'), 'Page crashed: ' + route);
23
+ ensure(!document.getElementById('finoraAuthOverlay'), 'Auth overlay returned on ' + route);
24
+ pages.push({ route, renderedCharacters: content.length });
25
+ }
26
+ await FINORA.Router.go('dashboard');
27
+ return { routes: pages, allRoutesRendered: pages.length === routes.length,
28
+ version: FINORA.version, nativeLocation: location.protocol };
29
+}
30
+
31
+module.exports = async function verifyNativeRoutes(cdp, expectedVersion, reportPath) {
32
+ const evidence = await cdp.evaluate('(' + inspectNativeRoutes.toString() + ')()', 45000);
33
+ assert.ok(evidence.allRoutesRendered);
34
+ assert.equal(evidence.routes.length, 10);
35
+ assert.equal(evidence.version, expectedVersion);
36
+ let screenshot = 'UNVERIFIED';
37
+ try {
38
+ const img = await cdp.command('Page.captureScreenshot', {
39
+ format: 'png', captureBeyondViewport: false, fromSurface: true
40
+ }, 25000);
41
+ if (!img?.data) throw Error('Native WebView2 did not return screenshot data');
42
+ const png = Buffer.from(img.data, 'base64');
43
+ if (png.length < 2000 || png.toString('ascii', 1, 4) !== 'PNG') {
44
+ throw Error('Invalid native screenshot PNG');
45
+ }
46
+ if (!reportPath) throw Error('No artifact directory configured');
47
+ const filename = path.join(path.dirname(reportPath), 'fresh-native-dashboard.png');
48
+ fs.writeFileSync(filename, png);
49
+ screenshot = path.basename(filename);
50
+ } catch (error) {
51
+ screenshot = 'UNVERIFIED: ' + error.message;
52
+ }
53
+ console.log('NATIVE WINDOWS ROUTES PASSED: ' + JSON.stringify({
54
+ count: evidence.routes.length, screenshot
55
+ }));
56
+ return { ...evidence, screenshot, physicalPrinter: 'not-covered' };
57
+};