Files
MetonaSqlark/tests/e2e/harness.html
T
thzxx 334067d89e
CI / test (18.x) (push) Successful in 10m10s
CI / test (20.x) (push) Successful in 10m10s
CI / test (22.x) (push) Successful in 10m6s
CI / e2e (push) Successful in 9m51s
CI / test (24.x) (push) Successful in 10m28s
release: v0.5.1 — 存储后端生产级硬化(CRC-32/全库加密/WAL分片/页面化存储/多标签页锁/e2e)+ 深度审查修复(假实现接线/死代码清理)
2026-08-10 12:07:00 +08:00

98 lines
2.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>MetonaSqlark E2E Harness</title>
</head>
<body>
<h1>MetonaSqlark E2E Harness</h1>
<div id="status">loading</div>
<script src="/dist/metona-sqlark.js"></script>
<script>
// E2E 驱动器:暴露全局 API,测试通过 page.evaluate 调用
// 使用高层 APIMetonaSqlark.create),保证 e2e 覆盖真实入口路径
window.__ms = {
version: () => (window.MetonaSqlark ? window.MetonaSqlark.VERSION : null),
/**
* 创建并打开 Aria 库。
* opts: {
* name, diskEngine ('opfs'|'indexeddb'|'memory'),
* walSyncMode, checkpointInterval,
* encryptionPassword, memtableSizeThreshold
* }
*/
open: async (opts) => {
const db = await window.MetonaSqlark.create({
name: opts.name,
mode: 'aria',
diskEngine: opts.diskEngine || 'opfs',
aria: {
walSyncMode: opts.walSyncMode || 'full',
checkpointInterval: opts.checkpointInterval || 100000,
memtableSizeThreshold: opts.memtableSizeThreshold || 64 * 1024 * 1024,
...(opts.encryptionPassword ? { encryption: { password: opts.encryptionPassword } } : {}),
},
});
window.__ms.__db = db;
return { ok: true, engineName: db.getEngine().name };
},
createTable: async (opts) => {
const db = window.__ms.__db;
const columns = {};
for (const col of opts.columns) {
columns[col.name] = { type: col.type, primaryKey: !!col.primaryKey, index: !!col.index };
}
await db.defineTable(opts.table, columns);
return { ok: true };
},
insert: async (opts) => {
const db = window.__ms.__db;
const pks = await db.table(opts.table).insertMany(opts.rows);
return { pks };
},
count: async (opts) => {
const db = window.__ms.__db;
return { count: await db.table(opts.table).count() };
},
find: async (opts) => {
const db = window.__ms.__db;
const rows = await db.table(opts.table).select().where(opts.where || {}).execute();
return { rows };
},
query: async (opts) => {
const db = window.__ms.__db;
return { rows: await db.query(opts.sql) };
},
repair: async () => {
const db = window.__ms.__db;
await db.repair();
return { ok: true };
},
clearAll: async () => {
const db = window.__ms.__db;
await db.clearAll();
return { ok: true };
},
close: async () => {
const db = window.__ms.__db;
await db.close();
window.__ms.__db = null;
return { ok: true };
},
getEngine: () => (window.__ms.__db ? window.__ms.__db.getEngine() : null),
};
document.getElementById('status').textContent = 'ready';
</script>
</body>
</html>