feat: update demo video scripts and HTML for improved functionality and user experience
Browse files- scripts/demo_video/README.md +1 -1
- scripts/demo_video/make_takes.py +4 -4
- scripts/demo_video/promo.html +5 -4
- static/index.html +13 -4
- tests/test_learner_home_browser.py +67 -0
scripts/demo_video/README.md
CHANGED
|
@@ -24,7 +24,7 @@ D=scripts/demo_video; .venv/bin/python $D/record.py --takes $D/takes --out $D/ih
|
|
| 24 |
app says "诪爪讜讬谉" and shows no letters to tap; if a scoring change moves it, pick another take in make_takes.py.
|
| 25 |
- The app listens by itself after "next"; the recorder plays the take into the fake mic either way.
|
| 26 |
|
| 27 |
-
## The short promo (
|
| 28 |
|
| 29 |
The opening logo, with "讞讚砖! 讛讗驻诇讬拽爪讬讛 砖诇 讗讛诇讗 讜住讛诇讗" rising under it; the booklet (its cover face on, then lying
|
| 30 |
open, pages flipping to lesson 4's new verbs, the row "讚讬讘专 路 讞讻讗 路 讬讞讻讬" circled); the focused home ("诪讛 注讜砖讬诐
|
|
|
|
| 24 |
app says "诪爪讜讬谉" and shows no letters to tap; if a scoring change moves it, pick another take in make_takes.py.
|
| 25 |
- The app listens by itself after "next"; the recorder plays the take into the fake mic either way.
|
| 26 |
|
| 27 |
+
## The short promo (76 s, a 3D iPhone)
|
| 28 |
|
| 29 |
The opening logo, with "讞讚砖! 讛讗驻诇讬拽爪讬讛 砖诇 讗讛诇讗 讜住讛诇讗" rising under it; the booklet (its cover face on, then lying
|
| 30 |
open, pages flipping to lesson 4's new verbs, the row "讚讬讘专 路 讞讻讗 路 讬讞讻讬" circled); the focused home ("诪讛 注讜砖讬诐
|
scripts/demo_video/make_takes.py
CHANGED
|
@@ -2,9 +2,9 @@
|
|
| 2 |
|
| 3 |
python scripts/demo_video/make_takes.py <out_dir>
|
| 4 |
|
| 5 |
-
m876.wav: 丨賰賶貙 賷丨賰賷 said with 禺 instead of 丨 (a Hebrew speaker's "dirty" 讞'), in
|
| 6 |
-
"讞 (丨) 谞砖诪注讛 讻诪讜 讞' (禺)"
|
| 7 |
-
|
| 8 |
The mistake has to score under 75: from 75 up the app says "诪爪讜讬谉" and shows no letters to tap.
|
| 9 |
TTS_BUCKET is cleared, so these takes don't go into the app's TTS cache bucket.
|
| 10 |
Each take gets 1 s of silence before (the recorder is listening) and 2.5 s after (so it stops by itself).
|
|
@@ -19,7 +19,7 @@ import os
|
|
| 19 |
os.environ["TTS_BUCKET"] = ""
|
| 20 |
from app.tts import load_tts, LINE_VOICES
|
| 21 |
|
| 22 |
-
TAKES = {"m876": ("禺賻賰賻賶貙 賷賽禺賿賰賽賷",
|
| 23 |
|
| 24 |
out = Path(sys.argv[1]); out.mkdir(parents=True, exist_ok=True)
|
| 25 |
tts = load_tts()
|
|
|
|
| 2 |
|
| 3 |
python scripts/demo_video/make_takes.py <out_dir>
|
| 4 |
|
| 5 |
+
m876.wav: 丨賰賶貙 賷丨賰賷 said with 禺 instead of 丨 (a Hebrew speaker's "dirty" 讞'), in Raef's voice: 67 on the POWSM model
|
| 6 |
+
(exports/powsm-ft-shortpad), with "讞 (丨) 谞砖诪注讛 讻诪讜 讞' (禺)" on the 讞 of 賷丨賰賷. c876.wav: said right, also Raef: 100.
|
| 7 |
+
Phrase 876 is "讚讬讘专 (注讘专, 注转讬讚)" (topic "驻注诇讬诐", lesson 4). The takes depend on the model: re-check them after a change.
|
| 8 |
The mistake has to score under 75: from 75 up the app says "诪爪讜讬谉" and shows no letters to tap.
|
| 9 |
TTS_BUCKET is cleared, so these takes don't go into the app's TTS cache bucket.
|
| 10 |
Each take gets 1 s of silence before (the recorder is listening) and 2.5 s after (so it stops by itself).
|
|
|
|
| 19 |
os.environ["TTS_BUCKET"] = ""
|
| 20 |
from app.tts import load_tts, LINE_VOICES
|
| 21 |
|
| 22 |
+
TAKES = {"m876": ("禺賻賰賻賶貙 賷賽禺賿賰賽賷", ""), "c876": ("丨賻賰賻賶貙 賷賽丨賿賰賽賷", "")}
|
| 23 |
|
| 24 |
out = Path(sys.argv[1]); out.mkdir(parents=True, exist_ok=True)
|
| 25 |
tts = load_tts()
|
scripts/demo_video/promo.html
CHANGED
|
@@ -203,6 +203,7 @@ const $=id=>document.getElementById(id);
|
|
| 203 |
// the opening logo, the announcement and the booklet come before the screen; the animated logo closes
|
| 204 |
// the logo stays up while the description rises under it
|
| 205 |
const OPEN_END=4.2, ANN=[1.0,4.2], BOOK0=4.0, BOOK_LEN=7.0, INTRO=BOOK0+BOOK_LEN, CHIPS=0.5, LOGO=6.8, LOGO_SPEED=1.2;
|
|
|
|
| 206 |
const PW=520, PH=716; // a booklet page on the frame
|
| 207 |
const LEAVES=[["cover.jpg",null],["p53.jpg","p54.jpg"],["p55.jpg","p56.jpg"],["p57.jpg","p58.jpg"],["p59.jpg","p60.jpg"]];
|
| 208 |
const ROW={u:.13,v:.293,w:.67,h:.034}; // "讚讬讘专 路 讞讻讗 路 讬讞讻讬" on page 60 (the last leaf's back), as page fractions
|
|
@@ -255,7 +256,7 @@ async function setup(d){
|
|
| 255 |
`<circle cx="540" cy="716" r="18" fill="#2E9C9C" stroke="rgba(0,0,0,.25)" stroke-width="2"/>`+
|
| 256 |
`<path d="M540 732 L522 790 M540 732 L534 794 M540 732 L546 794 M540 732 L558 790" stroke="#B88A3A" stroke-width="5" stroke-linecap="round"/>`;
|
| 257 |
$("mis").innerHTML=mis;
|
| 258 |
-
const S=t=>INTRO+t;
|
| 259 |
const rest={tx:0,ty:0,k:1,rx:4,ry:-16,rz:0}, away={tx:0,ty:1500,k:.9,rx:20,ry:-30,rz:-6};
|
| 260 |
const SUM={tx:0, ty:150, k:.88, rx:3, ry:-9, rz:0};
|
| 261 |
const HOMEV=focus(.5,.5,1.06,540,1200,{ry:-5,rx:2}); // the home's cards, a little closer // beside the summary's pills
|
|
@@ -286,7 +287,7 @@ async function setup(d){
|
|
| 286 |
[S(END)+.7,away],
|
| 287 |
];
|
| 288 |
}
|
| 289 |
-
const duration=()=>INTRO+END+CHIPS+LOGO;
|
| 290 |
|
| 291 |
function stateAt(t){
|
| 292 |
let i=KEYS.findIndex(k=>k[0]>t); if(i<0) return KEYS[KEYS.length-1][1]; if(i===0) return KEYS[0][1];
|
|
@@ -319,7 +320,7 @@ function drawBook(t){
|
|
| 319 |
}
|
| 320 |
async function seek(t){
|
| 321 |
if(scrollX||scrollY) scrollTo(0,0);
|
| 322 |
-
const s=Math.max(0,Math.min(END,t-INTRO)), file=frameAt(s);
|
| 323 |
if(file!==shown){ $("scr").src=file; await $("scr").decode().catch(()=>{}); shown=file; }
|
| 324 |
const p=stateAt(t);
|
| 325 |
$("phone").style.transform=`translate3d(${p.tx}px,${p.ty}px,0) rotateX(${p.rx}deg) rotateY(${p.ry}deg) rotateZ(${p.rz}deg) scale(${p.k})`;
|
|
@@ -327,7 +328,7 @@ async function seek(t){
|
|
| 327 |
$("shadow").style.opacity=Math.max(0,1-Math.max(0,p.ty)/600);
|
| 328 |
$("gloss").style.backgroundPosition=`${p.ry*4}px 0`;
|
| 329 |
// the opening logo, then the headlines, each on its stretch
|
| 330 |
-
const S=x=>INTRO+x;
|
| 331 |
// the opening logo: in, a slow push, out for the announcement
|
| 332 |
const op=Math.min(ease(t/.5),1-ease((t-(OPEN_END-.4))/.5)), up=ease((t-1.0)/.8); // up: the logo's way to the top
|
| 333 |
$("open").style.opacity=op; $("open").style.visibility=op>0?"visible":"hidden"; // drawn only while shown: the logo is heavy (visibility keeps its animations, display would drop them)
|
|
|
|
| 203 |
// the opening logo, the announcement and the booklet come before the screen; the animated logo closes
|
| 204 |
// the logo stays up while the description rises under it
|
| 205 |
const OPEN_END=4.2, ANN=[1.0,4.2], BOOK0=4.0, BOOK_LEN=7.0, INTRO=BOOK0+BOOK_LEN, CHIPS=0.5, LOGO=6.8, LOGO_SPEED=1.2;
|
| 206 |
+
const SLOW=1.15; // the app's screens play 15% slower than recorded, to be read
|
| 207 |
const PW=520, PH=716; // a booklet page on the frame
|
| 208 |
const LEAVES=[["cover.jpg",null],["p53.jpg","p54.jpg"],["p55.jpg","p56.jpg"],["p57.jpg","p58.jpg"],["p59.jpg","p60.jpg"]];
|
| 209 |
const ROW={u:.13,v:.293,w:.67,h:.034}; // "讚讬讘专 路 讞讻讗 路 讬讞讻讬" on page 60 (the last leaf's back), as page fractions
|
|
|
|
| 256 |
`<circle cx="540" cy="716" r="18" fill="#2E9C9C" stroke="rgba(0,0,0,.25)" stroke-width="2"/>`+
|
| 257 |
`<path d="M540 732 L522 790 M540 732 L534 794 M540 732 L546 794 M540 732 L558 790" stroke="#B88A3A" stroke-width="5" stroke-linecap="round"/>`;
|
| 258 |
$("mis").innerHTML=mis;
|
| 259 |
+
const S=t=>INTRO+t*SLOW;
|
| 260 |
const rest={tx:0,ty:0,k:1,rx:4,ry:-16,rz:0}, away={tx:0,ty:1500,k:.9,rx:20,ry:-30,rz:-6};
|
| 261 |
const SUM={tx:0, ty:150, k:.88, rx:3, ry:-9, rz:0};
|
| 262 |
const HOMEV=focus(.5,.5,1.06,540,1200,{ry:-5,rx:2}); // the home's cards, a little closer // beside the summary's pills
|
|
|
|
| 287 |
[S(END)+.7,away],
|
| 288 |
];
|
| 289 |
}
|
| 290 |
+
const duration=()=>INTRO+END*SLOW+CHIPS+LOGO;
|
| 291 |
|
| 292 |
function stateAt(t){
|
| 293 |
let i=KEYS.findIndex(k=>k[0]>t); if(i<0) return KEYS[KEYS.length-1][1]; if(i===0) return KEYS[0][1];
|
|
|
|
| 320 |
}
|
| 321 |
async function seek(t){
|
| 322 |
if(scrollX||scrollY) scrollTo(0,0);
|
| 323 |
+
const s=Math.max(0,Math.min(END,(t-INTRO)/SLOW)), file=frameAt(s); // the app's screens play SLOW times slower
|
| 324 |
if(file!==shown){ $("scr").src=file; await $("scr").decode().catch(()=>{}); shown=file; }
|
| 325 |
const p=stateAt(t);
|
| 326 |
$("phone").style.transform=`translate3d(${p.tx}px,${p.ty}px,0) rotateX(${p.rx}deg) rotateY(${p.ry}deg) rotateZ(${p.rz}deg) scale(${p.k})`;
|
|
|
|
| 328 |
$("shadow").style.opacity=Math.max(0,1-Math.max(0,p.ty)/600);
|
| 329 |
$("gloss").style.backgroundPosition=`${p.ry*4}px 0`;
|
| 330 |
// the opening logo, then the headlines, each on its stretch
|
| 331 |
+
const S=x=>INTRO+x*SLOW;
|
| 332 |
// the opening logo: in, a slow push, out for the announcement
|
| 333 |
const op=Math.min(ease(t/.5),1-ease((t-(OPEN_END-.4))/.5)), up=ease((t-1.0)/.8); // up: the logo's way to the top
|
| 334 |
$("open").style.opacity=op; $("open").style.visibility=op>0?"visible":"hidden"; // drawn only while shown: the logo is heavy (visibility keeps its animations, display would drop them)
|
static/index.html
CHANGED
|
@@ -2385,7 +2385,10 @@ function homeLesson(){ // the current lesson, its topics, and whether every on
|
|
| 2385 |
function homeActions(){ // in this order, the first three that can start: homework, today's video, the lesson, a short round
|
| 2386 |
const {l,cats,done}=homeLesson(), d=today();
|
| 2387 |
const hw=homeworks().filter(h=>!h.t.over).sort((a,b)=>(a.left??1e9)-(b.left??1e9))[0];
|
| 2388 |
-
const vids=dailyVideos().filter(v=>v.date===d&&!dailyWatched[v.id])
|
|
|
|
|
|
|
|
|
|
| 2389 |
const listed=PHRASES.filter(p=>p.listed!==false), said=CATS.filter(c=>!c.story), mine=cats.filter(c=>!c.story);
|
| 2390 |
const plan=LH.shortPlan(listed.filter(p=>said.some(c=>c.id===p.cat)),listed.filter(p=>mine.some(c=>c.id===p.cat)),best,EXCELLENT);
|
| 2391 |
const left=c=>{ const t=topicT(c); return Math.max(1,(t.n||0)-(t.done||0)); }; // what is left of a topic, for its time
|
|
@@ -4389,7 +4392,8 @@ function show(p,wait){ // wait: do not record until the microphone button is p
|
|
| 4389 |
if(c.bubble){ $("prompt").style.animation="none"; void $("prompt").offsetWidth; $("prompt").style.animation=""; }
|
| 4390 |
heStop(); $("heCheck").hidden=true; micZone.classList.toggle("two",heOk&&!!cur.read&&!story); // a phrase to read can be answered in Hebrew too
|
| 4391 |
$("task").textContent=cur.read?heOk?HE_TASK:"拽专讗讜 讘拽讜诇 讜转专讙诪讜 诇注讘专讬转":mine&&c.task||"讗讬讱 讗讜诪专讬诐 讗转 讝讛 讘注专讘讬转 诪讚讜讘专转?";
|
| 4392 |
-
$("catName")
|
|
|
|
| 4393 |
// the number and the bar are the sentence's place in the topic, whatever the round holds
|
| 4394 |
const b=best[cur.id], at=topic.indexOf(cur.id), hintBox=$("doneHint");
|
| 4395 |
$("counter").textContent=ordered?"":`${pos+1} / ${order.length}`;
|
|
@@ -8494,11 +8498,16 @@ if(AUTH_URL){
|
|
| 8494 |
:error.status===429?"谞砖诇讞讜 讬讜转专 诪讚讬 讘拽砖讜转. 谞住讜 砖讜讘 讘注讜讚 讻诪讛 讚拽讜转.":"诇讗 讛爪诇讞谞讜 诇砖诇讜讞 讗转 讛拽讬砖讜专. 讘讚拽讜 讗转 讛讻转讜讘转 讜谞住讜 砖讜讘.");
|
| 8495 |
};
|
| 8496 |
let asked=""; // the account whose permission was already asked; token refreshes do not ask again
|
| 8497 |
-
|
| 8498 |
options:{redirectTo:here,queryParams:{prompt:"select_account"}}});
|
|
|
|
| 8499 |
logout.onclick=$("switchBtn").onclick=async()=>{ // the best scores kept on the device belong to this student
|
| 8500 |
await Promise.race([pushSignOut(),new Promise(r=>setTimeout(r,3000))]);
|
| 8501 |
-
await sb.auth.signOut()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8502 |
$("classExit").onclick=$("pickExit").onclick=()=>logout.click(); // the same exit, from the class pill's dialogs
|
| 8503 |
sb.auth.onAuthStateChange((_e,session)=>{
|
| 8504 |
login.hidden=mail.hidden=$("tagline").hidden=!!session; logout.hidden=$("classExit").hidden=$("pickExit").hidden=!session;
|
|
|
|
| 2385 |
function homeActions(){ // in this order, the first three that can start: homework, today's video, the lesson, a short round
|
| 2386 |
const {l,cats,done}=homeLesson(), d=today();
|
| 2387 |
const hw=homeworks().filter(h=>!h.t.over).sort((a,b)=>(a.left??1e9)-(b.left??1e9))[0];
|
| 2388 |
+
const vids=dailyVideos().filter(v=>v.date===d&&!dailyWatched[v.id]);
|
| 2389 |
+
// Keep following the learner's intent: if they left a topic part-way through, resume it even when an earlier
|
| 2390 |
+
// topic in the lesson is also unfinished. An untouched or completed remembered topic does not change the path.
|
| 2391 |
+
const active=cats.find(c=>c.id===cat&&topicT(c).done>0&&!topicT(c).over), next=active||cats.find(c=>!topicT(c).over);
|
| 2392 |
const listed=PHRASES.filter(p=>p.listed!==false), said=CATS.filter(c=>!c.story), mine=cats.filter(c=>!c.story);
|
| 2393 |
const plan=LH.shortPlan(listed.filter(p=>said.some(c=>c.id===p.cat)),listed.filter(p=>mine.some(c=>c.id===p.cat)),best,EXCELLENT);
|
| 2394 |
const left=c=>{ const t=topicT(c); return Math.max(1,(t.n||0)-(t.done||0)); }; // what is left of a topic, for its time
|
|
|
|
| 4392 |
if(c.bubble){ $("prompt").style.animation="none"; void $("prompt").offsetWidth; $("prompt").style.animation=""; }
|
| 4393 |
heStop(); $("heCheck").hidden=true; micZone.classList.toggle("two",heOk&&!!cur.read&&!story); // a phrase to read can be answered in Hebrew too
|
| 4394 |
$("task").textContent=cur.read?heOk?HE_TASK:"拽专讗讜 讘拽讜诇 讜转专讙诪讜 诇注讘专讬转":mine&&c.task||"讗讬讱 讗讜诪专讬诐 讗转 讝讛 讘注专讘讬转 诪讚讜讘专转?";
|
| 4395 |
+
setTr($("catName"),c.name+(retry&&!daily?" 路 馃攣 住讘讘 讞讜讝专":""));
|
| 4396 |
+
setTr($("lessonName"),lessonName(LESSONS.find(l=>l.id===c.lesson)));
|
| 4397 |
// the number and the bar are the sentence's place in the topic, whatever the round holds
|
| 4398 |
const b=best[cur.id], at=topic.indexOf(cur.id), hintBox=$("doneHint");
|
| 4399 |
$("counter").textContent=ordered?"":`${pos+1} / ${order.length}`;
|
|
|
|
| 8498 |
:error.status===429?"谞砖诇讞讜 讬讜转专 诪讚讬 讘拽砖讜转. 谞住讜 砖讜讘 讘注讜讚 讻诪讛 讚拽讜转.":"诇讗 讛爪诇讞谞讜 诇砖诇讜讞 讗转 讛拽讬砖讜专. 讘讚拽讜 讗转 讛讻转讜讘转 讜谞住讜 砖讜讘.");
|
| 8499 |
};
|
| 8500 |
let asked=""; // the account whose permission was already asked; token refreshes do not ask again
|
| 8501 |
+
const googleSignIn=()=>sb.auth.signInWithOAuth({provider:"google",
|
| 8502 |
options:{redirectTo:here,queryParams:{prompt:"select_account"}}});
|
| 8503 |
+
login.onclick=googleSignIn;
|
| 8504 |
logout.onclick=$("switchBtn").onclick=async()=>{ // the best scores kept on the device belong to this student
|
| 8505 |
await Promise.race([pushSignOut(),new Promise(r=>setTimeout(r,3000))]);
|
| 8506 |
+
const {error}=await sb.auth.signOut().catch(error=>({error}));
|
| 8507 |
+
store.set("ihki.best2",{}); store.set("ihki.silent",{}); store.set("ihki.written",{}); store.set("ihki.unsent",{});
|
| 8508 |
+
if(error) location.replace(here); // at least return to the app's sign-in screen when sign-out or OAuth is unavailable
|
| 8509 |
+
else{ const next=await googleSignIn().catch(error=>({error})); if(next&&next.error) location.replace(here); }
|
| 8510 |
+
};
|
| 8511 |
$("classExit").onclick=$("pickExit").onclick=()=>logout.click(); // the same exit, from the class pill's dialogs
|
| 8512 |
sb.auth.onAuthStateChange((_e,session)=>{
|
| 8513 |
login.hidden=mail.hidden=$("tagline").hidden=!!session; logout.hidden=$("classExit").hidden=$("pickExit").hidden=!session;
|
tests/test_learner_home_browser.py
CHANGED
|
@@ -256,6 +256,34 @@ def test_complete_path_renders_shadda_with_original_accessible_text_on_mobile(si
|
|
| 256 |
assert r["noOverflow"] and r["fallback"] is True
|
| 257 |
|
| 258 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
GOOD_MOMENT = """
|
| 260 |
await sleep(1500);
|
| 261 |
out.before=open("pushDlg");
|
|
@@ -416,6 +444,25 @@ def test_changing_the_lesson_moves_the_home_and_keeps_progress(site):
|
|
| 416 |
assert site.auth.rows[("dana@x.com", 7)]["current_lesson"] == "3"
|
| 417 |
|
| 418 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 419 |
PRIORITY = """
|
| 420 |
await sleep(1500);
|
| 421 |
const titles=()=>[...document.querySelectorAll("#vids .focus-action strong")].map(s=>s.textContent);
|
|
@@ -476,6 +523,26 @@ def test_the_open_service_keeps_the_path(open_site):
|
|
| 476 |
assert r["view"] == "" and r["asked"] is False and r["homeTab"] is False
|
| 477 |
|
| 478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
FINISHED = """
|
| 480 |
await sleep(1500);
|
| 481 |
for(const p of PHRASES) best[p.id]=60; // every sentence said, none excellent: there is something to improve
|
|
|
|
| 256 |
assert r["noOverflow"] and r["fallback"] is True
|
| 257 |
|
| 258 |
|
| 259 |
+
EXERCISE_HEADING_SHADDA = """
|
| 260 |
+
await sleep(1500);
|
| 261 |
+
const headingTopic=CATS.find(c=>!c.story&&!c.bubble&&PHRASES.some(p=>p.cat===c.id));
|
| 262 |
+
const lesson=LESSONS.find(l=>l.id===headingTopic.lesson), phrase=PHRASES.find(p=>p.cat===headingTopic.id);
|
| 263 |
+
headingTopic.name="讻只旨诇賾"; lesson.name="讚址专賾住";
|
| 264 |
+
cat=headingTopic.id; home=false; document.body.classList.remove("home"); setRound(); show(phrase,true);
|
| 265 |
+
await until(()=>document.getElementById("catName").querySelector(".sh"));
|
| 266 |
+
const check=(id,original)=>{
|
| 267 |
+
const el=document.getElementById(id), sh=el.querySelector(".sh"), pseudo=getComputedStyle(sh,"::before");
|
| 268 |
+
return {wrappers:el.querySelectorAll(".sh").length, text:el.textContent, original,
|
| 269 |
+
visible:!!(el.offsetWidth&&el.offsetHeight), mark:{content:pseudo.content,mask:pseudo.maskImage||pseudo.webkitMaskImage}};
|
| 270 |
+
};
|
| 271 |
+
out.topic=check("catName",headingTopic.name); out.lesson=check("lessonName",lesson.name);
|
| 272 |
+
out.noOverflow=document.documentElement.scrollWidth<=innerWidth;
|
| 273 |
+
"""
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
def test_exercise_heading_renders_shadda_on_mobile(site):
|
| 277 |
+
site.auth.rows[("dana@x.com", 7)] = {"current_lesson": "5"}
|
| 278 |
+
r = site("dana@x.com", EXERCISE_HEADING_SHADDA, mobile=True)
|
| 279 |
+
for name in ("topic", "lesson"):
|
| 280 |
+
item = r[name]
|
| 281 |
+
assert item["wrappers"] == 1 and item["visible"]
|
| 282 |
+
assert item["original"].replace("賾", "") in item["text"]
|
| 283 |
+
assert item["mark"]["content"] != "none" and item["mark"]["mask"] != "none"
|
| 284 |
+
assert r["noOverflow"] is True
|
| 285 |
+
|
| 286 |
+
|
| 287 |
GOOD_MOMENT = """
|
| 288 |
await sleep(1500);
|
| 289 |
out.before=open("pushDlg");
|
|
|
|
| 444 |
assert site.auth.rows[("dana@x.com", 7)]["current_lesson"] == "3"
|
| 445 |
|
| 446 |
|
| 447 |
+
RESUME_STARTED_TOPIC = """
|
| 448 |
+
await sleep(1500);
|
| 449 |
+
const lesson=LESSONS.find(l=>l.id===currentLesson()), topics=CATS.filter(c=>c.lesson===lesson.id&&!c.story);
|
| 450 |
+
const started=topics.slice(1).find(c=>PHRASES.some(p=>p.cat===c.id&&p.listed!==false));
|
| 451 |
+
const phrase=started&&PHRASES.find(p=>p.cat===started.id&&p.listed!==false);
|
| 452 |
+
if(!started||!phrase) throw new Error("the current lesson needs two practice topics");
|
| 453 |
+
cat=started.id; store.set("ihki.cat",cat); best[phrase.id]=60; store.set("ihki.best2",best);
|
| 454 |
+
drawNav();
|
| 455 |
+
const action=[...document.querySelectorAll("#vids .focus-action")].find(b=>b.textContent.includes("诪诪砖讬讻讬诐 讘"));
|
| 456 |
+
out.started=started.name; out.proposed=action.querySelector(".focus-detail").textContent;
|
| 457 |
+
"""
|
| 458 |
+
|
| 459 |
+
|
| 460 |
+
def test_home_resumes_the_partly_started_topic_instead_of_the_first_unfinished_one(site):
|
| 461 |
+
site.auth.rows[("dana@x.com", 7)] = {"current_lesson": "5"}
|
| 462 |
+
r = site("dana@x.com", RESUME_STARTED_TOPIC)
|
| 463 |
+
assert r["proposed"] == r["started"]
|
| 464 |
+
|
| 465 |
+
|
| 466 |
PRIORITY = """
|
| 467 |
await sleep(1500);
|
| 468 |
const titles=()=>[...document.querySelectorAll("#vids .focus-action strong")].map(s=>s.textContent);
|
|
|
|
| 523 |
assert r["view"] == "" and r["asked"] is False and r["homeTab"] is False
|
| 524 |
|
| 525 |
|
| 526 |
+
LOG_OUT_TO_GOOGLE = """
|
| 527 |
+
await sleep(200);
|
| 528 |
+
const calls=[];
|
| 529 |
+
pushSignOut=async()=>calls.push("push");
|
| 530 |
+
sb.auth.signOut=async()=>{ calls.push("sign-out"); return {}; };
|
| 531 |
+
sb.auth.signInWithOAuth=async options=>{ calls.push("google"); out.oauth=options; return {}; };
|
| 532 |
+
document.getElementById("classExit").click();
|
| 533 |
+
await until(()=>calls.includes("google"));
|
| 534 |
+
out.calls=calls;
|
| 535 |
+
"""
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
def test_account_exit_signs_out_then_returns_to_google_authentication(site):
|
| 539 |
+
r = site("dana@x.com", LOG_OUT_TO_GOOGLE)
|
| 540 |
+
assert r["calls"] == ["push", "sign-out", "google"]
|
| 541 |
+
assert r["oauth"]["provider"] == "google"
|
| 542 |
+
assert r["oauth"]["options"]["queryParams"] == {"prompt": "select_account"}
|
| 543 |
+
assert r["oauth"]["options"]["redirectTo"].startswith("http")
|
| 544 |
+
|
| 545 |
+
|
| 546 |
FINISHED = """
|
| 547 |
await sleep(1500);
|
| 548 |
for(const p of PHRASES) best[p.id]=60; // every sentence said, none excellent: there is something to improve
|