Beam

Matrix / To-dos saved under the react-todos key

To-dos saved under the react-todos key

Not runKane issue #255Measured on Kane 0.10.9 and 0.10.8

Each added to-do is saved as a JSON array under the localStorage key "react-todos". The broken page renders the list but never writes anything to localStorage.

What your agent will do with Beam installed

Not measured yet.

Results

Before each check, Kane does: Type "milk" into the "What needs to be done?" box and press Enter. Type "eggs" into the same box and press Enter.

WordingKaneCorrect pageBroken pageResult
Verify the browser localStorage key "react-todos" holds exactly 2 todos.Not run yet
Verify that the localStorage value stored under the key "react-todos" is a list containing "milk" and "eggs".Not run yet

The two pages

These are live. To see the difference, do what Kane does: Type "milk" into the "What needs to be done?" box and press Enter. Type "eggs" into the same box and press Enter.

Correct page Kane should passOpen full page
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Todos</title><style>body{font:18px system-ui,sans-serif;margin:24px}input{font-size:18px;padding:6px}</style></head><body>
<h1>todos</h1>
<input id="new" placeholder="What needs to be done?">
<ul id="list"></ul>
<script>
  const KEY = 'react-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>
Broken page Kane should failOpen full page
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Todos</title><style>body{font:18px system-ui,sans-serif;margin:24px}input{font-size:18px;padding:6px}</style></head><body>
<h1>todos</h1>
<input id="new" placeholder="What needs to be done?">
<ul id="list"></ul>
<script>
  const KEY = 'react-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());
    /* save to localStorage skipped */
    input.value = '';
    render();
  });
  render();
</script></body></html>

Reproduce it

Clone the repo, then run this behavior on your own Kane:

npm run suite -- localstorage-key