Skip to content

Commit

Permalink
Merge branch 'feat/core/9468-test-improvement-epic-ldml' into feat/co…
Browse files Browse the repository at this point in the history
…re/9468-marker-normalization-epic-ldml
  • Loading branch information
srl295 authored Oct 16, 2023
2 parents ca2ba94 + c3a74dd commit 622735b
Show file tree
Hide file tree
Showing 18 changed files with 780 additions and 119 deletions.
10 changes: 10 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Keyman Version History

## 17.0.192 alpha 2023-10-16

* fix(ios): missing backslash in build script (#9765)
* chore(linux): Speed up ibus-util tests (#9754)
* feat(linux): Allow loading of keyboards with arbitrary language ️ (#9735)

## 17.0.191 alpha 2023-10-15

* chore: update readme for keyboard_info schema (#9746)

## 17.0.190 alpha 2023-10-12

* chore(web): web build streamlining (#9743)
Expand Down
2 changes: 1 addition & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.0.191
17.0.193
14 changes: 13 additions & 1 deletion common/schemas/keyboard_info/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ Documentation at https://help.keyman.com/developer/cloud/keyboard_info
# .keyboard_info version history

## 2023-08-11 2.0 stable
* Removed legacyId, documentationFilename, documentationFileSize. Source vs distribution keyboard_info distinction is removed. Example key sequences are simplified.
* Removed:
- `.documentationFilename`
- `.documentationFileSize`
- `.legacyId`
`.links`
`.related[].note`
`.languages[].example`
Added:
- `.languages[].examples[]`
Modified:
- `.languages[].font`, `.languages[].oskFont`: `.source` is `[string]`
- Source .keyboard_info files are no longer needed, so source vs distribution
keyboard_info distinction is removed

## 2019-09-06 1.0.6 stable
* No changes (see api.keyman.com#36 and api.keyman.com#59. Reverted in 2020-06-10.).
Expand Down
33 changes: 20 additions & 13 deletions common/web/types/src/ldml-keyboard/ldml-keyboard-testdata-xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,41 @@ export interface LKTTests {
export interface LKTTest {
name?: string;
startContext?: LKTStartContext;
actions?: LKTAction[]; // differs from XML, to represent order of actions
actions?: LKTAnyAction[]; // differs from XML, to represent order of actions
};

export interface LKTStartContext {
to?: string;
};

export interface LKTCheck {
/**
* Test Actions.
* The expectation is that each LKTAction object will have exactly one non-falsy field.
*/
export interface LKTAction {
type?: "check" | "emit" | "keystroke" | "backspace";
};

export interface LKTCheck extends LKTAction {
type: "check";
result?: string;
};

export interface LKTEmit {
export interface LKTEmit extends LKTAction {
type: "emit";
to?: string;
};

export interface LKTKeystroke {
export interface LKTKeystroke extends LKTAction {
type: "keystroke";
key?: string;
flick?: string;
longPress?: string;
tapCount?: string;
};

/**
* Test Actions.
* The expectation is that each LKTAction object will have exactly one non-falsy field.
*/
export interface LKTAction {
check?: LKTCheck;
emit?: LKTEmit;
keystroke?: LKTKeystroke;
};
export interface LKTBackspace extends LKTAction {
type: "backspace";
}

export type LKTAnyAction = LKTCheck | LKTEmit | LKTKeystroke | LKTBackspace;
4 changes: 0 additions & 4 deletions common/web/types/src/util/common-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,4 @@ export class CommonTypesMessages {
m(this.ERROR_TestDataUnexpectedArray,
`Problem reading test data: expected single ${o.subtag} element, found multiple`);
static ERROR_TestDataUnexpectedArray = SevError | 0x0007;
static Error_TestDataUnexpectedAction = (o: {subtag: string}) =>
m(this.ERROR_TestDataUnexpectedAction,
`Problem reading test data: unexpected action element ${o.subtag}`);
static ERROR_TestDataUnexpectedAction = SevError | 0x0008;
};
8 changes: 8 additions & 0 deletions common/web/types/test/fixtures/test-fr.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboardTest3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboardTest3.dtd">
<keyboardTest3 conformsTo="techpreview">
<!--
Read by:
- common/web/types/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts
Also see the other test-fr.xml in developer
-->
<info keyboard="fr-t-k0-azerty.xml" author="Team Keyboard" name="fr-test" />
<repertoire name="simple-repertoire" chars="[a b c d e \u{22}]" type="simple" /> <!-- verify that these outputs are all available from simple keys on any layer, for all form factors -->
<repertoire name="chars-repertoire" chars="[á é ó]" type="gesture" /> <!-- verify that these outputs are all available from simple or gesture keys on any layer, for touch -->
Expand All @@ -17,6 +23,8 @@
<!-- tests by specifying 'to' output char -->
<emit to="v"/>
<check result="abc\u0022...stuv" />
<backspace />
<check result="abc\u0022...stu" />
</test>
</tests>
</keyboardTest3>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { constants } from '@keymanapp/ldml-keyboard-constants';
import { assert } from 'chai';
import 'mocha';
import { testTestdataReaderCases } from '../helpers/reader-callback-test.js';
import { LKTAnyAction } from './ldml-keyboard-testdata-xml.js';

describe('ldml keyboard xml reader tests', function () {
this.slow(500); // 0.5 sec -- json schema validation takes a while

testTestdataReaderCases([
{
// Note! There's another test case against similar data, in developer/src/kmc-ldml/test/test-testdata-e2e.ts using test-fr.json
subpath: 'test-fr.xml',
callback: (data, source) => {
assert.ok(source);
Expand Down Expand Up @@ -35,16 +37,19 @@ describe('ldml keyboard xml reader tests', function () {
const test0 = source.keyboardTest3.tests[0].test[0];
assert.equal('key-test', test0.name);
assert.equal('abc\\u0022...', test0.startContext?.to);
assert.sameDeepOrderedMembers([
{ keystroke: { key: 's' } },
{ check: { result: 'abc\\u0022...s' } },
{ keystroke: { key: 't' } },
{ check: { result: 'abc\\u0022...st' } },
{ keystroke: { key: 'u' } },
{ check: { result: 'abc\\u0022...stu' } },
{ emit: { to: 'v' } },
{ check: { result: 'abc\\u0022...stuv' } },
], test0.actions);
const expectedActions : LKTAnyAction[] = [
{ type: "keystroke", key: 's' },
{ type: "check", result: 'abc\\u0022...s' },
{ type: "keystroke", key: 't' },
{ type: "check", result: 'abc\\u0022...st' },
{ type: "keystroke", key: 'u' },
{ type: "check", result: 'abc\\u0022...stu' },
{ type: "emit", to: 'v' },
{ type: "check", result: 'abc\\u0022...stuv' },
{ type: "backspace" },
{ type: "check", result: 'abc\\u0022...stu' },
];
assert.sameDeepOrderedMembers(expectedActions, test0.actions, 'Static data in .ts file should match parsed test-fr.xml');
},
}
]);
Expand Down
7 changes: 7 additions & 0 deletions developer/src/kmc-ldml/test/fixtures/test-fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
{
"type": "check",
"result": "abc\\u0022...stuv"
},
{
"type": "backspace"
},
{
"type": "check",
"result": "abc\\u0022...stu"
}
]
}
Expand Down
3 changes: 3 additions & 0 deletions developer/src/kmc-ldml/test/fixtures/test-fr.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE keyboardTest3 SYSTEM "../../../../../resources/standards-data/ldml-keyboards/techpreview/dtd/ldmlKeyboardTest3.dtd">
<keyboardTest3 conformsTo="techpreview">
<!-- Also see the other test-fr.xml in common -->
<info keyboard="fr-t-k0-azerty.xml" author="Team Keyboard" name="fr-test" />
<repertoire name="simple-repertoire" chars="[a b c d e \u{22}]" type="simple" /> <!-- verify that these outputs are all available from simple keys on any layer, for all form factors -->
<repertoire name="chars-repertoire" chars="[á é ó]" type="gesture" /> <!-- verify that these outputs are all available from simple or gesture keys on any layer, for touch -->
Expand All @@ -17,6 +18,8 @@
<!-- tests by specifying 'to' output char -->
<emit to="v"/>
<check result="abc\u0022...stuv" />
<backspace />
<check result="abc\u0022...stu" />
</test>
</tests>
</keyboardTest3>
3 changes: 2 additions & 1 deletion developer/src/kmc-ldml/test/test-testdata-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('testdata-tests', function() {
it('should-build-testdata-fixtures', async function() {
// Let's build test-fr.json
// It should match test-fr.json (built from test-fr.xml)
// Note! There's another test case against similar data, in common/web/types/test/ldml-keyboard/test-ldml-keyboard-testdata-reader.ts

const inputFilename = makePathToFixture('test-fr.xml');
const jsonFilename = makePathToFixture('test-fr.json');
Expand All @@ -19,6 +20,6 @@ describe('testdata-tests', function() {

const jsonData = JSON.parse(readFileSync(jsonFilename, 'utf-8'));

assert.deepEqual(testData, jsonData);
assert.deepEqual(testData, jsonData, 'parsed +test-fr.xml should match -test-fr.json');
});
});
Loading

0 comments on commit 622735b

Please sign in to comment.