Beam

Matrix / Counter label, singular vs plural

Counter label, singular vs plural

Balanced with wordingKane issue #254Measured on Kane 0.10.9 and 0.10.8

After adding one to-do, the counter should read "1 item left". The broken page always renders "items", so one to-do shows "1 items left".

What your agent will do with Beam installed

Use

Verify the exact visible text of the todo counter is "1 item left".

Avoid

  • Verify the todo counter reads "1 item left". (False green)

Results

Before each check, Kane does: Type "buy some cheese" into the "What needs to be done?" box and press Enter.

WordingKaneCorrect pageBroken pageResult
Verify the todo counter reads "1 item left".From the Kane issue0.10.9passedpassedFalse green
0.10.8passedpassedFalse green
Verify the exact visible text of the todo counter is "1 item left".From the Kane issue0.10.9passedfailedBalanced
0.10.8passedfailedBalanced

How Kane read the page

Kane turns each wording into code that reads the page. This is the code it recorded:

Verify the todo counter reads "1 item left". False green

el(3).textContent

Verify the exact visible text of the todo counter is "1 item left". Balanced

el(3).textContent + (el(3).nextSibling ? el(3).nextSibling.textContent : '')

The two pages

These are live. To see the difference, do what Kane does: Type "buy some cheese" into the "What needs to be done?" 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></head><body>
<h1>todos</h1>
<input id="new" placeholder="What needs to be done?">
<span class="todo-count" data-testid="todo-count"></span>
<script>
  let n = 0;
  const out = document.querySelector('.todo-count');
  document.getElementById('new').addEventListener('keydown', e => {
    if (e.key !== 'Enter') return;
    n++;
    out.innerHTML = '<strong>' + n + '</strong> ' + (n === 1 ? 'item' : 'items') + ' left';
  });
</script></body></html>
Broken page Kane should failOpen full page
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>todos</title></head><body>
<h1>todos</h1>
<input id="new" placeholder="What needs to be done?">
<span class="todo-count" data-testid="todo-count"></span>
<script>
  let n = 0;
  const out = document.querySelector('.todo-count');
  document.getElementById('new').addEventListener('keydown', e => {
    if (e.key !== 'Enter') return;
    n++;
    out.innerHTML = '<strong>' + n + '</strong> ' + ('items') + ' left';
  });
</script></body></html>

Reproduce it

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

npm run suite -- plural-counter