Matrix / To-do survives a page reload
To-do survives a page reload
After adding a to-do and reloading the page, the to-do is still listed because it is saved in localStorage (Kane issue 252 reported the reload being done as a Ctrl+R key press). The broken page keeps to-dos only in memory and never reads them back, so a real reload clears the list.
What your agent will do with Beam installed
Use
Verify the to-do list shows "pay rent".Results
Before each check, Kane does: Type "pay rent" into the "New to-do" box and press Enter. Reload the page.
| Wording | Kane | Correct page | Broken page | Result |
|---|---|---|---|---|
Verify the to-do list shows "pay rent".From the Kane issue | 0.10.9 | passed | failed | Balanced |
| 0.10.8 | passed | failed | Balanced | |
Verify the exact visible text of the to-do list includes "pay rent" after the page has been reloaded.Baseline | 0.10.9 | passed | – | Not run |
How Kane read the page
Kane turns each wording into code that reads the page. This is the code it recorded:
Verify the to-do list shows "pay rent". Balanced
Array.from(el(3).querySelectorAll(':scope > li')).some(li => li.innerText.trim() === 'pay rent')Verify the exact visible text of the to-do list includes "pay rent" after the page has been reloaded. Not run
Array.from(el(3).querySelectorAll(':scope > li')).some(li => li.innerText.trim().includes('pay rent'))The two pages
These are live. To see the difference, do what Kane does: Type "pay rent" into the "New to-do" box and press Enter. Reload the page.
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>To-dos</title><style>body{font:18px system-ui,sans-serif;margin:24px}input{font-size:18px;padding:6px}</style></head><body>
<h1>To-dos</h1>
<input id="new" placeholder="New to-do" aria-label="New to-do">
<ul id="list"></ul>
<script>
const KEY = 'todos';
let todos = JSON.parse(localStorage.getItem(KEY) || '[]');
const input = document.getElementById('new');
const list = document.getElementById('list');
function render() {
list.innerHTML = '';
for (const t of todos) {
const li = document.createElement('li');
li.textContent = t;
list.appendChild(li);
}
}
input.addEventListener('keydown', e => {
if (e.key !== 'Enter' || !input.value.trim()) return;
todos.push(input.value.trim());
localStorage.setItem(KEY, JSON.stringify(todos));
input.value = '';
render();
});
render();
</script></body></html>
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>To-dos</title><style>body{font:18px system-ui,sans-serif;margin:24px}input{font-size:18px;padding:6px}</style></head><body>
<h1>To-dos</h1>
<input id="new" placeholder="New to-do" aria-label="New to-do">
<ul id="list"></ul>
<script>
const KEY = 'todos';
let todos = [];
const input = document.getElementById('new');
const list = document.getElementById('list');
function render() {
list.innerHTML = '';
for (const t of todos) {
const li = document.createElement('li');
li.textContent = t;
list.appendChild(li);
}
}
input.addEventListener('keydown', e => {
if (e.key !== 'Enter' || !input.value.trim()) return;
todos.push(input.value.trim());
localStorage.setItem(KEY, JSON.stringify(todos));
input.value = '';
render();
});
render();
</script></body></html>
Reproduce it
Clone the repo, then run this behavior on your own Kane:
npm run suite -- reload-persists