SharpMeow commited on
Commit
05acee5
·
1 Parent(s): f918b86

Ink Bench: fix a share-link restore race, patient start in the e2e test

Browse files
lib/bench.js CHANGED
@@ -171,7 +171,7 @@ function shareURL() {
171
  async function restoreShare(code) {
172
  const st = JSON.parse(unb64u(code));
173
  if (st.v !== 1) throw new Error('Unknown share link version.');
174
- open('compare');
175
  await selectSegment(st.s);
176
  S.tRef = +st.t[0]; S.tPred = +st.t[1]; S.invert = !!st.i; S.target = st.g || 'ink'; S.model = st.m || { name: '' };
177
  S.ann = (st.an || []).map((a, i) => C.cleanAnnotation({ x: a[0], y: a[1], w: a[2], h: a[3], letter: a[4], confidence: a[5], note: a[6] }, i));
@@ -673,11 +673,13 @@ function renderBoard() {
673
  // ------------------------------------------------------------------ open, close, API
674
 
675
  let opener = null;
676
- async function open(tab = 'compare') {
677
  await loadIndex(); build();
 
678
  opener = document.activeElement;
679
  $('bench').hidden = false; document.body.classList.add('bench-open');
680
- if (!S.seg) await selectSegment(Object.keys(S.index.segments).includes('w046') ? 'w046' : Object.keys(S.index.segments)[0]);
 
681
  showTab(tab);
682
  $('bClose').focus();
683
  }
 
171
  async function restoreShare(code) {
172
  const st = JSON.parse(unb64u(code));
173
  if (st.v !== 1) throw new Error('Unknown share link version.');
174
+ S.seg = null; await open('compare', st.s);
175
  await selectSegment(st.s);
176
  S.tRef = +st.t[0]; S.tPred = +st.t[1]; S.invert = !!st.i; S.target = st.g || 'ink'; S.model = st.m || { name: '' };
177
  S.ann = (st.an || []).map((a, i) => C.cleanAnnotation({ x: a[0], y: a[1], w: a[2], h: a[3], letter: a[4], confidence: a[5], note: a[6] }, i));
 
673
  // ------------------------------------------------------------------ open, close, API
674
 
675
  let opener = null;
676
+ async function open(tab = 'compare', seg = null) {
677
  await loadIndex(); build();
678
+ if (seg && !S.seg) S.seg = seg;
679
  opener = document.activeElement;
680
  $('bench').hidden = false; document.body.classList.add('bench-open');
681
+ if (S.seg && !S.ref) await selectSegment(S.seg);
682
+ else if (!S.seg) await selectSegment(Object.keys(S.index.segments).includes('w046') ? 'w046' : Object.keys(S.index.segments)[0]);
683
  showTab(tab);
684
  $('bClose').focus();
685
  }
tests/__pycache__/synth.cpython-313.pyc CHANGED
Binary files a/tests/__pycache__/synth.cpython-313.pyc and b/tests/__pycache__/synth.cpython-313.pyc differ
 
tests/e2e_bench.py CHANGED
@@ -38,7 +38,7 @@ with sync_playwright() as pw:
38
  p.wait_for_selector('#btnBench', timeout=60000)
39
  p.wait_for_selector('#loader', state='detached', timeout=120000)
40
  p.wait_for_timeout(500)
41
- p.click('#btnBench')
42
  p.wait_for_selector('#bench:not([hidden])')
43
  txt = p.inner_text('#bench')
44
  check('Nothing is uploaded' in txt, 'UI says nothing is uploaded')
@@ -153,7 +153,7 @@ with sync_playwright() as pw:
153
  ct = p.inner_text('#bench')
154
  check('Apache License 2.0' in ct and 'CC BY-NC 4.0' in ct and 'Chase Hendrick' in ct, 'cite panel shows Apache-2.0, CC BY-NC 4.0 and attribution')
155
  p.screenshot(path=os.path.join(shots, 'bench_cite.png'))
156
- p.click('#bClose'); p.wait_for_timeout(200); p.click('#btnInfo'); p.wait_for_timeout(400)
157
  check('Why this matters for researchers' in p.inner_text('#about'), 'About panel has the researchers section')
158
  p.locator('#about .bench-why').scroll_into_view_if_needed(); p.screenshot(path=os.path.join(shots, 'bench_about.png'))
159
  R['api'] = p.evaluate("({ shim: typeof window.unrollBench, viaUnroll: !!(window.unroll && window.unroll.bench), hasUnroll: typeof window.unroll })")
 
38
  p.wait_for_selector('#btnBench', timeout=60000)
39
  p.wait_for_selector('#loader', state='detached', timeout=120000)
40
  p.wait_for_timeout(500)
41
+ p.click('#btnBench', timeout=180000) # software WebGL in headless runs can keep the main thread busy at start
42
  p.wait_for_selector('#bench:not([hidden])')
43
  txt = p.inner_text('#bench')
44
  check('Nothing is uploaded' in txt, 'UI says nothing is uploaded')
 
153
  ct = p.inner_text('#bench')
154
  check('Apache License 2.0' in ct and 'CC BY-NC 4.0' in ct and 'Chase Hendrick' in ct, 'cite panel shows Apache-2.0, CC BY-NC 4.0 and attribution')
155
  p.screenshot(path=os.path.join(shots, 'bench_cite.png'))
156
+ p.click('#bClose'); p.wait_for_timeout(200); p.click('#btnInfo', timeout=120000); p.wait_for_timeout(400)
157
  check('Why this matters for researchers' in p.inner_text('#about'), 'About panel has the researchers section')
158
  p.locator('#about .bench-why').scroll_into_view_if_needed(); p.screenshot(path=os.path.join(shots, 'bench_about.png'))
159
  R['api'] = p.evaluate("({ shim: typeof window.unrollBench, viaUnroll: !!(window.unroll && window.unroll.bench), hasUnroll: typeof window.unroll })")
tools/__pycache__/inkbench.cpython-313.pyc CHANGED
Binary files a/tools/__pycache__/inkbench.cpython-313.pyc and b/tools/__pycache__/inkbench.cpython-313.pyc differ