File size: 4,228 Bytes
b320573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d2a95e9
b320573
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs/promises');
const {chromium} = require(process.env.PLAYWRIGHT_MODULE || 'playwright');
(async () => {
  const browser = await chromium.launch({headless: true});
  try {
    const context = await browser.newContext({viewport: {width: 1440, height: 1000}});
    const page = await context.newPage();
    const errors = [];
    page.on('pageerror', error => errors.push(error.message));
    await page.goto(process.env.APP_URL || 'http://127.0.0.1:7861/');
    await page.getByRole('button', {name: 'Try a sample review', exact: true}).click();
    assert.equal(await page.locator('#authorization').isChecked(), false, 'sample never grants authorization');
    assert.match(await page.locator('#content').inputValue(), /subprocess/);
    assert.match(await page.locator('#scope').inputValue(), /Fictional sample/);
    await page.locator('#authorization').check();
    await page.locator('#create-form button[type=submit]').click();
    await page.getByRole('button', {name: 'Review next issue', exact: true}).click();
    assert.equal(await page.locator('#confirmation-fields').isVisible(), false);
    await page.locator('#verdict').selectOption('confirmed-static');
    assert.equal(await page.locator('#confirmation-fields').isVisible(), true);
    await page.locator('#verdict').selectOption('rejected');
    assert.equal(await page.locator('#confirmation-fields').isVisible(), false);
    await page.locator('#review-note').fill('Synthetic tutorial review only; rejecting this example to exercise saved decision navigation.');
    await page.locator('#verdict-form button[type=submit]').click();
    await page.getByRole('button', {name: 'Prepare report', exact: true}).click();
    assert.equal(await page.locator('#tab-reports').getAttribute('aria-selected'), 'true');
    console.log('PASS sample authorization, conditional evidence fields and saved-decision report path');
    await page.locator('#nav-overview').click();
    await page.locator('details.quick-start > summary').click();
    await page.getByRole('button', {name: 'Try a sample review', exact: true}).click();
    page.once('dialog', dialog => dialog.accept());
    await page.locator('#workflow').selectOption('exercise');
    await page.locator('#sample').click();
    assert.equal(await page.locator('#assessment-name').inputValue(), 'Sample team exercise');
    await page.locator('#authorization').check();
    await page.locator('#create-form button[type=submit]').click();
    await page.getByRole('button', {name: 'Open role tasks', exact: true}).click();
    assert.equal(await page.locator('#tab-missions').getAttribute('aria-selected'), 'true');
    assert.match(await page.locator('.review-guide').innerText(), /does not establish.*secure/);
    await page.locator('#tab-missions').focus();
    await page.keyboard.press('ArrowRight');
    assert.equal(await page.locator('#tab-coverage').getAttribute('aria-selected'), 'true');
    console.log('PASS zero-issue exercise guidance and keyboard tab navigation');
    await page.locator('#nav-overview').click();
    await page.locator('.workspace-tools summary').focus();
    await page.keyboard.press('Enter');
    assert.equal(await page.getByRole('button', {name: 'Recovery guide', exact: true}).isVisible(), true);
    if (process.env.ARTIFACT_DIR) {
      await fs.mkdir(process.env.ARTIFACT_DIR, {recursive: true});
      await page.locator('.workspace-tools summary').click();
      await page.waitForFunction(() => !document.querySelector('#notice').classList.contains('visible'));
      await page.screenshot({path: process.env.ARTIFACT_DIR + '/usability-desktop.png', fullPage: true});
      await page.setViewportSize({width: 390, height: 844});
      assert.equal(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth + 1), true);
      await page.screenshot({path: process.env.ARTIFACT_DIR + '/usability-mobile.png', fullPage: true});
    }
    assert.deepEqual(errors, []);
    console.log('PASS accessible backup disclosure, mobile overflow and no page errors');
  } finally { await browser.close(); }
})().catch(error => {console.error(error); process.exitCode = 1;});