<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #34635 # Details This PR switches us to a [fork of node-sql-parser](https://github.com/sgress454/node-sql-parser) that I'm maintaining to fast-track fixes to the SQLite implementation. The first published version of the fork is 5.4.0-fork.1 (forked from v5.4.0 of the upstream), and includes fixes for #34635 and #30109 that haven't made it to the upstream yet. Fixes in 5.4.0-fork.1: * https://github.com/sgress454/node-sql-parser/pull/7 * https://github.com/sgress454/node-sql-parser/pull/5 * https://github.com/sgress454/node-sql-parser/pull/4 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [X] Added/updated automated tests - Granular tests are added [in the package itself](https://github.com/sgress454/node-sql-parser/blob/5.4.0-fork.1/test/sqlite.spec.js), and new regression tests for the Fleet issues are added in the Fleet. - [X] QA'd all new/changed functionality manually - Pasted the offending queries into the editor and saw no syntax errors |
||
|---|---|---|
| .. | ||
| handlers | ||
| default-handlers.ts | ||
| jest.config.js | ||
| mock-server.ts | ||
| README.md | ||
| stubs.ts | ||
| test-setup.ts | ||
| test-utils.tsx | ||
Fleet UI tests
The test directory contains the jest configuration, test setup, request handlers, mock server definition, testing utilities, and entity stubs (deprecated and will be replaced by mocks in frontend/__mocks__) for use in test files throughout the application. The test files for components and app functions are located in the same directory as the files they test.
Table of contents
- Jest configuration
- Test setup
- Request handlers and their setup
- Testing utilities
- Entity stubs (deprecated)
- Related links
Jest configuration
This is where the jest configuration is located. Refer to Jest's official documentation.
Test setup
This file configures the testing environment for every test file.
Request handlers and their setup
Default handlers and custom handlers are both defined within the handlers directory and return mocked data. The handlers directory will naturally grow with more default and custom handlers required for more tests. We use mock service worker to define all request handlers.
Default handlers and custom handlers differ in their setup. Default handlers are setup in mock-server.ts. The mock server will serve the default handlers outlined in default-handlers.ts. Custom handlers must be setup inline within a component's test suite (frontend/**/ComponentName.tests.tsx). For example, we would setup the custom handler activityHandler9Activities inline using mockServer.use(activityHandler9Activities);.
Testing utilities
We use various utility functions to write our tests.
Testing stubs Deprecated
Testing stubs are still being used in a handful of old tests. We are no longer following this pattern of adding data to testing stubs. Rather, we are building stubs as mocks located in the frontend/__mocks__ directory.
Related links
Check out how we mock data used for unit and integration tests.
Follow this guide to run tests locally.
Visit the frontend overview of Fleet UI testing for more information on our testing strategy, philosophies, and tools.