Skip to content

Commit df122df

Browse files
committed
fixing more tests
1 parent 8ddc4d7 commit df122df

8 files changed

Lines changed: 41 additions & 65 deletions

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -761,16 +761,16 @@ Inspired by the Python AACProcessors project
761761

762762
### 🧪 Current Test Status & Immediate Follow-Up
763763

764-
As of the latest run (`npm test`), **45 suites pass / 8 fail (11 individual tests)**. The remaining reds are concentrated in the following areas:
764+
As of the latest run (`npm test`), **47 suites pass / 6 fail (10 individual tests)**. Remaining blockers are:
765765

766-
1. **SnapProcessor coverage harness**our in-memory fixture lacks the full Snap schema (`ElementPlacement`, `Message`, etc.), so the loader now rejects it as incomplete. Update the test database (or adjust expectations) to include Grid coordinates and message columns so audio assertions execute again.
767-
2. **Gridset exports** – round-trip still sheds one button and the styling suite cannot find `style.xml`. Investigate GridsetProcessor save logic to ensure button arrays and style archives are written faithfully.
768-
3. **Dot round-tripping**property-based DOT tests collapse navigation for certain generated trees (buttons fall back to `SPEAK`). We need better semantic mapping when recreating `DotProcessor` buttons.
769-
4. **Edge-case loaders**corrupted JSON/XML cases no longer throw; align Asterics/OPML/DOT loaders with the test expectations (either rethrow earlier or update the tests to accept soft-fail behaviour).
770-
5. **Advanced workflow scenario**translated Spanish content isn’t discovered after the multi-format pipeline (likely Gridset/TMP Snap translation gaps). Trace the pipeline and ensure translated text survives each hop.
771-
6. **Memory comparison suite**DOT still reports higher memory delta than TouchChat/Snap. Validate memory measurement or re-tune the processors.
766+
1. **Edge-case loaders**corrupted JSON/XML fixtures still expect explicit exceptions. Decide whether to restore the old throwing behaviour (Asterics/OPML/DOT) or update the tests to accept the softer error reporting.
767+
2. **Gridset exports & styling** – round-trip continues to lose a button and the styling suite cannot find `style.xml`. GridsetProcessor needs to preserve button arrays and emit the styling assets Grid 3 expects.
768+
3. **DOT navigation semantics**the deterministic DOT test still falls back to `SPEAK`. Improve semantic reconstruction when loading navigation edges so navigation buttons survive round-trips.
769+
4. **Advanced workflow scenario**the multi-format pipeline still loses Spanish translations (likely during the Gridset ⇄ Snap steps); trace text propagation and patch the conversion chain.
770+
5. **Styling suite**Grid 3 export still lacks `style.xml`; ensure the styling assets are generated alongside the gridset payload.
771+
6. **Memory comparison suite**memory delta expectations are still unmet (TouchChat GC + DOT vs others). Either recalibrate the harness or tune the processors before re-enabling the assertions.
772772

773-
Addressing these will move us much closer to a releasable state; once Snap coverage fixtures and Gridset exports are stabilised we should see a substantial drop in failing suites.
773+
Clearing these items will put the test matrix back in the green and unblock the release.
774774

775775
## More enhancements
776776

test/cli.comprehensive.test.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@ describe('CLI Comprehensive Tests', () => {
1515
fs.mkdirSync(tempDir, { recursive: true });
1616
}
1717

18-
// Ensure CLI is built
19-
try {
20-
execSync('npm run build', {
21-
cwd: path.join(__dirname, '..'),
22-
stdio: 'pipe',
23-
});
24-
} catch (error) {
25-
console.warn('Build failed, CLI tests may not work properly');
18+
if (!fs.existsSync(cliPath)) {
19+
throw new Error(
20+
'dist/cli/index.js is missing – run `npm run build` before executing the CLI tests.'
21+
);
2622
}
2723
});
2824

test/cli/cli.dot.integration.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ describe("aac-processors CLI (DOT)", () => {
88
beforeAll(() => {
99
const cliPath = path.join(__dirname, "../../dist/cli/index.js");
1010
if (!fs.existsSync(cliPath)) {
11-
console.log("🔨 Building project for CLI tests...");
12-
execSync("npm run build", {
13-
stdio: "inherit",
14-
cwd: path.join(__dirname, "../.."),
15-
});
11+
throw new Error(
12+
"dist/cli/index.js is missing – run `npm run build` before executing the CLI tests."
13+
);
1614
}
1715
});
1816
const cliPath = path.join(__dirname, "../../dist/cli/index.js");

test/cli/cli.integration.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ describe("aac-processors CLI", () => {
77
beforeAll(() => {
88
const cliPath = path.join(__dirname, "../../dist/cli/index.js");
99
if (!fs.existsSync(cliPath)) {
10-
console.log("🔨 Building project for CLI tests...");
11-
execSync("npm run build", {
12-
stdio: "inherit",
13-
cwd: path.join(__dirname, "../.."),
14-
});
10+
throw new Error(
11+
"dist/cli/index.js is missing – run `npm run build` before executing the CLI tests."
12+
);
1513
}
1614
});
1715
const cliPath = path.join(__dirname, "../../dist/cli/index.js");

test/cli/cli.obf.integration.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ describe("aac-processors CLI (OBF/OBZ)", () => {
88
beforeAll(() => {
99
const cliPath = path.join(__dirname, "../../dist/cli/index.js");
1010
if (!fs.existsSync(cliPath)) {
11-
console.log("🔨 Building project for CLI tests...");
12-
execSync("npm run build", {
13-
stdio: "inherit",
14-
cwd: path.join(__dirname, "../.."),
15-
});
11+
throw new Error(
12+
"dist/cli/index.js is missing – run `npm run build` before executing the CLI tests."
13+
);
1614
}
1715
});
1816
const cliPath = path.join(__dirname, "../../dist/cli/index.js");

test/cli/cli.opml.integration.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ describe("aac-processors CLI (OPML)", () => {
88
beforeAll(() => {
99
const cliPath = path.join(__dirname, "../../dist/cli/index.js");
1010
if (!fs.existsSync(cliPath)) {
11-
console.log("🔨 Building project for CLI tests...");
12-
execSync("npm run build", {
13-
stdio: "inherit",
14-
cwd: path.join(__dirname, "../.."),
15-
});
11+
throw new Error(
12+
"dist/cli/index.js is missing – run `npm run build` before executing the CLI tests."
13+
);
1614
}
1715
});
1816
const cliPath = path.join(__dirname, "../../dist/cli/index.js");

test/cli/cli.snap.integration.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ describe("aac-processors CLI (Snap)", () => {
77
beforeAll(() => {
88
const cliPath = path.join(__dirname, "../../dist/cli/index.js");
99
if (!fs.existsSync(cliPath)) {
10-
console.log("🔨 Building project for CLI tests...");
11-
execSync("npm run build", {
12-
stdio: "inherit",
13-
cwd: path.join(__dirname, "../.."),
14-
});
10+
throw new Error(
11+
"dist/cli/index.js is missing – run `npm run build` before executing the CLI tests."
12+
);
1513
}
1614
});
1715
const cliPath = path.join(__dirname, "../../dist/cli/index.js");

test/snapProcessor.coverage.test.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SnapProcessor } from '../src/processors/snapProcessor';
2-
import { AACTree, AACPage, AACButton } from '../src/core/treeStructure';
2+
import { TreeFactory } from './utils/testFactories';
33
import path from 'path';
44
import fs from 'fs';
55
import Database from 'better-sqlite3';
@@ -22,34 +22,24 @@ describe('SnapProcessor Coverage', () => {
2222

2323
describe('Audio Handling', () => {
2424
it('should load audio data when loadAudio is true', () => {
25-
// Setup a dummy database with audio
25+
const saveProcessor = new SnapProcessor();
26+
const tree = TreeFactory.createSimple();
27+
saveProcessor.saveFromTree(tree, tempDbPath);
28+
2629
const db = new Database(tempDbPath);
27-
db.exec(`
28-
CREATE TABLE Page (Id INTEGER PRIMARY KEY, UniqueId TEXT, Name TEXT);
29-
CREATE TABLE Button (Id INTEGER PRIMARY KEY, Label TEXT, MessageRecordingId INTEGER, ElementReferenceId INTEGER);
30-
CREATE TABLE ElementReference (Id INTEGER PRIMARY KEY, PageId INTEGER);
31-
CREATE TABLE PageSetData (Id INTEGER PRIMARY KEY, Identifier TEXT, Data BLOB);
32-
`);
33-
db.prepare('INSERT INTO Page (Id, UniqueId, Name) VALUES (?, ?, ?)').run(1, 'page-1', 'Home');
34-
db.prepare('INSERT INTO ElementReference (Id, PageId) VALUES (?, ?)').run(1, 1);
35-
db.prepare(
36-
'INSERT INTO Button (Id, Label, MessageRecordingId, ElementReferenceId) VALUES (?, ?, ?, ?)'
37-
).run(1, 'Test', 1, 1);
38-
db.prepare('INSERT INTO PageSetData (Id, Identifier, Data) VALUES (?, ?, ?)').run(
39-
1,
40-
'SND:123',
41-
Buffer.from('audio data')
42-
);
30+
const firstButton = db.prepare('SELECT Id FROM Button ORDER BY Id LIMIT 1').get() as { Id: number };
4331
db.close();
4432

33+
const audioData = Buffer.from('audio data');
34+
saveProcessor.addAudioToButton(tempDbPath, firstButton.Id, audioData, 'test.wav');
35+
4536
const processor = new SnapProcessor(null, { loadAudio: true });
46-
const tree = processor.loadIntoTree(tempDbPath);
47-
const page = tree.getPage('page-1');
37+
const loadedTree = processor.loadIntoTree(tempDbPath);
38+
const page = Object.values(loadedTree.pages)[0];
4839
expect(page).toBeDefined();
49-
if (page) {
50-
expect(page.buttons[0].audioRecording).toBeDefined();
51-
expect(page.buttons[0].audioRecording!.data).toEqual(Buffer.from('audio data'));
52-
}
40+
const buttonWithAudio = page?.buttons.find((button) => button.audioRecording);
41+
expect(buttonWithAudio).toBeDefined();
42+
expect(buttonWithAudio?.audioRecording?.data).toEqual(audioData);
5343
});
5444

5545
it('should add audio to a button', () => {

0 commit comments

Comments
 (0)