This change explicitly specifies the return types and access for the
functions in KeymanEngine. Also introduce `KeyboardDetails` instead of
`ReturnType<>`.
Test-bot: skip
VSCode shows red squiggles under things like `describe` or `it` in
.ts test files for web. This change adds the types to the `tsconfig.json`
file which fixes this problem.
Build-bot: skip build:web
Test-bot: skip
This change appends the filename to the description of the tests on
the index page of the manual web tests. This makes it easier to find
the test on the rendered index page when having the directory name
of the test available.
Build-bot: skip
Test-bot: skip
To reduce the number of possible failure cases within KeymanWeb,
require variableStoreSerializer to always be initialized. This impacts
only unit tests in practice. There remains a unit test special case in
the variable store code itself which needs to be removed in the future.
Create a mock VariableStoreTestSerializer class so that unit tests can
run without impacting state or requiring cookies. (We should leverage
this in future tests to verify that variable stores are saved
correctly.)
Establish keyman/test/headless-resources, so that we can include shared
resources such as VariableStoreTestSerializer without creating a
dependency on either DOM or Node.
- inline consts so that we don't have to export them for unit testing
- create `getKeymanRoot` and `getWebTestResourcesPath` helper functions
to DRY out the code
- run `languageProcessortests.js` without coverage to prevent a failure
creating the coverage report.
Simplify usage of `TestCompilerCallbacks` by making it responsible for
the `beforeEach` and `afterEach` incantations itself. There are a couple
of more complex usages of `TestCompilerCallbacks` which have been
excluded from this change on purpose.
Renamed `testCallbacks` to `callbacks` in the one place where it was
different.
Hoist @types/node and @types/mocha because inconsistent versions of
@types/mocha were causing compiler errors with this change.
Also added a cast to `fs.readFileSync` to `Uint8Array` to eliminate
compiler warnings/errors in test files.
Fixes: #15654
Test-bot: skip
The command shortcuts that were used by Web
scripts to create bundles via `esbuild` were not
properly handling the $KEYMAN_ROOT path when it
contained a space. These changes will rectify
this behavior and permit builds for such cases.
Build-bot: skip build:web
Test-bot: skip
This change stubs out `KMXKeyboard.isRTL` and adds a unit test for RTL
with .js and .kmx (currently skipped) keyboards. Also change some code
to use `Keyboard` instead of `JSKeyboard` and stub out additional methods.
The RTL functionality will have to be completed when the necessary
extensions to the Core API are implemented (#15482).
Fixes: #15288
Test-bot: skip
PR #15093 merged multiple engine modules into one. However, in doing so
we lost the .js tests and ran only the .ts ones. This change re-adds the
.js tests and fixes them where the code diverged since then.
Other changes:
- rename `queryEngine.ts` to `cloudQueryEngine.ts` to match the class name
- remove unused `keyboard-storage/cloud/index.ts`
- expose `CLOUD_TIMEOUT_ERR` and `CLOUD_STUB_REGISTRATION_ERR` as
`unitTestEndpoints`
- add `test/resources` to exports in `web/package.json`. This was necessary
because the compiled .ts test files are under `web/build` whereas the
.js test files are under `web/src` and so the relative paths in imports
no longer work. Also fix the imports in test files.
- apply fix from #15477 if KEYMAN_ROOT is not set
I'm not happy to put the compiled files under
`web/src/test/auto/resources/build`, but that's the only way I got it
to work. If I put the compiled files in `web/build/test/resources` it
couldn't find the types for `promise-status-async`.
Also, running the .js tests succeeded but then creating the coverage
report failed. I was not able to find the reason or a fix for that. As a
hack to work around this problem we check the number of failed tests
instead of relying on the exit code of the test.
Follows: #15093
Test-bot: skip
fix(web): fix problem with tests if KEYMAN_ROOT is not set 🎼
When running mocha without starting it through `build.sh`/`test.sh` the tests failed if the `KEYMAN_ROOT` environment variable was not set. Things were almost correct, but the undefined `KEYMAN_ROOT` variable added an extra `undefined` subdirectory. This change fixes this problem by setting `KEYMAN_ROOT` relative to the current file. This gets removed by `pathToFileURL` which also adds the absolute path to the current directory since we pass a relative path as argument.
refactor(web): refactor `ProcessorInitOptions` 📏🎼
This addresses a web-core TODO comment.
This change makes the `options` parameter in the `JSKeyboardProcessor` constructor no longer optional. Also `baseLayout` and `defaultOutputRules` are now required in `ProcessorInitOptions`. For testing purposes we export `DEFAULT_OPTIONS` in a testing endpoint.
The `options` parameter in the `InputProcessor` constructor is no longer optional. Also removes the `DEFAULT_OPTIONS` from
`InputProcessor`.
This change also moves the `ProcessorInitOptions` interface to a separate file and makes `keyboardInterface` a required field.
An alternative approach would have been to get rid of `ProcessorInitOptions` and instead set the `JSKeyboardProcessor` fields after creating the instance. Doing it the implemented way seemed cleaner.
When running mocha without starting it through `build.sh`/`test.sh`
the tests failed if the `KEYMAN_ROOT` environment variable was not set.
Things were almost correct, but the undefined `KEYMAN_ROOT` variable
added an extra `undefined` subdirectory. This change fixes this problem
by setting `KEYMAN_ROOT` to the current directory (`.`). This gets
removed by `pathToFileURL` which also adds the absolute path to the
current directory since we pass a relative path as argument.
Build-bot: skip
Test-bot: skip