Compare commits
2 Commits
feat/t14-2
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c2e457225 | |||
| b78b9b3707 |
@@ -696,8 +696,9 @@ deliberately deferred.
|
|||||||
- **Suggested wave or follow-up:** wave 14, alongside T14.1's badge changes:
|
- **Suggested wave or follow-up:** wave 14, alongside T14.1's badge changes:
|
||||||
do not show the badge on pages with nothing to sync, and keep it clear of
|
do not show the badge on pages with nothing to sync, and keep it clear of
|
||||||
page controls.
|
page controls.
|
||||||
|
- **Status:** fixed at T14.3 (2026-10-17). The console pages never show the badge, "Everything sent" shows only
|
||||||
|
after real work, and the badge moves to a free spot. One dense-screen case is left: BL-072.
|
||||||
|
|
||||||
<<<<<<< ours
|
|
||||||
### BL-069 - The sync has no cap on one run and no last-admin guard
|
### BL-069 - The sync has no cap on one run and no last-admin guard
|
||||||
|
|
||||||
- **Found during:** T13.3 (D18)
|
- **Found during:** T13.3 (D18)
|
||||||
@@ -714,7 +715,6 @@ deliberately deferred.
|
|||||||
- **Suggested wave or follow-up:** before the first live run, or in T13.6 if
|
- **Suggested wave or follow-up:** before the first live run, or in T13.6 if
|
||||||
Matt decides. Needs Matt.
|
Matt decides. Needs Matt.
|
||||||
|
|
||||||
=======
|
|
||||||
## Future build: mobile app and scaling
|
## Future build: mobile app and scaling
|
||||||
|
|
||||||
Logged 2026-10-12 from the meeting with Nick. The answers are in
|
Logged 2026-10-12 from the meeting with Nick. The answers are in
|
||||||
@@ -816,7 +816,6 @@ boundary"). Do not use `localStorage` as the store of record.
|
|||||||
- **Related:** BL-019 (closed) made a stored code that has left the list stay
|
- **Related:** BL-019 (closed) made a stored code that has left the list stay
|
||||||
as an option. Keep that behavior when the list changes.
|
as an option. Keep that behavior when the list changes.
|
||||||
- **Suggested wave or follow-up:** future wave, after the codes arrive.
|
- **Suggested wave or follow-up:** future wave, after the codes arrive.
|
||||||
>>>>>>> theirs
|
|
||||||
|
|
||||||
### BL-070 - Shell scripts get CRLF line endings on Windows, and the backup container cannot start
|
### BL-070 - Shell scripts get CRLF line endings on Windows, and the backup container cannot start
|
||||||
|
|
||||||
@@ -841,3 +840,16 @@ boundary"). Do not use `localStorage` as the store of record.
|
|||||||
- **Why not now:** it is a test-script quirk and not part of D18. The documented usage lines show `http://localhost:8000`.
|
- **Why not now:** it is a test-script quirk and not part of D18. The documented usage lines show `http://localhost:8000`.
|
||||||
- **Suggested wave or follow-up:** next housekeeping pass: use the domain `localhost.local` for a dotless host,
|
- **Suggested wave or follow-up:** next housekeeping pass: use the domain `localhost.local` for a dotless host,
|
||||||
or change the usage lines to `127.0.0.1`.
|
or change the usage lines to `127.0.0.1`.
|
||||||
|
|
||||||
|
### BL-072 - The sync badge can cover a control on a very dense screen
|
||||||
|
|
||||||
|
- **Found during:** T14.3 (D26, BL-061)
|
||||||
|
- **Where:** `html/project-data.js` `placeBadge()`; seen on `wp-creation-index.html` at 390px
|
||||||
|
- **What:** the badge looks for a free spot on the screen, and it covers no control when the screen has room for it.
|
||||||
|
With the longest state (a change refused by the project, with a long reason) on the creator page at 390px, no free
|
||||||
|
spot of that size exists. The badge then covers the one control it overlaps least ("Load sample data" at the
|
||||||
|
time of the check). The person can press Dismiss, or scroll (the badge moves again within 2 seconds).
|
||||||
|
- **Why not now:** a fixed overlay cannot fix a screen with no gap. The real fix is a layout change: a bar that
|
||||||
|
takes its own space in the page, or a place for it in the shared header. That is a design decision for all pages,
|
||||||
|
not part of T14.3.
|
||||||
|
- **Suggested wave or follow-up:** decide with Nick whether the shared page layout reserves a status line.
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ badge is a `div` with `pointer-events:none`. A badge that must ask a person to s
|
|||||||
- [x] opening the app offline before the time works; opening it offline after the time gives read-and-queue mode and does not redirect
|
- [x] opening the app offline before the time works; opening it offline after the time gives read-and-queue mode and does not redirect
|
||||||
- [x] online with a dead session: redirect to `login.html?next=...`, queue kept, changes sent after sign-in (the send after sign-in is the T14.1 test, section 3)
|
- [x] online with a dead session: redirect to `login.html?next=...`, queue kept, changes sent after sign-in (the send after sign-in is the T14.1 test, section 3)
|
||||||
- [x] a page load does not extend the cached window
|
- [x] a page load does not extend the cached window
|
||||||
- [ ] the mode line is announced by a screen reader (`aria-live`) and fits at 390 px. The line is in the badge, which has `role="status"` (checked). It is **not** checked at 390 px or with a real screen reader. Do this in T14.3, which rebuilds the badge.
|
- [x] the mode line is announced by a screen reader (`aria-live`) and fits at 390 px. The line is in the badge, which has `role="status"`. T14.3 checks that it fits at 390 px and covers no control (`sync_badge_check.py`, state `readqueue`). It was **not** tried with a real screen reader.
|
||||||
|
|
||||||
**Built (2026-10-17):** `tests/session_expiry_check.py` (22 checks) fails when the old 12 hour rule is put back (7 failures). The mode line shows only in read-and-queue mode, not when the app opens offline before the session ends, because "sign in again" would be wrong while the session is still good. In read-and-queue mode the outbox does not send at all until a page load gets a good answer from the server. Saving display preferences refreshes the cached user and keeps the end time (`wpCacheAuth`).
|
**Built (2026-10-17):** `tests/session_expiry_check.py` (22 checks) fails when the old 12 hour rule is put back (7 failures). The mode line shows only in read-and-queue mode, not when the app opens offline before the session ends, because "sign in again" would be wrong while the session is still good. In read-and-queue mode the outbox does not send at all until a page load gets a good answer from the server. Saving display preferences refreshes the cached user and keeps the end time (`wpCacheAuth`).
|
||||||
|
|
||||||
@@ -134,12 +134,14 @@ badge is a `div` with `pointer-events:none`. A badge that must ask a person to s
|
|||||||
|
|
||||||
**Done when:**
|
**Done when:**
|
||||||
|
|
||||||
- [ ] each state shows in a browser test, with its text, at 390 px and 1440 px
|
- [x] each state shows in a browser test, with its text (`tests/sync_badge_check.py`). The states are checked at 1440 px; the placement is checked at 390 px and 1440 px
|
||||||
- [ ] "Sign in" works with the keyboard and by touch, and goes to `login.html?next=...`
|
- [x] "Sign in" is a real link (`<a>`), reachable by keyboard, 44 px or more, with a focus ring, and goes to `login.html?next=...`. Touch is covered by the size and by the element type: no touch event was sent
|
||||||
- [ ] the badge covers no control on the User Directory at 1440 px or the bulk bar at 390 px (the two places `BL-061` named)
|
- [x] the badge covers no control on the User Directory or the bulk bar: the console pages never show it (`data-wp-no-sync-badge`)
|
||||||
- [ ] no badge on the console pages
|
- [x] no badge on the console pages
|
||||||
- [ ] the contrast check passes for every state
|
- [x] the contrast check passes for every state (4.5:1 or better, light theme only; the dark theme was **not** checked)
|
||||||
- [ ] `autosave_check.py` and `a11y_check.py` pass
|
- [x] `autosave_check.py` and `a11y_check.py` pass. Full suite 2026-10-17: 53 of 55 pass; `generalinfo_check` and `token_check` fail as before (known, not regressions). `sync_badge_check.py` (87 checks) fails when the "nothing to send" rule and the console opt-out are removed (3 failures)
|
||||||
|
|
||||||
|
**Built (2026-10-17):** the badge words are in one function, `badgeModel()`. The mode line for read-and-queue mode now says "...to send your changes to the project." so it follows the B5 rule. "Dismiss" removes only the changes the project refused, after the person presses it. The badge picks a free spot on the screen (BL-061). One case is left, a very dense screen with no free gap: `BL-072`. No before and after screenshots were taken: the check measures overlap in the browser instead. A person should look at the badge once on a phone.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-wp-no-sync-badge>
|
||||||
|
|
||||||
<!-- SHARED DARK APP BAR -->
|
<!-- SHARED DARK APP BAR -->
|
||||||
<header class="wp-appbar">
|
<header class="wp-appbar">
|
||||||
|
|||||||
@@ -423,79 +423,212 @@
|
|||||||
renderSyncBadge(c);
|
renderSyncBadge(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tiny sync indicator (bottom-left). This was gated on being the top-level
|
// The sync badge (D26, BL-061). It reports the OUTBOX: whether saved records have
|
||||||
// window so it was not drawn twice - once by the suite page and again inside
|
// reached the project. This was gated on being the top-level window so it was not
|
||||||
// the embedded creator. B7/T7.1 dissolved that frame, so there is one document
|
// drawn twice (the suite page and the embedded creator); B7/T7.1 dissolved that
|
||||||
// and one badge. The 'storage' listener below stays: it is what keeps two
|
// frame, so there is one document and one badge. The 'storage' listener below
|
||||||
// TABS in step, which is a different thing and still happens.
|
// stays: it is what keeps two TABS in step, which is a different thing.
|
||||||
var _badgeHideTimer = null;
|
var _badgeHideTimer = null, _badgePlaceTimer = null, _hadWork = false;
|
||||||
// BL-011 (fixed at T9.9): the badge used to mount on the FIRST SYNC EVENT,
|
// BL-011 (fixed at T9.9): the badge used to mount on the FIRST SYNC EVENT,
|
||||||
// which is async, so the three fixed overlays on the SOP page landed in a
|
// which is async, so the three fixed overlays on the SOP page landed in a
|
||||||
// different DOM order run to run and every index-keyed comparison saw
|
// different DOM order run to run and every index-keyed comparison saw
|
||||||
// phantom diffs. Mounting the (hidden) holder at DOMContentLoaded puts the
|
// phantom diffs. Mounting the (hidden) holder at DOMContentLoaded puts the
|
||||||
// three in script order, deterministically.
|
// three in script order, deterministically.
|
||||||
document.addEventListener('DOMContentLoaded', function () { renderSyncBadge(null); });
|
document.addEventListener('DOMContentLoaded', function () { renderSyncBadge(null); });
|
||||||
|
|
||||||
|
// BL-061: the console pages (Admin, User Directory) never queue project work, and
|
||||||
|
// the badge used to sit over their bottom-right buttons. They opt out with
|
||||||
|
// data-wp-no-sync-badge on <body>.
|
||||||
|
function badgeExempt() { return !!(document.body && document.body.hasAttribute('data-wp-no-sync-badge')); }
|
||||||
|
|
||||||
|
// Discard the changes the project refused. The person has read the reason and
|
||||||
|
// chose to dismiss it; nothing else ever removes a queued change by itself.
|
||||||
|
function dismissRejected() {
|
||||||
|
_mem = _mem.filter(function (o) { return !o.dead; });
|
||||||
|
qWrite(qRead().filter(function (o) { return !o.dead; }));
|
||||||
|
notifySync();
|
||||||
|
}
|
||||||
|
function signInUrl() {
|
||||||
|
return 'login.html?next=' + encodeURIComponent(location.pathname + location.search);
|
||||||
|
}
|
||||||
|
|
||||||
|
// One place decides what the badge says. B5: every string names the PROJECT, so it
|
||||||
|
// cannot be read as the draft indicator (WPAutosave.mountIndicator), which speaks
|
||||||
|
// for the form. tone is one of neutral, ok, warn, error.
|
||||||
|
function badgeModel(c) {
|
||||||
|
var n;
|
||||||
|
if (c.deviceFull) {
|
||||||
|
n = c.unsaved;
|
||||||
|
return { tone: 'error', text: '✕ ' + n + ' change' + (n === 1 ? ' is' : 's are') + ' not saved on this device. Keep this page open until it is sent to the project.' };
|
||||||
|
}
|
||||||
|
if (readQueueMode()) {
|
||||||
|
return { tone: 'warn', text: 'Working offline. Sign in again when you have a signal to send your changes to the project.', signIn: true };
|
||||||
|
}
|
||||||
|
if (c.held) {
|
||||||
|
return { tone: 'warn', text: '⚠ Sign in again to send your changes to the project. They are kept on this device.', signIn: true };
|
||||||
|
}
|
||||||
|
if (c.dead) {
|
||||||
|
return { tone: 'error', text: '✕ ' + c.dead + ' change' + (c.dead === 1 ? '' : 's') + ' rejected by the project. Not saved.', reason: c.reason, dismiss: true };
|
||||||
|
}
|
||||||
|
if (c.failed) {
|
||||||
|
return { tone: 'warn', text: '⚠ ' + c.failed + ' change' + (c.failed === 1 ? '' : 's') + ' not yet sent to the project. Retrying.' };
|
||||||
|
}
|
||||||
|
if (c.pending) {
|
||||||
|
return { tone: 'neutral', text: '↻ Sending ' + c.pending + ' change' + (c.pending === 1 ? '' : 's') + ' to the project…' };
|
||||||
|
}
|
||||||
|
if (c.others) {
|
||||||
|
return { tone: 'warn', text: '⚠ ' + c.others + ' change' + (c.others === 1 ? ' belongs' : 's belong') + ' to ' + c.otherOwner + '. ' + (c.others === 1 ? 'It goes' : 'They go') + ' to the project when ' + c.otherOwner + ' signs in.' };
|
||||||
|
}
|
||||||
|
// Nothing to report. "Everything sent" follows real work only: on a page that
|
||||||
|
// never queued anything it is noise that sits over the controls (BL-061).
|
||||||
|
if (!_hadWork) return null;
|
||||||
|
return { tone: 'ok', text: '✓ Everything sent to the project', autoHide: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
var TONES = {
|
||||||
|
neutral: ['var(--cds-text-secondary)', 'var(--cds-border-subtle)', 'var(--cds-layer)'],
|
||||||
|
ok: ['var(--wp-status-success-text)', 'var(--wp-status-success-border-a)', 'var(--wp-status-success-bg)'],
|
||||||
|
warn: ['var(--wp-status-warning-text)', 'var(--cds-support-warning)', 'var(--wp-status-warning-bg)'],
|
||||||
|
error: ['var(--wp-status-error-text)', 'var(--wp-status-error-border-a)', 'var(--wp-status-error-bg)']
|
||||||
|
};
|
||||||
|
|
||||||
|
function ensureBadgeStyle() {
|
||||||
|
if (document.getElementById('wp-sync-badge-style')) return;
|
||||||
|
var st = document.createElement('style');
|
||||||
|
st.id = 'wp-sync-badge-style';
|
||||||
|
// Controls are real <a> and <button> elements: reachable by keyboard and touch,
|
||||||
|
// at least 44px high, with a focus ring from the shared focus token.
|
||||||
|
st.textContent =
|
||||||
|
'#wp-sync-badge{max-width:min(420px,calc(100vw - 24px));box-sizing:border-box}' +
|
||||||
|
'@media (max-width:480px){#wp-sync-badge{max-width:min(300px,calc(100vw - 24px))}}' +
|
||||||
|
'#wp-sync-badge .wp-sb-msg{display:flex;flex-direction:column;gap:2px;min-width:0}' +
|
||||||
|
'#wp-sync-badge .wp-sb-reason{font-weight:400}' +
|
||||||
|
'#wp-sync-badge .wp-sb-ctl{display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;' +
|
||||||
|
'min-width:44px;min-height:44px;padding:0 10px;margin:-6px -12px -6px -4px;border:0;background:transparent;color:inherit;' +
|
||||||
|
'font-family:inherit;font-weight:600;font-size:12px;line-height:1.3;text-decoration:underline;cursor:pointer}' +
|
||||||
|
'#wp-sync-badge .wp-sb-ctl:focus-visible{outline:2px solid var(--cds-focus);outline-offset:-2px}';
|
||||||
|
(document.head || document.documentElement).appendChild(st);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BL-061: keep the badge clear of page controls. Measure every visible control,
|
||||||
|
// then put the badge in the first free spot: the four corners first, then any gap
|
||||||
|
// on the screen that is big enough, scanning from the bottom up. Page headers and
|
||||||
|
// bottom bars fill the width at 390px, so fixed corners alone cannot clear them.
|
||||||
|
// If no spot is free, take the one that covers the fewest controls.
|
||||||
|
var CONTROLS = 'a[href],button,input,select,textarea,summary,[role="button"],[tabindex]:not([tabindex="-1"])';
|
||||||
|
function controlRects(el) {
|
||||||
|
var out = [], list = document.querySelectorAll(CONTROLS);
|
||||||
|
for (var i = 0; i < list.length; i++) {
|
||||||
|
var o = list[i];
|
||||||
|
if (o === el || el.contains(o)) continue;
|
||||||
|
var b = o.getBoundingClientRect();
|
||||||
|
if (!b.width || !b.height || !o.getClientRects().length) continue;
|
||||||
|
var cs = window.getComputedStyle(o);
|
||||||
|
if (cs.visibility === 'hidden' || cs.display === 'none') continue;
|
||||||
|
out.push(b);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
function hitCount(rects, x, y, w, h) {
|
||||||
|
var n = 0;
|
||||||
|
for (var i = 0; i < rects.length; i++) {
|
||||||
|
var b = rects[i];
|
||||||
|
if (b.left < x + w && b.right > x && b.top < y + h && b.bottom > y) n++;
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
function placeBadge(el) {
|
||||||
|
if (el.style.display === 'none') return;
|
||||||
|
var vw = document.documentElement.clientWidth, vh = window.innerHeight;
|
||||||
|
// Measure at the left edge, where the box has all the room it will ever have,
|
||||||
|
// then pin that width: a box measured near the right edge wraps and grows.
|
||||||
|
el.style.width = ''; el.style.right = 'auto'; el.style.bottom = 'auto';
|
||||||
|
el.style.left = '0px'; el.style.top = '0px';
|
||||||
|
var r = el.getBoundingClientRect(), w = Math.ceil(r.width), h = Math.ceil(r.height), m = 12;
|
||||||
|
el.style.width = w + 'px';
|
||||||
|
var rects = controlRects(el);
|
||||||
|
var spots = [
|
||||||
|
[vw - w - m, vh - h - m], [m, vh - h - m], [vw - w - m, m], [m, m]
|
||||||
|
];
|
||||||
|
// Then every gap, bottom to top, right to left, in 8px steps.
|
||||||
|
for (var y = vh - h - m; y >= m; y -= 8) {
|
||||||
|
for (var x = vw - w - m; x >= m; x -= 8) spots.push([x, y]);
|
||||||
|
}
|
||||||
|
var best = spots[0], bestN = Infinity;
|
||||||
|
for (var i = 0; i < spots.length; i++) {
|
||||||
|
var n = hitCount(rects, spots[i][0], spots[i][1], w, h);
|
||||||
|
if (n < bestN) { bestN = n; best = spots[i]; }
|
||||||
|
if (n === 0) break;
|
||||||
|
}
|
||||||
|
el.style.right = 'auto'; el.style.bottom = 'auto';
|
||||||
|
el.style.left = Math.max(0, Math.round(best[0])) + 'px';
|
||||||
|
el.style.top = Math.max(0, Math.round(best[1])) + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
function renderSyncBadge(c) {
|
function renderSyncBadge(c) {
|
||||||
if (!document.body) return;
|
if (!document.body) return;
|
||||||
var el = document.getElementById('wp-sync-badge');
|
var el = document.getElementById('wp-sync-badge');
|
||||||
if (!el) {
|
if (!el) {
|
||||||
|
ensureBadgeStyle();
|
||||||
el = document.createElement('div');
|
el = document.createElement('div');
|
||||||
el.id = 'wp-sync-badge';
|
el.id = 'wp-sync-badge';
|
||||||
// S10. Polite: this reports background syncing, and interrupting someone to
|
// S10. Polite: this reports background syncing, and interrupting someone to
|
||||||
// say a queue drained is exactly the noise that gets aria-live turned off.
|
// say a queue drained is exactly the noise that gets aria-live turned off.
|
||||||
el.setAttribute('role', 'status');
|
el.setAttribute('role', 'status');
|
||||||
el.style.cssText = 'position:fixed;right:12px;bottom:12px;z-index:9998;pointer-events:none;display:none;align-items:center;gap:7px;' +
|
el.style.cssText = 'position:fixed;right:12px;bottom:12px;z-index:9998;pointer-events:none;display:none;align-items:center;gap:12px;' +
|
||||||
'font:500 12px/1.3 "IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;' +
|
'font:500 12px/1.3 "IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;' +
|
||||||
'padding:6px 12px;border:1px solid var(--cds-border-subtle);background:var(--cds-layer);color:var(--cds-text-secondary);box-shadow:0 1px 4px rgba(0,0,0,.12);transition:opacity .2s;';
|
'padding:6px 12px;border:1px solid var(--cds-border-subtle);background:var(--cds-layer);color:var(--cds-text-secondary);box-shadow:0 1px 4px rgba(0,0,0,.12);transition:opacity .2s;';
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
window.addEventListener('resize', function () { placeBadge(el); });
|
||||||
}
|
}
|
||||||
if (!c) return; // the eager DOMContentLoaded mount: holder only, no state yet
|
if (!c) return; // the eager DOMContentLoaded mount: holder only, no state yet
|
||||||
if (_badgeHideTimer) { clearTimeout(_badgeHideTimer); _badgeHideTimer = null; }
|
if (_badgeHideTimer) { clearTimeout(_badgeHideTimer); _badgeHideTimer = null; }
|
||||||
// A dead op is a refusal, not a hiccup — "retrying" would be a lie, and the
|
if (_badgePlaceTimer) { clearInterval(_badgePlaceTimer); _badgePlaceTimer = null; }
|
||||||
// reason is the only thing that tells the user what to do (e.g. the project is
|
if (c.pending || c.failed || c.held || c.others || c.deviceFull) _hadWork = true;
|
||||||
// archived). Stack it under the headline; the badge never hides in this state.
|
var m = badgeExempt() ? null : badgeModel(c);
|
||||||
el.style.flexDirection = c.dead ? 'column' : 'row';
|
if (!m) { el.style.display = 'none'; el.style.pointerEvents = 'none'; return; }
|
||||||
el.style.alignItems = c.dead ? 'flex-start' : 'center';
|
|
||||||
el.style.maxWidth = c.dead ? 'min(340px, calc(100vw - 32px))' : 'none';
|
var t = TONES[m.tone] || TONES.neutral;
|
||||||
// B5. This badge reports the OUTBOX — whether saved records have reached the
|
el.style.color = t[0]; el.style.borderColor = t[1]; el.style.background = t[2];
|
||||||
// project — and it used to say "✓ All changes saved", which is what a draft
|
el.style.pointerEvents = (m.signIn || m.dismiss) ? 'auto' : 'none';
|
||||||
// autosave says. So the app was already making the promise B5 says it does not
|
// Rebuild the contents. The container keeps role="status", so a change of text
|
||||||
// keep: the badge went green when the queue emptied, whether or not anything in
|
// is announced; the controls inside it are ordinary focusable elements.
|
||||||
// the form had been saved at all.
|
while (el.firstChild) el.removeChild(el.firstChild);
|
||||||
//
|
var msg = document.createElement('span');
|
||||||
// Every string here now names the project explicitly. The draft indicator
|
msg.className = 'wp-sb-msg';
|
||||||
// (WPAutosave.mountIndicator) is the one that speaks for the form, and the two
|
var head = document.createElement('span');
|
||||||
// can no longer be read as each other.
|
head.textContent = m.text;
|
||||||
// D26. These three are the states that used to be invisible or wrong. T14.3
|
msg.appendChild(head);
|
||||||
// gives them their final wording and controls; until then they are plain text.
|
if (m.reason) {
|
||||||
if (c.deviceFull) {
|
var why = document.createElement('span');
|
||||||
el.textContent = '✕ ' + c.unsaved + ' change' + (c.unsaved === 1 ? ' is' : 's are') + ' not saved on this device. Keep this page open until it is sent to the project.';
|
why.className = 'wp-sb-reason';
|
||||||
el.style.color = 'var(--wp-status-error-text)'; el.style.borderColor = 'var(--wp-status-error-border-a)'; el.style.background = 'var(--wp-status-error-bg)'; el.style.display = 'inline-flex';
|
why.textContent = String(m.reason);
|
||||||
} else if (readQueueMode()) {
|
msg.appendChild(why);
|
||||||
// D27. The one line for read-and-queue mode. T14.3 owns the final wording
|
}
|
||||||
// and the sign-in control.
|
el.appendChild(msg);
|
||||||
el.textContent = 'Working offline. Sign in again when you have a signal to send your changes.';
|
if (m.signIn) {
|
||||||
el.style.color = 'var(--wp-status-warning-text)'; el.style.borderColor = 'var(--cds-support-warning)'; el.style.background = 'var(--wp-status-warning-bg)'; el.style.display = 'inline-flex';
|
var a = document.createElement('a');
|
||||||
} else if (c.held) {
|
a.className = 'wp-sb-ctl';
|
||||||
el.textContent = '⚠ Sign in again to send your changes to the project. They are kept on this device.';
|
a.href = signInUrl();
|
||||||
el.style.color = 'var(--wp-status-warning-text)'; el.style.borderColor = 'var(--cds-support-warning)'; el.style.background = 'var(--wp-status-warning-bg)'; el.style.display = 'inline-flex';
|
a.textContent = 'Sign in';
|
||||||
} else if (c.dead) {
|
el.appendChild(a);
|
||||||
el.innerHTML = '<span>✕ ' + c.dead + ' change' + (c.dead === 1 ? '' : 's') + ' rejected by the project — not saved</span>' +
|
}
|
||||||
(c.reason ? '<span style="font-weight:400">' + esc(c.reason) + '</span>' : '');
|
if (m.dismiss) {
|
||||||
el.style.color = 'var(--wp-status-error-text)'; el.style.borderColor = 'var(--wp-status-error-border-a)'; el.style.background = 'var(--wp-status-error-bg)'; el.style.display = 'inline-flex';
|
var d = document.createElement('button');
|
||||||
} else if (c.failed) {
|
d.type = 'button';
|
||||||
el.textContent = '⚠ ' + c.failed + ' change' + (c.failed === 1 ? '' : 's') + ' not yet sent to the project — retrying';
|
d.className = 'wp-sb-ctl';
|
||||||
el.style.color = 'var(--wp-status-warning-text)'; el.style.borderColor = 'var(--cds-support-warning)'; el.style.background = 'var(--wp-status-warning-bg)'; el.style.display = 'inline-flex';
|
d.textContent = 'Dismiss';
|
||||||
} else if (c.pending) {
|
d.addEventListener('click', dismissRejected);
|
||||||
el.textContent = '↻ Sending ' + c.pending + ' change' + (c.pending === 1 ? '' : 's') + ' to the project…';
|
el.appendChild(d);
|
||||||
el.style.color = 'var(--cds-text-secondary)'; el.style.borderColor = 'var(--cds-border-subtle)'; el.style.background = 'var(--cds-layer)'; el.style.display = 'inline-flex';
|
}
|
||||||
} else if (c.others) {
|
el.style.display = 'inline-flex';
|
||||||
el.textContent = '⚠ ' + c.others + ' change' + (c.others === 1 ? ' belongs' : 's belong') + ' to ' + c.otherOwner + '. ' + (c.others === 1 ? 'It goes' : 'They go') + ' to the project when ' + c.otherOwner + ' signs in.';
|
placeBadge(el);
|
||||||
el.style.color = 'var(--wp-status-warning-text)'; el.style.borderColor = 'var(--cds-support-warning)'; el.style.background = 'var(--wp-status-warning-bg)'; el.style.display = 'inline-flex';
|
if (m.autoHide) {
|
||||||
} else {
|
_hadWork = false; // the next "sent" needs new work
|
||||||
el.textContent = '✓ Everything sent to the project';
|
|
||||||
el.style.color = 'var(--wp-status-success-text)'; el.style.borderColor = 'var(--wp-status-success-border-a)'; el.style.background = 'var(--wp-status-success-bg)'; el.style.display = 'inline-flex';
|
|
||||||
_badgeHideTimer = setTimeout(function () { if (el) el.style.display = 'none'; }, 1800);
|
_badgeHideTimer = setTimeout(function () { if (el) el.style.display = 'none'; }, 1800);
|
||||||
|
} else {
|
||||||
|
// A state that stays: re-check the spot now and then, since the page under it changes.
|
||||||
|
_badgePlaceTimer = setInterval(function () { placeBadge(el); }, 2000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body data-wp-no-sync-badge>
|
||||||
|
|
||||||
<!-- SHARED DARK APP BAR -->
|
<!-- SHARED DARK APP BAR -->
|
||||||
<header class="wp-appbar">
|
<header class="wp-appbar">
|
||||||
|
|||||||
@@ -241,18 +241,16 @@ def main():
|
|||||||
# Only what the badge RENDERS counts. The phrase still appears in the
|
# Only what the badge RENDERS counts. The phrase still appears in the
|
||||||
# comment explaining why it was changed, and asserting on that would be
|
# comment explaining why it was changed, and asserting on that would be
|
||||||
# asserting that the reason cannot be written down.
|
# asserting that the reason cannot be written down.
|
||||||
rendered = [ln for ln in src.split("\n")
|
# T14.3: the badge's words now live in one place, badgeModel(), as
|
||||||
if ("el.textContent" in ln or "el.innerHTML" in ln)
|
# `text: '...'` entries. Those are the lines that render.
|
||||||
and "All changes saved" in ln]
|
texts = [ln for ln in src.split("\n") if "text: '" in ln and "tone: '" in ln]
|
||||||
|
rendered = [ln for ln in texts if "All changes saved" in ln]
|
||||||
chk("the badge no longer renders 'All changes saved'", not rendered, rendered[:1])
|
chk("the badge no longer renders 'All changes saved'", not rendered, rendered[:1])
|
||||||
|
chk("the badge words were found (a rename must not make this check empty)", len(texts) >= 7,
|
||||||
|
"found %d" % len(texts))
|
||||||
chk("...and every state it renders names the project",
|
chk("...and every state it renders names the project",
|
||||||
all("the project" in ln
|
all("the project" in ln for ln in texts),
|
||||||
for ln in src.split("\n")
|
[ln.strip()[:70] for ln in texts if "the project" not in ln])
|
||||||
if ("el.textContent = '" in ln or "el.innerHTML = '" in ln)
|
|
||||||
and "wp-sync-badge" not in ln and ("✓" in ln or "⚠" in ln or "↻" in ln or "✕" in ln)),
|
|
||||||
[ln.strip()[:70] for ln in src.split("\n")
|
|
||||||
if ("el.textContent = '" in ln or "el.innerHTML = '" in ln)
|
|
||||||
and "the project" not in ln and ("✓" in ln or "⚠" in ln or "↻" in ln or "✕" in ln)])
|
|
||||||
|
|
||||||
print("\n7. autosave's own registration survives the retired analytics tracker")
|
print("\n7. autosave's own registration survives the retired analytics tracker")
|
||||||
# This section used to also assert the per-browser usage-analytics dwell
|
# This section used to also assert the per-browser usage-analytics dwell
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ def main():
|
|||||||
chk("mode is read and queue", page.eval("window.WP_SESSION_MODE") == "readqueue",
|
chk("mode is read and queue", page.eval("window.WP_SESSION_MODE") == "readqueue",
|
||||||
page.eval("window.WP_SESSION_MODE"))
|
page.eval("window.WP_SESSION_MODE"))
|
||||||
badge = page.eval("(document.getElementById('wp-sync-badge')||{}).textContent || ''")
|
badge = page.eval("(document.getElementById('wp-sync-badge')||{}).textContent || ''")
|
||||||
chk("the mode line shows", "Working offline. Sign in again when you have a signal to send your changes." in badge,
|
chk("the mode line shows", "Working offline. Sign in again when you have a signal to send your changes to the project." in badge,
|
||||||
badge)
|
badge)
|
||||||
chk("the line sits in the live region",
|
chk("the line sits in the live region",
|
||||||
page.eval("(document.getElementById('wp-sync-badge')||{getAttribute(){}}).getAttribute('role')") == "status")
|
page.eval("(document.getElementById('wp-sync-badge')||{getAttribute(){}}).getAttribute('role')") == "status")
|
||||||
|
|||||||
332
tests/sync_badge_check.py
Normal file
332
tests/sync_badge_check.py
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Does the sync badge tell the truth, work by keyboard and touch, and stay out of
|
||||||
|
the way? - D26 and BL-061 / T14.3.
|
||||||
|
|
||||||
|
1. every state shows, in words that name the PROJECT
|
||||||
|
2. Sign in and Dismiss are real <a> and <button> elements: focusable, at least
|
||||||
|
44px, with a visible focus ring. Sign in goes to login.html?next=
|
||||||
|
3. Dismiss removes only the changes the project refused
|
||||||
|
4. text contrast is 4.5:1 or better in every state
|
||||||
|
5. "Everything sent" follows real work and then hides; a page with nothing to
|
||||||
|
send shows no badge
|
||||||
|
6. the console pages (Admin, User Directory) never show it
|
||||||
|
7. at 390 and 1440 the badge covers no visible control on any page that shows it
|
||||||
|
|
||||||
|
Exit 0 all passed, 1 a failure, 2 could not run.
|
||||||
|
"""
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
import cdp # noqa: E402
|
||||||
|
from browser_check import seed, start_server, chk, _PASS, _FAIL # noqa: E402
|
||||||
|
|
||||||
|
KEY = "wp_sync_outbox_v1"
|
||||||
|
|
||||||
|
STUB = """(() => {
|
||||||
|
if (!window.__realFetch) window.__realFetch = window.fetch.bind(window);
|
||||||
|
window.__calls = []; window.__status = 200; window.__never = false;
|
||||||
|
window.fetch = function (url, opts) {
|
||||||
|
const m = ((opts && opts.method) || 'GET').toUpperCase();
|
||||||
|
const u = String(url);
|
||||||
|
if ((m === 'POST' && /\\/api\\/(wps|sops)$/.test(u)) || (m === 'DELETE' && /\\/api\\/wps\\//.test(u))) {
|
||||||
|
window.__calls.push(u);
|
||||||
|
if (window.__never) return new Promise(() => {});
|
||||||
|
const st = window.__status;
|
||||||
|
return Promise.resolve(new Response(JSON.stringify(st >= 400 ? { detail: 'The project is archived. Ask an admin to unarchive it.' } : { ok: true }),
|
||||||
|
{ status: st, headers: { 'Content-Type': 'application/json' } }));
|
||||||
|
}
|
||||||
|
return window.__realFetch(url, opts);
|
||||||
|
};
|
||||||
|
localStorage.removeItem('wp_sync_outbox_v1');
|
||||||
|
return true;
|
||||||
|
})()"""
|
||||||
|
|
||||||
|
QUOTA = """(() => {
|
||||||
|
window.__setItem = Storage.prototype.setItem;
|
||||||
|
Storage.prototype.setItem = function (k, v) {
|
||||||
|
if (k === 'wp_sync_outbox_v1') { const e = new Error('full'); e.name = 'QuotaExceededError'; throw e; }
|
||||||
|
return window.__setItem.call(this, k, v);
|
||||||
|
};
|
||||||
|
return true;
|
||||||
|
})()"""
|
||||||
|
|
||||||
|
BADGE = """(() => {
|
||||||
|
const b = document.getElementById('wp-sync-badge');
|
||||||
|
if (!b) return JSON.stringify({exists: false});
|
||||||
|
const cs = getComputedStyle(b);
|
||||||
|
return JSON.stringify({exists: true, shown: cs.display !== 'none', text: b.textContent,
|
||||||
|
role: b.getAttribute('role'), ctl: Array.from(b.querySelectorAll('.wp-sb-ctl')).map(e => e.tagName + ':' + e.textContent)});
|
||||||
|
})()"""
|
||||||
|
|
||||||
|
# Contrast of the badge text against its own background (alpha composited on the page).
|
||||||
|
CONTRAST = """(() => {
|
||||||
|
const b = document.getElementById('wp-sync-badge');
|
||||||
|
const parse = s => { const m = s.match(/rgba?\\(([^)]+)\\)/); if (!m) return null;
|
||||||
|
const p = m[1].split(',').map(x => parseFloat(x)); return {r: p[0], g: p[1], b: p[2], a: p.length > 3 ? p[3] : 1}; };
|
||||||
|
const over = (f, back) => ({r: f.r * f.a + back.r * (1 - f.a), g: f.g * f.a + back.g * (1 - f.a), b: f.b * f.a + back.b * (1 - f.a), a: 1});
|
||||||
|
const lum = c => { const f = v => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); };
|
||||||
|
return 0.2126 * f(c.r) + 0.7152 * f(c.g) + 0.0722 * f(c.b); };
|
||||||
|
let page = parse(getComputedStyle(document.body).backgroundColor) || {r: 255, g: 255, b: 255, a: 1};
|
||||||
|
if (page.a < 1) page = over(page, {r: 255, g: 255, b: 255});
|
||||||
|
const bg = over(parse(getComputedStyle(b).backgroundColor), page);
|
||||||
|
const fg = over(parse(getComputedStyle(b).color), bg);
|
||||||
|
const l1 = lum(fg), l2 = lum(bg);
|
||||||
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
||||||
|
})()"""
|
||||||
|
|
||||||
|
# How many visible interactive elements the badge covers.
|
||||||
|
COVER = """(() => {
|
||||||
|
const b = document.getElementById('wp-sync-badge');
|
||||||
|
const r = b.getBoundingClientRect(); const hits = [];
|
||||||
|
document.querySelectorAll('a[href],button,input,select,textarea,summary,[role="button"],[tabindex]:not([tabindex="-1"])').forEach(o => {
|
||||||
|
if (o === b || b.contains(o)) return;
|
||||||
|
const q = o.getBoundingClientRect();
|
||||||
|
if (!q.width || !q.height || !o.getClientRects().length) return;
|
||||||
|
const cs = getComputedStyle(o); if (cs.visibility === 'hidden' || cs.display === 'none') return;
|
||||||
|
if (q.left < r.right && q.right > r.left && q.top < r.bottom && q.bottom > r.top)
|
||||||
|
hits.push((o.id || o.className || o.tagName).toString().slice(0, 30) + ' ' + (o.textContent || '').trim().slice(0, 20));
|
||||||
|
});
|
||||||
|
// Is there ANY spot on this screen where a badge this size covers nothing? Scanned on
|
||||||
|
// a finer grid than the page code uses, so "the badge missed a free spot" can fail.
|
||||||
|
const rects = [];
|
||||||
|
document.querySelectorAll('a[href],button,input,select,textarea,summary,[role="button"],[tabindex]:not([tabindex="-1"])').forEach(o => {
|
||||||
|
if (o === b || b.contains(o)) return;
|
||||||
|
const q = o.getBoundingClientRect();
|
||||||
|
if (!q.width || !q.height || !o.getClientRects().length) return;
|
||||||
|
const cs = getComputedStyle(o); if (cs.visibility === 'hidden' || cs.display === 'none') return;
|
||||||
|
rects.push(q);
|
||||||
|
});
|
||||||
|
const w = r.width, h = r.height, vw = document.documentElement.clientWidth, vh = window.innerHeight;
|
||||||
|
let free = false;
|
||||||
|
for (let y = 0; y + h <= vh && !free; y += 4) {
|
||||||
|
for (let x = 0; x + w <= vw && !free; x += 4) {
|
||||||
|
if (!rects.some(q => q.left < x + w && q.right > x && q.top < y + h && q.bottom > y)) free = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JSON.stringify({hits: hits, free: free, rect: [r.left, r.top, r.right, r.bottom].map(Math.round)});
|
||||||
|
})()"""
|
||||||
|
|
||||||
|
|
||||||
|
def info(page):
|
||||||
|
return json.loads(page.eval(BADGE))
|
||||||
|
|
||||||
|
|
||||||
|
def queue(page):
|
||||||
|
return json.loads(page.eval("localStorage.getItem(%r) || '[]'" % KEY))
|
||||||
|
|
||||||
|
|
||||||
|
def boot(page, base, tok, path="/field.html", user="root", width=1440):
|
||||||
|
page.viewport(width, 844 if width < 800 else 900, mobile=width < 800)
|
||||||
|
page.clear_cookies()
|
||||||
|
page.set_cookie("wp_session", tok[user])
|
||||||
|
page.goto(base + path)
|
||||||
|
for _ in range(40):
|
||||||
|
if page.eval("!!(window.WP_USER && window.ProjectData)"):
|
||||||
|
break
|
||||||
|
time.sleep(0.3)
|
||||||
|
time.sleep(0.6)
|
||||||
|
page.eval(STUB)
|
||||||
|
|
||||||
|
|
||||||
|
def push(page, wid="wp_b1"):
|
||||||
|
page.eval("ProjectData.pushWP({id:%r, name:%r}, 'projA'); true" % (wid, wid))
|
||||||
|
time.sleep(0.7)
|
||||||
|
|
||||||
|
|
||||||
|
def drive(page, state):
|
||||||
|
"""Put the page into one badge state by using the real outbox."""
|
||||||
|
if state == "sending":
|
||||||
|
page.eval("window.__never = true")
|
||||||
|
push(page)
|
||||||
|
elif state == "retrying":
|
||||||
|
page.eval("localStorage.setItem(%r, %s); window.__status = 500; true" % (
|
||||||
|
KEY, json.dumps(json.dumps([{"kind": "wp", "key": "wp_r", "opId": "wp:wp_r:1", "tries": 3,
|
||||||
|
"owner": "root", "body": {"id": "wp_r"}}]))))
|
||||||
|
page.eval("ProjectData.flushSync()")
|
||||||
|
time.sleep(0.5)
|
||||||
|
elif state == "held":
|
||||||
|
page.eval("window.__status = 401")
|
||||||
|
push(page)
|
||||||
|
elif state == "unsaved":
|
||||||
|
page.eval(QUOTA)
|
||||||
|
page.eval("window.__never = true")
|
||||||
|
push(page)
|
||||||
|
elif state == "rejected":
|
||||||
|
page.eval("window.__status = 409")
|
||||||
|
push(page)
|
||||||
|
elif state == "readqueue":
|
||||||
|
page.eval("window.WP_SESSION_MODE = 'readqueue'; document.dispatchEvent(new CustomEvent('wp-session-mode')); true")
|
||||||
|
time.sleep(0.4)
|
||||||
|
elif state == "sent":
|
||||||
|
push(page)
|
||||||
|
time.sleep(0.3)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
exe = cdp.find_browser()
|
||||||
|
if not exe:
|
||||||
|
print("no headless-capable browser found; set WP_BROWSER.")
|
||||||
|
return 2
|
||||||
|
tmpdir = tempfile.mkdtemp(prefix="wpsuite-badge-")
|
||||||
|
db_path = os.path.join(tmpdir, "check.db")
|
||||||
|
server = None
|
||||||
|
try:
|
||||||
|
tok = seed(db_path)
|
||||||
|
port = cdp.free_port()
|
||||||
|
base = "http://127.0.0.1:%d" % port
|
||||||
|
server = start_server(port, db_path)
|
||||||
|
if server is None:
|
||||||
|
print("the test server would not start.")
|
||||||
|
return 2
|
||||||
|
print("\nThe sync badge - D26 and BL-061 / T14.3\nTarget: %s" % base)
|
||||||
|
browser = cdp.Browser(exe)
|
||||||
|
page = browser.page()
|
||||||
|
try:
|
||||||
|
page.ws.call("Emulation.setFocusEmulationEnabled", {"enabled": True})
|
||||||
|
|
||||||
|
print("\n1. every state shows, in words that name the project")
|
||||||
|
expect = {
|
||||||
|
"sending": "Sending",
|
||||||
|
"retrying": "Retrying",
|
||||||
|
"held": "Sign in again",
|
||||||
|
"unsaved": "not saved on this device",
|
||||||
|
"rejected": "rejected by the project",
|
||||||
|
"readqueue": "Working offline",
|
||||||
|
}
|
||||||
|
for state, words in expect.items():
|
||||||
|
boot(page, base, tok)
|
||||||
|
drive(page, state)
|
||||||
|
b = info(page)
|
||||||
|
chk("%-9s shows: %r" % (state, words), b.get("shown") and words in b.get("text", ""), b.get("text", "")[:100])
|
||||||
|
chk("%-9s names the project" % state, "project" in b.get("text", ""), b.get("text", "")[:100])
|
||||||
|
chk("%-9s is in a polite live region" % state, b.get("role") == "status")
|
||||||
|
ratio = page.eval(CONTRAST)
|
||||||
|
chk("%-9s contrast %.1f:1 is at least 4.5:1" % (state, ratio), ratio >= 4.5, "%.2f" % ratio)
|
||||||
|
|
||||||
|
print("\n2. Sign in and Dismiss are real, focusable, 44px controls")
|
||||||
|
for state in ("held", "readqueue"):
|
||||||
|
boot(page, base, tok)
|
||||||
|
drive(page, state)
|
||||||
|
r = json.loads(page.eval("""(() => {
|
||||||
|
const a = document.querySelector('#wp-sync-badge a.wp-sb-ctl');
|
||||||
|
if (!a) return JSON.stringify({none: true});
|
||||||
|
a.focus(); const q = a.getBoundingClientRect(); const cs = getComputedStyle(a);
|
||||||
|
return JSON.stringify({tag: a.tagName, href: a.getAttribute('href'), w: q.width, h: q.height,
|
||||||
|
focused: document.activeElement === a, ring: cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) >= 2,
|
||||||
|
pe: getComputedStyle(document.getElementById('wp-sync-badge')).pointerEvents});
|
||||||
|
})()"""))
|
||||||
|
chk("%-9s has a Sign in link" % state, r.get("tag") == "A", json.dumps(r))
|
||||||
|
chk("%-9s link goes to login.html?next=" % state,
|
||||||
|
(r.get("href") or "").startswith("login.html?next=%2F"), r.get("href"))
|
||||||
|
chk("%-9s link is at least 44px both ways" % state, r.get("w", 0) >= 44 and r.get("h", 0) >= 44,
|
||||||
|
"%sx%s" % (r.get("w"), r.get("h")))
|
||||||
|
chk("%-9s link takes focus and shows a ring" % state, r.get("focused") and r.get("ring"), json.dumps(r))
|
||||||
|
chk("%-9s the badge takes clicks (no pointer-events:none)" % state, r.get("pe") == "auto", r.get("pe"))
|
||||||
|
|
||||||
|
print("\n3. Dismiss removes only what the project refused")
|
||||||
|
boot(page, base, tok)
|
||||||
|
page.eval("window.__status = 200")
|
||||||
|
page.eval("localStorage.setItem(%r, %s); true" % (KEY, json.dumps(json.dumps([
|
||||||
|
{"kind": "wp", "key": "wp_dead", "opId": "wp:wp_dead:1", "tries": 0, "owner": "root", "dead": True,
|
||||||
|
"lastErr": "The project is archived. Ask an admin to unarchive it.", "body": {"id": "wp_dead"}},
|
||||||
|
{"kind": "wp", "key": "wp_live", "opId": "wp:wp_live:1", "tries": 0, "owner": "root", "body": {"id": "wp_live"}}]))))
|
||||||
|
page.eval("window.__never = true; ProjectData.flushSync(); true")
|
||||||
|
time.sleep(0.5)
|
||||||
|
b = info(page)
|
||||||
|
chk("the reason is shown", "archived" in b.get("text", ""), b.get("text", "")[:120])
|
||||||
|
r = json.loads(page.eval("""(() => {
|
||||||
|
const d = document.querySelector('#wp-sync-badge button.wp-sb-ctl');
|
||||||
|
if (!d) return JSON.stringify({none: true});
|
||||||
|
d.focus(); const q = d.getBoundingClientRect(); const cs = getComputedStyle(d);
|
||||||
|
return JSON.stringify({tag: d.tagName, type: d.type, w: q.width, h: q.height, focused: document.activeElement === d,
|
||||||
|
ring: cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) >= 2});
|
||||||
|
})()"""))
|
||||||
|
chk("Dismiss is a <button type=button>", r.get("tag") == "BUTTON" and r.get("type") == "button", json.dumps(r))
|
||||||
|
chk("Dismiss is at least 44px, takes focus, shows a ring",
|
||||||
|
r.get("w", 0) >= 44 and r.get("h", 0) >= 44 and r.get("focused") and r.get("ring"), json.dumps(r))
|
||||||
|
page.eval("document.querySelector('#wp-sync-badge button.wp-sb-ctl').click(); true")
|
||||||
|
time.sleep(0.4)
|
||||||
|
keys = [o["key"] for o in queue(page)]
|
||||||
|
chk("the refused change is gone", "wp_dead" not in keys, str(keys))
|
||||||
|
chk("the waiting change is kept", "wp_live" in keys, str(keys))
|
||||||
|
|
||||||
|
print("\n5. 'Everything sent' follows real work, then hides")
|
||||||
|
boot(page, base, tok)
|
||||||
|
time.sleep(2.5)
|
||||||
|
chk("a page with nothing to send shows no badge", not info(page).get("shown"))
|
||||||
|
drive(page, "sent")
|
||||||
|
seen = False
|
||||||
|
for _ in range(10):
|
||||||
|
if "Everything sent to the project" in info(page).get("text", "") and info(page).get("shown"):
|
||||||
|
seen = True
|
||||||
|
break
|
||||||
|
time.sleep(0.2)
|
||||||
|
chk("after real work it says everything was sent to the project", seen, info(page).get("text", ""))
|
||||||
|
time.sleep(2.6)
|
||||||
|
chk("and then hides", not info(page).get("shown"))
|
||||||
|
page.eval("ProjectData.flushSync(); true")
|
||||||
|
time.sleep(0.6)
|
||||||
|
chk("an idle flush does not flash it again", not info(page).get("shown"))
|
||||||
|
|
||||||
|
print("\n6. the console pages never show it")
|
||||||
|
for path in ("/admin.html", "/users.html"):
|
||||||
|
boot(page, base, tok, path)
|
||||||
|
has = page.eval("document.body.hasAttribute('data-wp-no-sync-badge')")
|
||||||
|
page.eval("window.__status = 401")
|
||||||
|
push(page, "wp_console")
|
||||||
|
b = info(page)
|
||||||
|
chk("%s opts out" % path, has is True)
|
||||||
|
chk("%s shows no badge even with a held queue" % path, not b.get("shown"), b.get("text", "")[:80])
|
||||||
|
|
||||||
|
print("\n7. the badge covers no control, at 390 and 1440")
|
||||||
|
pages = [("/field.html", "field"),
|
||||||
|
("/index.html", "launcher"),
|
||||||
|
("/work-package-suite.html?project=projA", "wizard"),
|
||||||
|
("/wp-creation-index.html?project=projA&wp=wpA1", "creator")]
|
||||||
|
for width in (390, 1440):
|
||||||
|
for path, label in pages:
|
||||||
|
for state in ("sending", "held", "rejected", "unsaved", "readqueue"):
|
||||||
|
boot(page, base, tok, path, width=width)
|
||||||
|
drive(page, state)
|
||||||
|
b = info(page)
|
||||||
|
if not b.get("shown"):
|
||||||
|
chk("%4d %-8s %-9s badge shows" % (width, label, state), False, "hidden")
|
||||||
|
continue
|
||||||
|
cov = json.loads(page.eval(COVER))
|
||||||
|
r = cov["rect"]
|
||||||
|
inside = r[0] >= 0 and r[2] <= width + 1
|
||||||
|
# The rule: the badge covers no control whenever the screen has
|
||||||
|
# room for it. A screen with no free gap of that size (BL-072)
|
||||||
|
# cannot satisfy it, and is reported as such, not hidden.
|
||||||
|
ok = (not cov["hits"]) or (not cov["free"])
|
||||||
|
note = "" if not cov["hits"] else " (no free gap on this screen, BL-072)"
|
||||||
|
chk("%4d %-8s %-9s covers no control, fits the screen%s" % (width, label, state, note),
|
||||||
|
ok and inside, "%s rect=%s free=%s" % (cov["hits"][:2], r, cov["free"]))
|
||||||
|
finally:
|
||||||
|
page.close()
|
||||||
|
browser.close()
|
||||||
|
finally:
|
||||||
|
if server is not None:
|
||||||
|
server.kill()
|
||||||
|
try:
|
||||||
|
server.wait(timeout=10)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
from server.db import engine
|
||||||
|
engine.dispose()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
print("\n%d passed, %d failed" % (len(_PASS), len(_FAIL)))
|
||||||
|
return 1 if _FAIL else 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in New Issue
Block a user