Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/og/gun-hesaplama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 53 additions & 2 deletions scripts/browser-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const KDV = "/tr/kdv-hesaplama/";
const YAS = "/tr/yas-hesaplama/";
const YUZDE = "/tr/yuzde-hesaplama/";
const ORTALAMA = "/tr/ortalama-hesaplama/";
const GUN = "/tr/gun-hesaplama/";
const DAYS = "/days-between-dates/";
const LINES = "/remove-line-breaks/";
const HEX = "/hex-to-rgb/";
Expand Down Expand Up @@ -398,7 +399,7 @@ for (const width of [1440, 390]) {
await setDate("start", "5", "15", "1990");
await setDate("end", "7", "30", "2026");
await page.screenshot({ path: `${shots}/en-days-${width}.png`, fullPage: true });
await langMenu(page, label, "en", { en: DAYS, tr: "/tr/" }, null);
await langMenu(page, label, "en", { en: DAYS, tr: GUN }, null);
finish(errors, label);
await context.close();
}
Expand Down Expand Up @@ -1086,6 +1087,56 @@ for (const width of [1440, 390]) {
await context.close();
}

for (const width of [1440, 390]) {
const label = `gun ${width}`;
const { context, page, errors } = await open(width, GUN, label);
await page.evaluate(() => localStorage.clear());
await page.reload({ waitUntil: "networkidle" });
const val = (id) => page.textContent(`#${id}`);
const setDate = async (p, d, m, y) => {
await page.fill(`#${p}-d`, String(d));
await page.selectOption(`#${p}-m`, String(m));
await page.fill(`#${p}-y`, String(y));
};
const now = new Date();
expect((await page.inputValue("#start-y")) === String(now.getFullYear()), `${label}: start is not today`);

await setDate("start", 15, 5, 1990);
await setDate("end", 30, 7, 2026);
expect((await val("days-main")) === "13.225 gün" && (await val("ymd")) === "36 yıl 2 ay 15 gün", `${label}: between gave ${await val("days-main")} ${await val("ymd")}`);
expect((await val("weeks")) === "1.889 hafta 2 gün", `${label}: weeks gave ${await val("weeks")}`);
await page.check("#include-end");
expect((await val("days-main")) === "13.226 gün", `${label}: include end gave ${await val("days-main")}`);
await page.uncheck("#include-end");
await setDate("start", 1, 1, 2027);
await setDate("end", 30, 11, 2026);
expect((await val("days-main")) === "32 gün" && (await val("status")).length > 10, `${label}: swap gave ${await val("days-main")}`);
await page.fill("#end-d", "15.05.1990");
expect((await page.inputValue("#end-m")) === "5" && (await page.inputValue("#end-y")) === "1990", `${label}: pasted date not spread`);
await setDate("end", 31, 2, 2023);
expect((await val("status")).includes("28 gün"), `${label}: missing day not reported`);

await setDate("base", 2, 12, 2026);
await page.fill("#shift-days", "90");
expect((await val("shift-out")) === "2 Mart 2027" && (await val("shift-sub")) === "Salı", `${label}: add gave ${await val("shift-out")} ${await val("shift-sub")}`);
await page.locator('label:has(input[name="op"][value="sub"]) span').click();
await page.fill("#shift-days", "30");
expect((await val("shift-out")) === "2 Kasım 2026" && (await val("shift-formula")).includes("- 30 gün"), `${label}: sub gave ${await val("shift-out")}`);
await page.fill("#shift-days", "abc");
expect((await val("shift-out")) === "-" && (await val("shift-status")).length > 10, `${label}: bad shift not reported`);
await page.reload({ waitUntil: "networkidle" });
expect(await page.isChecked('input[name="op"][value="sub"]'), `${label}: op not remembered`);

await page.locator('label:has(input[name="op"][value="add"]) span').click();
await setDate("start", 15, 5, 1990);
await setDate("end", 30, 7, 2026);
await page.fill("#shift-days", "90");
await page.screenshot({ path: `${shots}/tr-gun-${width}.png`, fullPage: true });
await langMenu(page, label, "tr", { en: DAYS, tr: GUN }, null);
finish(errors, label);
await context.close();
}

for (const path of OTHER) {
for (const width of [1440, 390]) {
const label = `${path} ${width}`;
Expand All @@ -1094,7 +1145,7 @@ for (const path of OTHER) {
if (path !== "/missing-page") expect((await page.locator(".tool-card").count()) === 19, `${label}: index does not list every tool`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/kdv-hesaplama/"]').count()) === 1, `${label}: index does not link KDV`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/tr/yas-hesaplama/"]').count()) === 1, `${label}: index does not link yaş hesaplama`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/days-between-dates/"]').count()) === 1, `${label}: index does not link days between dates`);
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${path === "/tr/" ? GUN : DAYS}"]`).count()) === 1, `${label}: index does not link days between dates`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/remove-line-breaks/"]').count()) === 1, `${label}: index does not link remove line breaks`);
if (path !== "/missing-page") expect((await page.locator(`.tool-card a[href="${INVISIBLE[path === "/tr/" ? "tr" : "en"]}"]`).count()) === 1, `${label}: index does not link the invisible character page`);
if (path !== "/missing-page") expect((await page.locator('.tool-card a[href="/text-repeater/"]').count()) === 1, `${label}: index does not link the text repeater`);
Expand Down
45 changes: 43 additions & 2 deletions scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,48 @@ ${out("agirlikli", u.weighted.result, ["weights", "products", "plain"])}
</section>`;
}

const TOOL_BODY = { paste: pasteTool, linebreaks: lineBreaksTool, case: caseTool, color: colorTool, invisible: invisibleTool, repeater: repeaterTool, chmod: chmodTool, slug: slugTool, special: specialTool, counter: counterTool, frequency: frequencyTool, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool, yuzde: pctTool, ortalama: avgTool };
/** The Turkish date page: days between two dates on top, a date plus or minus some days below, for "tarih hesaplama" searches. */
function gunTool(page) {
const u = page.ui;
const row = (id, label, cls = "") => `<div class="calc-row${cls}"><dt>${esc(label)}</dt><dd id="${id}">-</dd></div>`;
return `<section class="tool pct" aria-label="${esc(u.toolLabel)}">
<div class="calc pct-card" id="between">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.between.title)}</h3><p>${esc(u.between.question)}</p></div>
${dateFields("start", u.start, u, { today: u.today })}
${dateFields("end", u.end, u, { today: u.today })}
<label class="opt"><input type="checkbox" id="include-end"><span>${esc(u.includeEnd)}<small>${esc(u.includeEndHint)}</small></span></label>
</div>
<div class="calc-out">
<div class="age-main"><span>${esc(u.resultLabel)}</span><strong id="days-main">-</strong><p id="range"></p></div>
<dl>
${row("ymd", u.ymd)}
${row("weeks", u.totalWeeks)}
${row("months", u.totalMonths)}
${row("weekdays", u.weekdays)}
${row("weekend", u.weekend)}
</dl>
<p class="formula" id="formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="status" role="status" aria-live="polite"></p>
</div>
</div>
<div class="calc pct-card" id="shift">
<div class="calc-in">
<div class="pct-head"><h3>${esc(u.shift.title)}</h3><p>${esc(u.shift.question)}</p></div>
${dateFields("base", u.base, u, { today: u.today })}
<div class="seg seg-radio pct-dir" role="radiogroup" aria-label="${esc(u.opLabel)}">${u.ops.map(([v, l], i) => radio("op", v, l, i === 0)).join("")}</div>
<div class="field"><label for="shift-days">${esc(u.shiftDays)}</label><input id="shift-days" class="input" type="text" inputmode="numeric" autocomplete="off" maxlength="9" placeholder="${esc(u.shiftPh)}"></div>
</div>
<div class="calc-out">
<div class="age-main"><span>${esc(u.shift.result)}</span><strong id="shift-out">-</strong><p id="shift-sub"></p></div>
<p class="formula" id="shift-formula" aria-label="${esc(u.formula)}"></p>
<p class="status calc-status" id="shift-status" role="status" aria-live="polite"></p>
</div>
</div>
</section>`;
}

const TOOL_BODY = { paste: pasteTool, linebreaks: lineBreaksTool, case: caseTool, color: colorTool, invisible: invisibleTool, repeater: repeaterTool, chmod: chmodTool, slug: slugTool, special: specialTool, counter: counterTool, frequency: frequencyTool, reverse: caseTool, flip: pasteTool, compare: compareTool, kdv: kdvTool, yas: yasTool, dates: datesTool, yuzde: pctTool, ortalama: avgTool, gun: gunTool };

/** Prose, a list of titled rows with sources, and a dated note; the paste and compare pages build theirs from why and shortcuts. */
function infoSection(page, sec) {
Expand Down Expand Up @@ -954,7 +995,7 @@ function manifest(lang) {
};
}

const SCRIPTS = ["clean.js", "plain-text.js", "diff.js", "text-compare.js", "kdv.js", "kdv-hesaplama.js", "yas.js", "yas-hesaplama.js", "date-diff.js", "days-between-dates.js", "line-breaks.js", "remove-line-breaks.js", "case.js", "case-converter.js", "color.js", "hex-to-rgb.js", "invisible.js", "invisible-character.js", "repeat.js", "text-repeater.js", "reverse.js", "reverse-text.js", "flip.js", "upside-down-text.js", "chmod.js", "chmod-calculator.js", "slug.js", "slug-generator.js", "special.js", "remove-special-characters.js", "count.js", "karakter-sayaci.js", "frequency.js", "word-frequency-counter.js", "sayi.js", "yuzde.js", "yuzde-hesaplama.js", "ortalama.js", "ortalama-hesaplama.js", "nav.js"];
const SCRIPTS = ["clean.js", "plain-text.js", "diff.js", "text-compare.js", "kdv.js", "kdv-hesaplama.js", "yas.js", "yas-hesaplama.js", "date-diff.js", "days-between-dates.js", "line-breaks.js", "remove-line-breaks.js", "case.js", "case-converter.js", "color.js", "hex-to-rgb.js", "invisible.js", "invisible-character.js", "repeat.js", "text-repeater.js", "reverse.js", "reverse-text.js", "flip.js", "upside-down-text.js", "chmod.js", "chmod-calculator.js", "slug.js", "slug-generator.js", "special.js", "remove-special-characters.js", "count.js", "karakter-sayaci.js", "frequency.js", "word-frequency-counter.js", "sayi.js", "yuzde.js", "yuzde-hesaplama.js", "ortalama.js", "ortalama-hesaplama.js", "gun-hesaplama.js", "nav.js"];
const sha = (...parts) => {
const h = createHash("sha256");
for (const p of parts) h.update(p);
Expand Down
Loading