import json import os import subprocess from pathlib import Path import pytest from tests.dashboard_bundle import dashboard MY_WORK = Path(__file__).parents[1] / "frontend" / "my-work.js" NOTIFICATION_UNDO = Path(__file__).parents[1] / "frontend" / "notification-undo.js" TODAY_TIMER = Path(__file__).parents[1] / "frontend" / "today-timer.js" LATER_WORK = Path(__file__).parents[1] / "frontend" / "later-work.js" DETAIL_DEFER = Path(__file__).parents[1] / "frontend" / "detail-defer.js" LATER_PICKER = Path(__file__).parents[1] / "frontend" / "later-picker.js" LATER_AND_START = Path(__file__).parents[1] / "frontend" / "later-and-start.js" REVIEW_SHEET = Path(__file__).parents[1] / "frontend" / "review-sheet.js" ISSUE_SHEET = Path(__file__).parents[1] / "frontend" / "issue-sheet.js" CREATE_ISSUE_SHEET = Path(__file__).parents[1] / "frontend" / "create-issue-sheet.js" PULL_SHEET = Path(__file__).parents[1] / "frontend" / "pull-sheet.js" CONVERSATION = Path(__file__).parents[1] / "frontend" / "conversation.js" COMMENT_ACTIONS = Path(__file__).parents[1] / "frontend" / "comment-actions.js" PICK_WORK = Path(__file__).parents[1] / "frontend" / "pick-work.js" WORK_ROUTE = Path(__file__).parents[1] / "frontend" / "work-route.js" UPDATE_OWNERSHIP = Path(__file__).parents[1] / "frontend" / "update-ownership.js" CARD_PLANNING = Path(__file__).parents[1] / "frontend" / "card-planning.js" TODAY_WORK = Path(__file__).parents[1] / "frontend" / "today-work.js" WORK_SELECTION = Path(__file__).parents[1] / "frontend" / "work-selection.js" def test_queue_finder_matches_repository_number_and_title_without_reordering(): script = f""" const work = require({json.dumps(str(MY_WORK))}); const items = [ {{repository:'stackchain/api', key:'stackchain/api#42', number:42, title:'Retry failed deploy'}}, {{repository:'stackchain/web', key:'stackchain/web#7', number:7, title:'Polish mobile queue'}}, {{repository:'other/repo', key:'other/repo#42', number:42, title:'Unrelated task'}}, ]; process.stdout.write(JSON.stringify({{ repo:work.findQueueItems(items, 'STACKCHAIN/API').map(item => item.key), number:work.findQueueItems(items, '#42').map(item => item.key), title:work.findQueueItems(items, 'mobile queue').map(item => item.key), clear:work.findQueueItems(items, ' ').map(item => item.key), }})); """ result = subprocess.run(["node", "-e", script], capture_output=True, text=True) assert result.returncode == 0, result.stderr assert json.loads(result.stdout) == { "repo": ["stackchain/api#42"], "number": ["stackchain/api#42", "other/repo#42"], "title": ["stackchain/web#7"], "clear": ["stackchain/api#42", "stackchain/web#7", "other/repo#42"], } @pytest.mark.anyio async def test_mobile_queue_finder_is_labeled_thumb_safe_and_offers_older_search(): html = await dashboard() assert '