فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(A07): combine native finance E2E with all UI routes, safe backup replay and screenshots
* test(native): combine already passed real financial E2E with ten-route UI, backup replay and screenshot * ci(native): attach real WebView2 dashboard PNG in Windows evidence artifact * docs(native): explain repeatable real Windows VM lab, UI and backup evidence, and unresolved boundaries
davoodmehraban89 committed
Oct 16, 2026 at 19:04 UTC
ecb52f8b707aa713dca7d622ad506fd4fb42ac7d
3 files changed
+80
-4
.github/workflows/windows-vm-native-lab.yml
+1
@@ -68,6 +68,7 @@ jobs:
68
name: phase-a-native-windows-vm-evidence
69
path: |
70
${{ runner.temp }}/factor-easypro-native-vm-lab/reports/*.json
71
+ ${{ runner.temp }}/factor-easypro-native-vm-lab/reports/*.png
72
retention-days: 30
73
if-no-files-found: warn
74
- name: State acceptance boundary
docs/WINDOWS_NATIVE_VM_LAB_FA.md
new
+55
@@ -0,0 +1,55 @@
1
+# آزمایشگاه ویندوز بومی Factor-easyPro
2
+
3
+## هدف و محدوده
4
+این آزمایشگاه روی **Windows VM موقت GitHub Actions** اجرا میشود و فایل نصبکننده واقعی
5
+Tauri/NSIS را نصب و در WebView2 بومی اجرا میکند. از صفحه `vite preview` به جای
6
+برنامه دسکتاپ استفاده نمیشود. هیچ رکورد واقعی مشتری، رمز مشتری یا تغییر در نسخه
7
+عمومی وجود ندارد.
8
+
9
+فایلها:
10
+- `.github/workflows/windows-vm-native-lab.yml` — راهاندازی Windows VM و ثبت شواهد
11
+- `scripts/windows-vm-native-lab.ps1` — نصب NSIS، ارتقای درجا و حذف نسخه آزمایشی
12
+- `scripts/windows-vm-set-candidate.cjs` — افزایش موقت شماره نسخه صرفاً در فضای CI
13
+- `tests/windows-vm-installed-tauri-cdp.cjs` — اتصال به WebView2 و آزمونها
14
+
15
+## روش اجرا
16
+در GitHub Actions، workflow **Phase A Windows VM Native Installer and Upgrade Lab**
17
+را با `workflow_dispatch` اجرا کنید، یا PR تغییردهنده اسکریپتهای فوق بسازید.
18
+هیچ فرآیند برنامهنویسی یا ماشین شخصی نباید روشن بماند.
19
+هر بار یک Windows runner تمیز تخصیص داده میشود.
20
+
21
+## کنترلهای خودکار
22
+۱. اجرای همه تستهای Node و ساخت فرانتاند (از طریق Quality Gates).
23
+۲. ساخت NSIS بومی ویندوز از کد همان PR؛ شماره نسخه کاندید فقط داخل runner تغییر میکند.
24
+۳. دریافت فایل رسمی 2.0.3 و تطبیق SHA256 با checksum منتشرشده.
25
+۴. نصب بیصدا و اجرای واقعی Tauri، ایجاد رمز مدیر آزمایشی، نوشتن رکوردهای مصنوعی
26
+کالا/فاکتور در IndexedDB نسخه ۶.
27
+۵. نصب کاندید روی همان مسیر و همان WebView2 profile و تأیید داده و ورود حفظشده،
28
+مهاجرت ۶ به ۷ و عدم تولید غیرواقعی سابقه حسابرسی.
29
+۶. نصب تازه کاندید با پروفایل مستقل، ساخت مدیر و بررسی Windows DPAPI.
30
+۷. در نصب تازه، ایجاد شخص و کالا از طریق کنترلرهای واقعی، خروجی پشتیبان کامل
31
+بدون فیلدهای رمز، بازپخش بدون تکرار رکورد، و بازکردن هر ۱۰ صفحه اصلی از Router واقعی.
32
+۸. تلاش برای ثبت تصویر PNG محیط بومی و خروجی JSON برای هر سناریو؛
33
+اگر تصویر بهدلیل محدودیت CDP پشتیبانی نشود، صریحاً `UNVERIFIED` ثبت میشود.
34
+۹. پاکسازی فایلهای نصبشده و پروفایلهای موقت با پایان عمر runner.
35
+
36
+## مدرک قابل ارزیابی
37
+هر اجرای CI، artifact با نام `phase-a-native-windows-vm-evidence` را نگه میدارد.
38
+چهار فایل JSON (seed، upgrade، fresh و summary) به همراه تصویر احتمالی PNG
39
+در آن هستند. موفقیت workflow باید بر اساس مقادیر `status=PASSED`،
40
+نتایج مستقل و سبز بودن تمام Quality Gates تأیید شود، نه صرف وجود artifact.
41
+
42
+نمونه اولین اجرای موفق نصب/ارتقا:
43
+[Windows VM run 38920001588](https://github.com/davoodmehraban89/Factor-easyPro/actions/runs/38920001588).
44
+
45
+## محدودیتهای صریح
46
+- این آزمون **نصب واقعی NSIS و استفاده واقعی WebView2** است، ولی کاربر واقعی و
47
+پرینتر فیزیکی ندارد.
48
+- بازپخش یک پشتیبان مصنوعی معادل بازیابی فایل واقعی مشتری یا قطع برق وسط Restore نیست.
49
+- آزمون navigation همه صفحات، تأیید تکتک فرمها و تمام عملیات پیچیده مالی نیست.
50
+- چاپ RTL روی کاغذ، فونتهای سیستم مشتری، نصب روی Windows با محدودیت سازمانی،
51
+مهاجرت فایلهای ناشناخته نسخههای قبل از 2.0.3، و سناریوهای خطای سختافزار
52
+هنوز پذیرش دستی یا آزمایشگاه تخصصی بیشتری میخواهند.
53
+- نسخه رسمی 2.0.3 در فایل `src/main.js` خود برچسب رابط `1.1.1` را بهصورت
54
+ثابت داشت. آزمایشگاه این مغایرت تاریخی را گزارش میکند؛ نسخه کاندید جدید
55
+باید برچسب درست منطبق با فایل manifest نشان بدهد.
tests/windows-vm-installed-tauri-cdp.cjs
+24
-4
@@ -80,16 +80,16 @@ async function connect(url) {
80
if (reply.error) current.reject(Error(JSON.stringify(reply.error)));
81
else current.resolve(reply.result);
82
});
83
- const command = (method, params = {}) => new Promise((resolve, reject) => {
83
+ const command = (method, params = {}, timeoutMs = 12000) => new Promise((resolve, reject) => {
84
const next = ++id;
85
- const timer = setTimeout(() => { pending.delete(next); reject(Error('CDP ' + method + ' timed out')); }, 12000);
85
+ const timer = setTimeout(() => { pending.delete(next); reject(Error('CDP ' + method + ' timed out')); }, timeoutMs);
86
pending.set(next, { resolve, reject, timer });
87
ws.send(JSON.stringify({ id: next, method, params }));
88
});
89
- const evaluate = async expression => {
89
+ const evaluate = async (expression, timeoutMs = 12000) => {
90
const r = await command('Runtime.evaluate', {
91
expression, awaitPromise: true, returnByValue: true
92
- });
92
+ }, timeoutMs);
93
if (r.exceptionDetails) throw Error('Native UI exception: ' + r.exceptionDetails.text);
94
if (r.result?.subtype === 'error') throw Error('Native UI rejected JavaScript evaluation');
95
return r.result?.value;
@@ -294,6 +294,26 @@ async function connect(url) {
294
// verify accounting activation, financial journal, stock, backup and RTL.
295
report.nativeFunctional = await verifyNativeFunctionalMatrix(cdp);
296
}
297
+ if (mode === 'fresh') {
298
+ // Drive synthetic records, complete snapshot replay and every SPA route
299
+ // inside the actually installed Tauri WebView2, not Vite preview.
300
+ const ui = await cdp.evaluate("(async () => {\n const ensure = (pass, message) => { if (!pass) throw Error(message); };\n ensure(!document.getElementById('finoraAuthOverlay'), 'Cannot test UI before login');\n const person = await window.ContactController.create({\n name: 'شخص آزمایشی ماشین مجازی', role: 'both'\n });\n const product = await window.ProductController.createProduct({\n name: 'کالای آزمایشی ماشین مجازی', code: 'WINDOWS-VM-LAB',\n buyPrice: 150, sellPrice: 250, trackInventory: true\n });\n const db = window.FINORA.Storage;\n const before = {\n contacts: (await db.getAll('contacts')).length,\n products: (await db.getAll('products')).length\n };\n ensure((await db.get('contacts',person.id))?.name === 'شخص آزمایشی ماشین مجازی',\n 'Contact did not persist in the native app');\n ensure((await db.get('products',product.id))?.sellPrice === 250,\n 'Product did not persist in the native app');\n const snapshot = await db.exportAll();\n ensure(snapshot.version === 7 && snapshot.app === 'Factor-easyPro',\n 'Native snapshot identity/version mismatch');\n ensure(snapshot.data.users.every(u => !u.pwHash && !u.pwSalt && !u.pass),\n 'Credential hash leaked into plain export');\n ensure(snapshot.data.contacts.some(c => c.id === person.id) &&\n snapshot.data.products.some(p => p.id === product.id),\n 'Native snapshot missing committed master data');\n ensure(await db.importAll(snapshot) === true,\n 'Native full snapshot replay did not succeed');\n const after = {\n contacts: (await db.getAll('contacts')).length,\n products: (await db.getAll('products')).length\n };\n ensure(before.contacts === after.contacts && before.products === after.products,\n 'Snapshot replay duplicated a contact or product');\n const routes = [\n 'dashboard', 'invoices', 'products', 'contacts', 'treasury',\n 'cheques', 'expenses', 'reports', 'accounting', 'settings'\n ];\n const pages = [];\n for (const route of routes) {\n await FINORA.Router.go(route);\n const view = document.getElementById('pageContent');\n const text = (view?.textContent || '').trim();\n ensure(FINORA.Router.current() === route, 'Unexpected route: ' + route);\n ensure(text.length > 10, 'Empty page: ' + route);\n ensure(!text.includes('خطا در بارگذاری صفحه'),\n 'Router reported a page rendering error: ' + route);\n ensure(!document.querySelector('.toast-error'),\n 'Error toast while navigating to: ' + route);\n pages.push({route, renderedCharacters: text.length});\n }\n await FINORA.Router.go('dashboard');\n ensure(!document.getElementById('finoraAuthOverlay'),\n 'Navigation unexpectedly returned to authentication overlay');\n return {masterData:before, backup:'plain-no-credentials-replay-idempotent',\n routes:pages, visibleVersion:FINORA.version};\n})()", 45000);
301
+ assert.equal(ui.routes.length, 10);
302
+ assert.equal(ui.visibleVersion, expectedVersion);
303
+ report.nativeUI = ui;
304
+ try {
305
+ const screen = await cdp.command('Page.captureScreenshot', {
306
+ format: 'png', captureBeyondViewport: false, fromSurface: true
307
+ });
308
+ if (!screen?.data) throw Error('No PNG image data');
309
+ const filename = path.join(path.dirname(reportPath), 'fresh-native-dashboard.png');
310
+ fs.writeFileSync(filename, Buffer.from(screen.data, 'base64'));
311
+ report.screenshot = path.basename(filename);
312
+ } catch (screenshotError) {
313
+ // A screenshot is NOT claimed as verified if native CDP denies it.
314
+ report.screenshot = 'UNVERIFIED: ' + screenshotError.message;
315
+ }
316
+ }
317
report.status = 'PASSED';
318
console.log(JSON.stringify(report, null, 2));
319
} catch (err) {