add explicit button type regression test
This commit is contained in:
@@ -2224,3 +2224,9 @@ Doğrulama: browser QA başarılı; günlük bülten, analitik, ICS, çıktı ve
|
||||
Tüm JSX ekranlarında form dışında kalan düğmeler açık `type="button"` kullanacak şekilde standardize edildi. Filtre, gezinme, dışa aktarma, modal, pazar, bildirim ve yönetim eylemleri artık bir form kapsayıcısına taşınsa bile istemeden submit tetiklemiyor; gerçek form gönderimleri `type="submit"` olarak korunuyor.
|
||||
|
||||
Doğrulama: 293 otomatik test, üretim derlemesi ve browser QA başarılı. QA akışı Günlük Bülten, Analitik, ICS, çıktı ve 390px mobil kontrollerini geçti.
|
||||
|
||||
### 2026-09-06 · Düğme tipi regresyon testi
|
||||
|
||||
`tests/button-types.test.mjs` eklendi. Test, `src/**/*.jsx` içindeki her `<button>` açılışının `type="button"` veya `type="submit"` bildirdiğini denetliyor; yeni ekranlarda örtük submit davranışı CI’da yakalanacak.
|
||||
|
||||
Doğrulama: otomatik test sayısı 294/294’e yükseldi ve tamamı başarılı.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { readdir, readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const root = new URL('../src/', import.meta.url);
|
||||
|
||||
async function jsxFiles(directory) {
|
||||
const entries = await readdir(directory, { withFileTypes: true });
|
||||
const files = [];
|
||||
for (const entry of entries) {
|
||||
const path = join(directory, entry.name);
|
||||
if (entry.isDirectory()) files.push(...await jsxFiles(path));
|
||||
else if (entry.isFile() && entry.name.endsWith('.jsx')) files.push(path);
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
test('every JSX button declares an explicit button or submit type', async () => {
|
||||
const files = await jsxFiles(root.pathname);
|
||||
const violations = [];
|
||||
for (const file of files) {
|
||||
const source = await readFile(file, 'utf8');
|
||||
for (const match of source.matchAll(/<button\b[^>]*>/gs)) {
|
||||
const tag = match[0];
|
||||
const line = source.slice(0, match.index).split('\n').length;
|
||||
const type = /\btype\s*=\s*["'](button|submit)["']/.exec(tag)?.[1];
|
||||
if (!type) violations.push(`${file}:${line}`);
|
||||
}
|
||||
}
|
||||
assert.deepEqual(violations, [], `type eksik düğmeler: ${violations.join(', ')}`);
|
||||
});
|
||||
Reference in New Issue
Block a user