137 lines
6.0 KiB
Markdown
137 lines
6.0 KiB
Markdown
---
|
|
phase: 12-i18n-bugfixes
|
|
plan: "01"
|
|
type: execute
|
|
wave: 1
|
|
depends_on: []
|
|
files_modified:
|
|
- imptune/templates/base.html
|
|
- tests/e2e/test_port_autofill.py
|
|
autonomous: true
|
|
requirements: []
|
|
|
|
must_haves:
|
|
truths:
|
|
- "When a user's browser is set to English (navigator.language starts with 'en'), the UI loads in English by default without touching the toggle"
|
|
- "When localStorage has no saved language preference, the browser's navigator.language is used as the initial language"
|
|
- "When localStorage does have a saved preference, it wins over navigator.language"
|
|
- "test_port_autofill passes in CI — navigates to /printers/new (not /printers)"
|
|
artifacts:
|
|
- path: "imptune/templates/base.html"
|
|
provides: "i18n store with navigator.language fallback"
|
|
contains: "navigator.language"
|
|
- path: "tests/e2e/test_port_autofill.py"
|
|
provides: "Fixed E2E test navigating to /printers/new"
|
|
contains: "/printers/new"
|
|
key_links:
|
|
- from: "imptune/templates/base.html"
|
|
to: "Alpine.store('i18n').lang"
|
|
via: "localStorage.getItem || navigator.language fallback"
|
|
pattern: "navigator\\.language"
|
|
---
|
|
|
|
<objective>
|
|
Fix the two remaining correctness bugs from Phase 11: (1) browser language auto-detection not honouring navigator.language when no localStorage preference exists, and (2) the pre-existing test_port_autofill E2E failure caused by Phase 11 moving the add-printer form to /printers/new.
|
|
|
|
Purpose: Users whose browser is set to English should get the English UI on first visit, without manually clicking the toggle. The E2E suite should be fully green.
|
|
Output: Updated base.html i18n store, fixed test_port_autofill.py.
|
|
</objective>
|
|
|
|
<execution_context>
|
|
@C:/Users/SebastienQUEROL/.claude/get-shit-done/workflows/execute-plan.md
|
|
@C:/Users/SebastienQUEROL/.claude/get-shit-done/templates/summary.md
|
|
</execution_context>
|
|
|
|
<context>
|
|
@.planning/PROJECT.md
|
|
@.planning/ROADMAP.md
|
|
@.planning/STATE.md
|
|
@.planning/phases/11-ui-enhancements/11-03-SUMMARY.md
|
|
@.planning/phases/11-ui-enhancements/deferred-items.md
|
|
</context>
|
|
|
|
<tasks>
|
|
|
|
<task type="auto" tdd="true">
|
|
<name>Task 1: Browser language auto-detection in i18n store</name>
|
|
<files>imptune/templates/base.html</files>
|
|
<behavior>
|
|
- When localStorage key 'imptune_lang' is absent and navigator.language starts with 'en', lang initialises to 'en'
|
|
- When localStorage key 'imptune_lang' is absent and navigator.language starts with 'fr' (or anything else), lang initialises to 'fr'
|
|
- When localStorage key 'imptune_lang' is 'fr', it wins over navigator.language === 'en-US'
|
|
- When localStorage key 'imptune_lang' is 'en', it wins over navigator.language === 'fr-FR'
|
|
</behavior>
|
|
<action>
|
|
In imptune/templates/base.html, inside the alpine:init script, update the i18n store's lang initialisation line. Currently:
|
|
|
|
lang: localStorage.getItem('imptune_lang') || 'fr',
|
|
|
|
Change to a function-based initialisation that checks navigator.language when localStorage is absent:
|
|
|
|
lang: (() => {
|
|
const saved = localStorage.getItem('imptune_lang');
|
|
if (saved) return saved;
|
|
return navigator.language && navigator.language.startsWith('en') ? 'en' : 'fr';
|
|
})(),
|
|
|
|
This is a single targeted change. Do not modify anything else in base.html. The toggle() method, translations object, and all x-text bindings remain unchanged.
|
|
|
|
Note: Do NOT use a top-level property shorthand that would require Alpine to evaluate it lazily — the IIFE pattern evaluates at store creation time, which is the correct moment (stores are created inside alpine:init, before any hydration).
|
|
</action>
|
|
<verify>
|
|
<automated>cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/test_i18n_toggle.py -x -q 2>&1 | tail -10</automated>
|
|
</verify>
|
|
<done>
|
|
- base.html i18n store lang field uses IIFE with navigator.language fallback
|
|
- All 2 existing test_i18n_toggle.py tests still pass (they test toggle + persistence, not initial detection)
|
|
- Manual verification: open a fresh browser with no imptune_lang in localStorage; if browser language is English, nav shows "Drivers" not "Pilotes"
|
|
</done>
|
|
</task>
|
|
|
|
<task type="auto" tdd="true">
|
|
<name>Task 2: Fix test_port_autofill navigating to /printers/new</name>
|
|
<files>tests/e2e/test_port_autofill.py</files>
|
|
<behavior>
|
|
- test_port_autofill navigates to /printers/new (not /printers)
|
|
- Typing an IP into input[name='ip_address'] auto-populates port_name with 'IP_192_168_1_100'
|
|
- Test passes on chromium
|
|
</behavior>
|
|
<action>
|
|
In tests/e2e/test_port_autofill.py, change the page.goto line:
|
|
|
|
BEFORE: page.goto(f"{live_server}/printers", wait_until="domcontentloaded")
|
|
AFTER: page.goto(f"{live_server}/printers/new", wait_until="domcontentloaded")
|
|
|
|
That is the only change needed. The input[name='ip_address'] and port_name assertions remain exactly as is — they already match the form markup in printers_new.html.
|
|
|
|
Context: Plan 11-01 moved the add-printer form from /printers to /printers/new. The E2E test was deferred (logged in deferred-items.md) because it was a pre-existing failure at the time of 11-04 execution. Phase 12 is the correct place to fix it.
|
|
</action>
|
|
<verify>
|
|
<automated>cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/test_port_autofill.py -x -q 2>&1 | tail -10</automated>
|
|
</verify>
|
|
<done>
|
|
- test_port_autofill[chromium] passes
|
|
- The one-line URL fix is the only change in the file
|
|
</done>
|
|
</task>
|
|
|
|
</tasks>
|
|
|
|
<verification>
|
|
Run the full E2E suite to confirm no regressions:
|
|
cd /c/Users/SebastienQUEROL/Documents/projets/ImpTune && python -m pytest tests/e2e/ -q 2>&1 | tail -15
|
|
|
|
All 7 E2E tests should pass (the 7th was the previously failing test_port_autofill[chromium]).
|
|
</verification>
|
|
|
|
<success_criteria>
|
|
- base.html i18n store reads navigator.language as fallback when localStorage is empty
|
|
- test_port_autofill[chromium] passes
|
|
- Full E2E suite: 7/7 passing
|
|
- Non-E2E test suite unchanged and passing
|
|
</success_criteria>
|
|
|
|
<output>
|
|
After completion, create `.planning/phases/12-i18n-bugfixes/12-01-SUMMARY.md`
|
|
</output>
|