Matrix / Saved message despite failed request
Saved message despite failed request
Clicking "Save" fetches ok.json successfully and then shows "Saved" in green. The broken page requests a missing file, which returns 404, but still shows "Saved".
What your agent will do with Beam installed
No wording tried so far makes Kane get this right. Your agent adds a separate check (a unit test or a direct DOM assertion) next to the Kane check.
Avoid
Verify the page shows "Saved".(False green)Verify the page shows "Saved" and that the save request made after clicking Save succeeded with no failed network requests.(False red)Verify that the save request triggered by the Save click returned an HTTP 200 response and that the exact visible text of the status message is "Saved".(False red)Assert that the status message's exact visible text is "Saved" in its green success styling and that the request the save made for its data file completed successfully with a 2xx status.(False red)
Results
Before each check, Kane does: Click "Save".
| Wording | Kane | Correct page | Broken page | Result |
|---|---|---|---|---|
Verify the page shows "Saved".Baseline | 0.10.9 | passed | passed | False green |
| 0.10.8 | passed | passed | False green | |
Verify the page shows "Saved" and that the save request made after clicking Save succeeded with no failed network requests.Baseline | 0.10.9 | failed | failed | False red |
| 0.10.8 | failed | failed | False red | |
Verify that the save request triggered by the Save click returned an HTTP 200 response and that the exact visible text of the status message is "Saved".Proposed by the agent | 0.10.9 | failed | failed | False red |
| 0.10.8 | failed | failed | False red | |
Assert that the status message's exact visible text is "Saved" in its green success styling and that the request the save made for its data file completed successfully with a 2xx status.Proposed by the agent | 0.10.9 | failed | failed | False red |
| 0.10.8 | failed | failed | False red |
How Kane read the page
Kane turns each wording into code that reads the page. This is the code it recorded:
Verify the page shows "Saved". False green
el(6).innerText.trim() === 'Saved' && !!(el(6).offsetWidth || el(6).offsetHeight || el(6).getClientRects().length)Verify the page shows "Saved" and that the save request made after clicking Save succeeded with no failed network requests. False red
el(6).innerText.trim() === 'Saved'Verify that the save request triggered by the Save click returned an HTTP 200 response and that the exact visible text of the status message is "Saved". False red
el(6).innerText.trim()Assert that the status message's exact visible text is "Saved" in its green success styling and that the request the save made for its data file completed successfully with a 2xx status. False red
getComputedStyle(el(6)).color === 'rgb(0, 128, 0)'The two pages
These are live. To see the difference, do what Kane does: Click "Save".
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>editor</title></head><body>
<h1>Editor</h1>
<textarea id="doc" rows="4" cols="40">Draft text</textarea>
<br>
<button id="save" type="button">Save</button>
<p id="msg" style="color:green"></p>
<script>
document.getElementById('save').addEventListener('click', async () => {
const msg = document.getElementById('msg');
try {
const res = await fetch('ok.json');
if (res.ok) msg.textContent = 'Saved';
} catch (e) {
msg.textContent = '';
}
});
</script></body></html>
Source
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>editor</title></head><body>
<h1>Editor</h1>
<textarea id="doc" rows="4" cols="40">Draft text</textarea>
<br>
<button id="save" type="button">Save</button>
<p id="msg" style="color:green"></p>
<script>
document.getElementById('save').addEventListener('click', async () => {
const msg = document.getElementById('msg');
try {
const res = await fetch('missing.json');
msg.textContent = 'Saved';
} catch (e) {
msg.textContent = '';
}
});
</script></body></html>
Reproduce it
Clone the repo, then run this behavior on your own Kane:
npm run suite -- hidden-request-failure