Compare commits
No commits in common. "941a508d4b48fa411b1c91e92d81369a515d6019" and "b4a5401b22b70a35b39dca2c88315a31ed521ce4" have entirely different histories.
941a508d4b
...
b4a5401b22
|
|
@ -143,7 +143,6 @@
|
||||||
const mobileFirstTask = createMobileFirstTask({
|
const mobileFirstTask = createMobileFirstTask({
|
||||||
getLogin: () => confirmedOwnerLogin,
|
getLogin: () => confirmedOwnerLogin,
|
||||||
hasWork: () => todayMyWork.length > 0 || activeMyWork.length > 0,
|
hasWork: () => todayMyWork.length > 0 || activeMyWork.length > 0,
|
||||||
isTodayActive: () => workSession.checkpointed(),
|
|
||||||
});
|
});
|
||||||
mobileFirstTask.start();
|
mobileFirstTask.start();
|
||||||
const mobileWorkEntry = createMobileWorkEntry({
|
const mobileWorkEntry = createMobileWorkEntry({
|
||||||
|
|
|
||||||
|
|
@ -1838,8 +1838,8 @@
|
||||||
<p class="small">Choose work, start it, then return to Work whenever you want to continue.</p>
|
<p class="small">Choose work, start it, then return to Work whenever you want to continue.</p>
|
||||||
<p id="mobile-first-task-status" class="small" role="status" aria-live="polite"></p>
|
<p id="mobile-first-task-status" class="small" role="status" aria-live="polite"></p>
|
||||||
<div class="mobile-first-task-actions">
|
<div class="mobile-first-task-actions">
|
||||||
<button id="mobile-first-task-find" type="button">Find & start</button>
|
<button id="mobile-first-task-find" type="button">Find a task</button>
|
||||||
<button id="mobile-first-task-create" type="button">Create & start</button>
|
<button id="mobile-first-task-create" type="button">Create a task</button>
|
||||||
<button id="mobile-first-task-setup" type="button">Make this phone work-ready</button>
|
<button id="mobile-first-task-setup" type="button">Make this phone work-ready</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,11 @@
|
||||||
mediaQuery: win?.matchMedia('(max-width: 600px)') || {matches:false},
|
mediaQuery: win?.matchMedia('(max-width: 600px)') || {matches:false},
|
||||||
eventTarget: win,
|
eventTarget: win,
|
||||||
sheet: doc?.querySelector('#mobile-first-task'),
|
sheet: doc?.querySelector('#mobile-first-task'),
|
||||||
title: doc?.querySelector('#mobile-first-task-title'),
|
|
||||||
findButton: doc?.querySelector('#mobile-first-task-find'),
|
findButton: doc?.querySelector('#mobile-first-task-find'),
|
||||||
createButton: doc?.querySelector('#mobile-first-task-create'),
|
createButton: doc?.querySelector('#mobile-first-task-create'),
|
||||||
setupButton: doc?.querySelector('#mobile-first-task-setup'),
|
setupButton: doc?.querySelector('#mobile-first-task-setup'),
|
||||||
closeButton: doc?.querySelector('#close-mobile-first-task'),
|
closeButton: doc?.querySelector('#close-mobile-first-task'),
|
||||||
status: doc?.querySelector('#mobile-first-task-status'),
|
status: doc?.querySelector('#mobile-first-task-status'),
|
||||||
isTodayActive: () => false,
|
|
||||||
onFind: () => doc?.querySelector('#find-work')?.click(),
|
onFind: () => doc?.querySelector('#find-work')?.click(),
|
||||||
onCreate: () => doc?.querySelector('#new-issue')?.click(),
|
onCreate: () => doc?.querySelector('#new-issue')?.click(),
|
||||||
onSetup: () => doc?.querySelector('#open-device-setup')?.click(),
|
onSetup: () => doc?.querySelector('#open-device-setup')?.click(),
|
||||||
|
|
@ -40,7 +38,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function required() {
|
function required() {
|
||||||
return Boolean(options.mediaQuery.matches && account() && !options.isTodayActive() && !completed());
|
return Boolean(options.mediaQuery.matches && account() && !options.hasWork() && !completed());
|
||||||
}
|
}
|
||||||
|
|
||||||
function markComplete() {
|
function markComplete() {
|
||||||
|
|
@ -52,14 +50,9 @@
|
||||||
|
|
||||||
function render() {
|
function render() {
|
||||||
const online = options.isOnline();
|
const online = options.isOnline();
|
||||||
const awaitingStart = options.hasWork();
|
|
||||||
options.findButton.disabled = !online;
|
options.findButton.disabled = !online;
|
||||||
if (options.title) options.title.textContent = awaitingStart ? 'Finish starting your first task' : 'Start your first task';
|
options.status.textContent = online ?
|
||||||
options.findButton.textContent = 'Find & start';
|
'Choose a task to claim or create one of your own.' :
|
||||||
options.createButton.textContent = 'Create & start';
|
|
||||||
options.status.textContent = awaitingStart ?
|
|
||||||
'Your task is ready. Start it from Find or create and start another task.' : online ?
|
|
||||||
'Choose a task to claim and start, or create and start one of your own.' :
|
|
||||||
'You are offline. Create a task now and it will stay in Drafts until you reconnect.';
|
'You are offline. Create a task now and it will stay in Drafts until you reconnect.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,13 +65,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function refresh() {
|
function refresh() {
|
||||||
if (account() && options.isTodayActive() && !completed()) {
|
if (account() && options.hasWork() && !completed()) {
|
||||||
markComplete();
|
markComplete();
|
||||||
if (options.sheet.open) options.sheet.close();
|
if (options.sheet.open) options.sheet.close();
|
||||||
return 'completed';
|
return 'completed';
|
||||||
}
|
}
|
||||||
if (options.sheet.open) render();
|
if (options.sheet.open) render();
|
||||||
if (required() && options.hasWork()) return 'awaiting-start';
|
|
||||||
return required() ? 'required' : 'inactive';
|
return required() ? 'required' : 'inactive';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class Element {{
|
||||||
return json.loads(result.stdout)
|
return json.loads(result.stdout)
|
||||||
|
|
||||||
|
|
||||||
def test_first_task_activation_is_account_bound_and_completes_only_when_today_is_active():
|
def test_first_task_activation_is_account_bound_and_completes_when_work_appears():
|
||||||
result = run_node(
|
result = run_node(
|
||||||
"""
|
"""
|
||||||
const values = new Map();
|
const values = new Map();
|
||||||
|
|
@ -36,30 +36,24 @@ const storage = {getItem:key => values.get(key) || null, setItem:(key,value) =>
|
||||||
const sheet = new Element();
|
const sheet = new Element();
|
||||||
let login = 'Timmy';
|
let login = 'Timmy';
|
||||||
let hasWork = false;
|
let hasWork = false;
|
||||||
let todayActive = false;
|
|
||||||
const controller = createFirstTask({
|
const controller = createFirstTask({
|
||||||
storage, getLogin:() => login, hasWork:() => hasWork, isTodayActive:() => todayActive,
|
storage, getLogin:() => login, hasWork:() => hasWork, isOnline:() => true,
|
||||||
isOnline:() => true, mediaQuery:{matches:true}, sheet, title:new Element(),
|
mediaQuery:{matches:true}, sheet, findButton:new Element(), createButton:new Element(),
|
||||||
findButton:new Element(), createButton:new Element(), setupButton:new Element(),
|
setupButton:new Element(), closeButton:new Element(), status:new Element(),
|
||||||
closeButton:new Element(), status:new Element(), onFind() {}, onCreate() {}, onSetup() {},
|
onFind() {}, onCreate() {}, onSetup() {},
|
||||||
});
|
});
|
||||||
const before = [controller.required(), controller.open(), sheet.open];
|
const before = [controller.required(), controller.open(), sheet.open];
|
||||||
hasWork = true;
|
hasWork = true;
|
||||||
const awaitingStart = controller.refresh();
|
|
||||||
const stillRequired = controller.required();
|
|
||||||
todayActive = true;
|
|
||||||
const completed = controller.refresh();
|
const completed = controller.refresh();
|
||||||
const timmyRequired = controller.required();
|
const timmyRequired = controller.required();
|
||||||
login = 'alexander'; hasWork = false; todayActive = false;
|
login = 'alexander'; hasWork = false;
|
||||||
const alexanderRequired = controller.required();
|
const alexanderRequired = controller.required();
|
||||||
process.stdout.write(JSON.stringify({before, awaitingStart, stillRequired, completed, sheetOpen:sheet.open, timmyRequired, alexanderRequired, values:[...values]}));
|
process.stdout.write(JSON.stringify({before, completed, sheetOpen:sheet.open, timmyRequired, alexanderRequired, values:[...values]}));
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
assert result == {
|
assert result == {
|
||||||
"before": [True, True, True],
|
"before": [True, True, True],
|
||||||
"awaitingStart": "awaiting-start",
|
|
||||||
"stillRequired": True,
|
|
||||||
"completed": "completed",
|
"completed": "completed",
|
||||||
"sheetOpen": False,
|
"sheetOpen": False,
|
||||||
"timmyRequired": False,
|
"timmyRequired": False,
|
||||||
|
|
@ -68,37 +62,6 @@ process.stdout.write(JSON.stringify({before, awaitingStart, stillRequired, compl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_first_task_activation_resumes_with_finish_starting_guidance():
|
|
||||||
result = run_node(
|
|
||||||
"""
|
|
||||||
const sheet = new Element();
|
|
||||||
const title = new Element();
|
|
||||||
const findButton = new Element();
|
|
||||||
const createButton = new Element();
|
|
||||||
const status = new Element();
|
|
||||||
const controller = createFirstTask({
|
|
||||||
storage:{getItem:() => null, setItem() {}}, getLogin:() => 'timmy', hasWork:() => true,
|
|
||||||
isTodayActive:() => false, isOnline:() => true, mediaQuery:{matches:true}, sheet, title,
|
|
||||||
findButton, createButton, setupButton:new Element(), closeButton:new Element(), status,
|
|
||||||
onFind() {}, onCreate() {}, onSetup() {},
|
|
||||||
});
|
|
||||||
controller.open();
|
|
||||||
process.stdout.write(JSON.stringify({
|
|
||||||
required:controller.required(), title:title.textContent, status:status.textContent,
|
|
||||||
find:findButton.textContent, create:createButton.textContent,
|
|
||||||
}));
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result == {
|
|
||||||
"required": True,
|
|
||||||
"title": "Finish starting your first task",
|
|
||||||
"status": "Your task is ready. Start it from Find or create and start another task.",
|
|
||||||
"find": "Find & start",
|
|
||||||
"create": "Create & start",
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def test_first_task_activation_routes_existing_flows_and_keeps_create_available_offline():
|
def test_first_task_activation_routes_existing_flows_and_keeps_create_available_offline():
|
||||||
result = run_node(
|
result = run_node(
|
||||||
"""
|
"""
|
||||||
|
|
@ -149,12 +112,11 @@ async def test_dashboard_renders_and_wires_phone_safe_first_task_activation():
|
||||||
|
|
||||||
assert '<dialog class="mobile-first-task" id="mobile-first-task" aria-labelledby="mobile-first-task-title">' in html
|
assert '<dialog class="mobile-first-task" id="mobile-first-task" aria-labelledby="mobile-first-task-title">' in html
|
||||||
assert '<h2 id="mobile-first-task-title">Start your first task</h2>' in html
|
assert '<h2 id="mobile-first-task-title">Start your first task</h2>' in html
|
||||||
assert 'id="mobile-first-task-find" type="button">Find & start</button>' in html
|
assert 'id="mobile-first-task-find" type="button">Find a task</button>' in html
|
||||||
assert 'id="mobile-first-task-create" type="button">Create & start</button>' in html
|
assert 'id="mobile-first-task-create" type="button">Create a task</button>' in html
|
||||||
assert 'id="mobile-first-task-setup" type="button">Make this phone work-ready</button>' in html
|
assert 'id="mobile-first-task-setup" type="button">Make this phone work-ready</button>' in html
|
||||||
assert '<script src="static/mobile-first-task.js"></script>' in html
|
assert '<script src="static/mobile-first-task.js"></script>' in html
|
||||||
assert "const mobileFirstTask = createMobileFirstTask({" in html
|
assert "const mobileFirstTask = createMobileFirstTask({" in html
|
||||||
assert "isTodayActive: () => workSession.checkpointed()" in html
|
|
||||||
assert "shouldActivate: () => mobileFirstTask.required()" in html
|
assert "shouldActivate: () => mobileFirstTask.required()" in html
|
||||||
assert "openActivation: () => mobileFirstTask.open()" in html
|
assert "openActivation: () => mobileFirstTask.open()" in html
|
||||||
assert "mobileFirstTask.refresh()" in html
|
assert "mobileFirstTask.refresh()" in html
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user