Merge pull request 'WTC-38: проверить «Назад» в карточке рецепта' (#38) from task/wtc-38 into main
This commit is contained in:
commit
7ce33d7393
@ -46,3 +46,4 @@
|
||||
- WTC-34: «Назад» в рецепте уже работал; добавлен только заметный стиль #back (на всю ширину, #b4500c). Приёмочные стори снова описали готовое.
|
||||
- WTC-36: пометка «добавлено» у примеров уже была в WTC-32 (exampleStates, disabled, examplesAllAdded); добавлен только тест на возврат активной кнопки после removeDish(dishes, название) — removeDish принимает название, не индекс.
|
||||
- WTC-37: предупреждение «у своих блюд рецепта нет» уже было в WTC-26/33 (#noRecipeHint, noRecipe, guard в openRecipe); добавлен только test/own-dish-no-recipe.test.js.
|
||||
- WTC-38: «Назад» в рецепте уже был (WTC-9/21/34); добавлен только test/back-button.test.js (нет «Назад» вне #recipe, фокус возвращается на opener).
|
||||
|
||||
20
test/back-button.test.js
Normal file
20
test/back-button.test.js
Normal file
@ -0,0 +1,20 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
|
||||
const html = readFileSync(new URL("../src/index.html", import.meta.url), "utf8");
|
||||
const app = readFileSync(new URL("../src/app.js", import.meta.url), "utf8");
|
||||
|
||||
test("Сценарий: на главном экране «Назад» не появляется, пока рецепт не открыт", () => {
|
||||
const recipe = html.slice(html.indexOf('<article id="recipe"'));
|
||||
assert.match(html, /<article id="recipe"[^>]*hidden/);
|
||||
assert.ok(recipe.includes('id="back"'));
|
||||
assert.ok(!html.slice(0, html.indexOf('<article id="recipe"')).includes('id="back"'));
|
||||
assert.ok(html.includes('>Назад<'));
|
||||
});
|
||||
|
||||
test("Сценарий: «Назад» возвращает к кнопке, откуда открыт рецепт (список или выдача)", () => {
|
||||
assert.match(app, /openRecipe\(d, r\)/);
|
||||
assert.match(app, /openRecipe\(state\.last, \$\("recipeToday"\)\)/);
|
||||
assert.match(app, /opener\.focus\(\)/);
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user