mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-08-28 09:11:06 +00:00
feat(CI): modular testing and linting system + cursor rule
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
import { runGlobalSearchSelfTests } from "./selfTests";
|
||||
|
||||
describe("globalSearch selfTests", () => {
|
||||
it("all in-process cases pass", async () => {
|
||||
const report = await runGlobalSearchSelfTests();
|
||||
expect(report.failed).toBe(0);
|
||||
expect(report.failures).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -22,12 +22,10 @@ import {
|
||||
/**
|
||||
* Lightweight in-process self-tests for the global-search overhaul.
|
||||
*
|
||||
* The repository does not (yet) ship with a test runner, so we instead
|
||||
* expose a deterministic suite of assertions over the pure helpers that
|
||||
* back active jobs and the passive observer. This is intentionally
|
||||
* dependency-free so it can run inside the extension page (`window.
|
||||
* globalSearchDebug.runSelfTests()`) and from any future Vitest harness
|
||||
* without modification.
|
||||
* Exposes a deterministic suite of assertions over the pure helpers that
|
||||
* back active jobs and the passive observer. Runs in Jest via
|
||||
* `selfTests.test.ts`, and inside the extension page via
|
||||
* `window.globalSearchDebug.runSelfTests()`.
|
||||
*/
|
||||
|
||||
interface TestCase {
|
||||
|
||||
@@ -141,7 +141,7 @@ export function htmlToPlainText(rawHtml: string): string {
|
||||
}
|
||||
});
|
||||
|
||||
let text = body.innerText || "";
|
||||
let text = body.textContent || body.innerText || "";
|
||||
|
||||
text = text
|
||||
.replace(/\u00A0/g, " ")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { __resetBrowserStorageMock } from "./mocks/webextension-polyfill";
|
||||
|
||||
afterEach(() => {
|
||||
__resetBrowserStorageMock();
|
||||
});
|
||||
@@ -23,8 +23,16 @@ const local = {
|
||||
}),
|
||||
};
|
||||
|
||||
const onChanged = {
|
||||
addListener: jest.fn(),
|
||||
removeListener: jest.fn(),
|
||||
};
|
||||
|
||||
export default {
|
||||
storage: { local },
|
||||
storage: { local, onChanged },
|
||||
runtime: {
|
||||
sendMessage: jest.fn(async () => undefined),
|
||||
},
|
||||
};
|
||||
|
||||
export function __resetBrowserStorageMock() {
|
||||
@@ -32,4 +40,6 @@ export function __resetBrowserStorageMock() {
|
||||
local.get.mockClear();
|
||||
local.set.mockClear();
|
||||
local.remove.mockClear();
|
||||
onChanged.addListener.mockClear();
|
||||
onChanged.removeListener.mockClear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user