From 6ad56d07d1b0ddb080914d59c470be6b48ee74bd Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Tue, 17 Oct 2023 01:20:23 -0700 Subject: [PATCH] chore(private): convert request and builder tests to diagnostic (#9006) --- .eslintrc.js | 21 ++++++- packages/active-record/README.md | 2 +- .../src/-private/builders/find-record.ts | 2 +- .../src/-private/builders/query.ts | 2 +- .../src/-private/builders/save-record.ts | 6 +- packages/active-record/src/request.ts | 2 +- packages/diagnostic/README.md | 18 ++++++ .../diagnostic/server/bun/socket-handler.js | 7 ++- packages/diagnostic/server/default-setup.js | 25 ++++---- packages/diagnostic/server/index.js | 12 +++- .../diagnostic/server/reporters/default.js | 24 +++++++- packages/model/src/-private/model.d.ts | 3 + packages/rest/README.md | 2 +- .../rest/src/-private/builders/find-record.ts | 2 +- packages/rest/src/-private/builders/query.ts | 2 +- .../rest/src/-private/builders/save-record.ts | 6 +- packages/rest/src/request.ts | 2 +- pnpm-lock.yaml | 20 +++---- tests/builders/README.md | 1 + tests/builders/diagnostic.js | 3 + tests/builders/ember-cli-build.js | 5 +- tests/builders/package.json | 14 ++--- tests/builders/testem.js | 30 ---------- tests/builders/tests/index.html | 12 ++-- .../tests/integration/create-record-test.ts | 23 +++---- .../tests/integration/delete-record-test.ts | 29 +++++---- .../tests/integration/update-record-test.ts | 17 ++---- tests/builders/tests/test-helper.js | 60 +++++++++++++++---- .../tests/unit/active-record-builder-test.ts | 7 +-- .../tests/unit/build-base-url-test.ts | 44 +++++++------- .../tests/unit/build-query-params-test.ts | 30 +++++----- .../builders/tests/unit/filter-empty-test.ts | 2 +- .../tests/unit/json-api-builder-test.ts | 5 +- .../tests/unit/parse-cache-control-test.ts | 2 +- .../builders/tests/unit/rest-builder-test.ts | 7 +-- tests/ember-data__request/diagnostic.js | 23 +++++++ tests/ember-data__request/ember-cli-build.js | 4 +- tests/ember-data__request/holodeck.mjs | 2 +- tests/ember-data__request/package.json | 10 ++-- tests/ember-data__request/tests/index.html | 28 --------- .../integration/response-currying-test.ts | 24 ++------ .../tests/integration/response-test.ts | 6 +- .../ember-data__request/tests/test-helper.js | 7 +-- tests/main/holodeck.mjs | 2 +- 44 files changed, 294 insertions(+), 261 deletions(-) create mode 100644 tests/builders/diagnostic.js delete mode 100644 tests/builders/testem.js create mode 100644 tests/ember-data__request/diagnostic.js diff --git a/.eslintrc.js b/.eslintrc.js index f1f82c1f8be..623b72cc9b9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,7 +104,12 @@ module.exports = { }, overrides: [ { - files: ['tests/ember-data__json-api/**', 'tests/ember-data__graph/**', 'tests/ember-data__request/**'], + files: [ + 'tests/ember-data__json-api/**', + 'tests/ember-data__graph/**', + 'tests/ember-data__request/**', + 'tests/builders/**', + ], rules: { 'qunit/no-assert-equal': 'off', 'qunit/no-assert-logical-expression': 'off', @@ -272,6 +277,20 @@ module.exports = { ], }, + // modern node files + { + files: ['tests/*/diagnostic.js'], + parserOptions: { + sourceType: 'module', + ecmaVersion: 2022, + }, + env: { + browser: false, + node: true, + es6: true, + }, + }, + // node files { files: [ diff --git a/packages/active-record/README.md b/packages/active-record/README.md index 19de1dc383e..09e14ecd1eb 100644 --- a/packages/active-record/README.md +++ b/packages/active-record/README.md @@ -46,7 +46,7 @@ const options = findRecord('ember-developer', '1', { include: ['pets', 'friends' => { url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets', method: 'GET', - headers: , // 'Content-Type': 'application/json; charset=utf-8' + headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } diff --git a/packages/active-record/src/-private/builders/find-record.ts b/packages/active-record/src/-private/builders/find-record.ts index e9397707eb1..981dc6685c8 100644 --- a/packages/active-record/src/-private/builders/find-record.ts +++ b/packages/active-record/src/-private/builders/find-record.ts @@ -99,7 +99,7 @@ export function findRecord( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url: options.include?.length diff --git a/packages/active-record/src/-private/builders/query.ts b/packages/active-record/src/-private/builders/query.ts index 5bb34e7afe8..477551537bb 100644 --- a/packages/active-record/src/-private/builders/query.ts +++ b/packages/active-record/src/-private/builders/query.ts @@ -77,7 +77,7 @@ export function query( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url: `${url}?${buildQueryParams(query, options.urlParamsSettings)}`, diff --git a/packages/active-record/src/-private/builders/save-record.ts b/packages/active-record/src/-private/builders/save-record.ts index eb70e5dcdd9..673eb5e5d3c 100644 --- a/packages/active-record/src/-private/builders/save-record.ts +++ b/packages/active-record/src/-private/builders/save-record.ts @@ -91,7 +91,7 @@ export function deleteRecord(record: unknown, options: ConstrainedRequestOptions const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, @@ -160,7 +160,7 @@ export function createRecord(record: unknown, options: ConstrainedRequestOptions const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, @@ -236,7 +236,7 @@ export function updateRecord( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, diff --git a/packages/active-record/src/request.ts b/packages/active-record/src/request.ts index 60695bf6ef2..1f6c37c6b51 100644 --- a/packages/active-record/src/request.ts +++ b/packages/active-record/src/request.ts @@ -35,7 +35,7 @@ const options = findRecord('ember-developer', '1', { include: ['pets', 'friends' => { url: 'https://api.example.com/v1/ember_developers/1?include=friends,pets', method: 'GET', - headers: , // 'Content-Type': 'application/json; charset=utf-8' + headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } diff --git a/packages/diagnostic/README.md b/packages/diagnostic/README.md index 7ee18b61ee0..dc4ee0e3df0 100644 --- a/packages/diagnostic/README.md +++ b/packages/diagnostic/README.md @@ -47,6 +47,7 @@ or you can add your own. - [Using the DOM Reporter](#using-the-domreporter) - [Concurrency](#concurrency) - [Using The Launcher](#using-the-launcher) +- [Adding A Sidecar](#adding-a-sidecar) - [🔜 Parallelism](#parallelism) - [🔜 Randomization](#randomization) - [Why Is It Fast?](#why-is-it-fast) @@ -302,6 +303,23 @@ And update any necessary scripts in `package.json` --- +### Adding A Sidecar + +Diagnostic's launcher supports running additional services alongside your test suite +when they are necessary for your tests to run correctly. For instance, you may want +to start a local API instance, http mock service, or a build process. + +#### Use with @warp-drive/holodeck + +@warp-drive/holodeck is an http mock service for test suites. We can start and stop +the holodeck server along side our test server with an easy integration. + +```ts + +``` + +--- + ### Parallelism [Coming Soon] diff --git a/packages/diagnostic/server/bun/socket-handler.js b/packages/diagnostic/server/bun/socket-handler.js index 93619cecbee..84ed8b2e28e 100644 --- a/packages/diagnostic/server/bun/socket-handler.js +++ b/packages/diagnostic/server/bun/socket-handler.js @@ -5,7 +5,7 @@ import { sinceStart } from "../utils/time.js"; export function buildHandler(config, state) { return { perMessageDeflate: true, - message(ws, message) { + async message(ws, message) { const msg = JSON.parse(message); msg.launcher = state.browsers.get(msg.browserId).launcher; info(`${chalk.green('➡')} [${chalk.cyan(msg.browserId)}/${chalk.cyan(msg.windowId)}] ${chalk.green(msg.name)}`); @@ -39,6 +39,11 @@ export function buildHandler(config, state) { browser.proc.unref(); }); state.server.stop(); + if (config.cleanup) { + debug(`Running configured cleanup hook`); + await config.cleanup(); + debug(`Configured cleanup hook completed`); + } process.exit(exitCode); } diff --git a/packages/diagnostic/server/default-setup.js b/packages/diagnostic/server/default-setup.js index de3aa05ea68..364d7ebd167 100644 --- a/packages/diagnostic/server/default-setup.js +++ b/packages/diagnostic/server/default-setup.js @@ -52,23 +52,26 @@ const SUITE_TIMEOUT = process.env.SUITE_TIMEOUT ? Number(process.env.SUITE_TIMEOUT) - SUITE_TIMEOUT_BUFFER : DEFAULT_SUITE_TIMEOUT; -export default async function launchDefault() { +export default async function launchDefault(overrides = {}) { await launch({ - entry: `./dist-test/tests/index.html?${TEST_PAGE_FLAGS.join('&')}`, - assets: './dist-test', - parallel, - parallelMode: 'window', // 'tab' | 'browser' | 'window' + entry: overrides.entry ?? `./dist-test/tests/index.html?${TEST_PAGE_FLAGS.join('&')}`, + assets: overrides.assets ?? './dist-test', + parallel: overrides.parallel ?? parallel, + parallelMode: overrides.parallelMode ?? 'window', // 'tab' | 'browser' | 'window' - reporter: new DefaultReporter({ + reporter: overrides.reporter ?? new DefaultReporter({ mode: process.env.DIAGNOSTIC_REPORTER_MODE || 'dot', // 'dot' | 'compact' | 'verbose' }), - suiteTimeout: SUITE_TIMEOUT, - browserDisconnectTimeout: 15, - browserStartTimeout: 15, - socketHeartbeatTimeout: 15, + suiteTimeout: overrides.suiteTimeout ?? SUITE_TIMEOUT, + browserDisconnectTimeout: overrides.browserDisconnectTimeout ?? 15, + browserStartTimeout: overrides.browserStartTimeout ?? 15, + socketHeartbeatTimeout: overrides.socketHeartbeatTimeout ?? 15, - launchers: { + setup: overrides.setup ?? (() => {}), + cleanup: overrides.cleanup ?? (() => {}), + + launchers: overrides.launchers ?? { [BROWSER_TAG]: { command: browser, args: recommendedArgs(BROWSER_TAG), diff --git a/packages/diagnostic/server/index.js b/packages/diagnostic/server/index.js index 87d5dcbea21..8742090d9aa 100644 --- a/packages/diagnostic/server/index.js +++ b/packages/diagnostic/server/index.js @@ -12,6 +12,11 @@ const isBun = typeof Bun !== 'undefined'; export default async function launch(config) { if (isBun) { debug(`Bun detected, using Bun.serve()`); + if (config.setup) { + debug(`Running configured setup hook`); + await config.setup(); + debug(`Configured setup hook completed`); + } const { checkPort } = await import('./bun/port.js'); const hostname = config.hostname ?? 'localhost'; const protocol = config.protocol ?? 'http'; @@ -65,9 +70,14 @@ export default async function launch(config) { await launchBrowsers(config, state); } catch (e) { error(`Error: ${e?.message ?? e}`); + if (config.cleanup) { + debug(`Running configured cleanup hook`); + await config.cleanup(); + debug(`Configured cleanup hook completed`); + } throw e; } } else { - throw new Error(`Holodeck is not supported in this environment.`); + throw new Error(`Diagnostic is not supported in this environment.`); } } diff --git a/packages/diagnostic/server/reporters/default.js b/packages/diagnostic/server/reporters/default.js index 292067b2414..c57b9f7c35f 100644 --- a/packages/diagnostic/server/reporters/default.js +++ b/packages/diagnostic/server/reporters/default.js @@ -421,11 +421,11 @@ export default class CustomDotReporter { result.items.forEach((diagnostic) => { this.write(`\t\t${diagnostic.passed ? chalk.green('✅ Pass') : chalk.red('💥 Fail')} ${diagnostic.message}\n`); - if ('expected' in diagnostic && 'actual' in diagnostic) { - this.write(`\n\t\texpected: ${diagnostic.expected}\n\t\tactual: ${diagnostic.actual}\n`); + if (!diagnostic.passed && 'expected' in diagnostic && 'actual' in diagnostic) { + this.write(`\n\t\texpected: ${printValue(diagnostic.expected, 3)}\n\t\tactual: ${printValue(diagnostic.actual, 3)}\n`); } - if (diagnostic.stack) { + if (!diagnostic.passed && diagnostic.stack) { this.write(`\n${indent(diagnostic.stack)}\n`); } }); @@ -498,3 +498,21 @@ export default class CustomDotReporter { function remove(filePath) { fs.writeFileSync(filePath, '', { encoding: 'utf-8' }); } + +function printValue(value, tabs = 0) { + if (typeof value === 'string') { + return value; + } else if (typeof value === 'number') { + return value; + } else if (typeof value === 'boolean') { + return String(value); + } else if (value === null) { + return 'null'; + } else if (value === undefined) { + return 'undefined'; + } else if (Array.isArray(value)) { + return indent(`[\n ${value.map((v) => printValue(v, tabs + 1)).join(',\n ')}\n]`, tabs); + } else if (typeof value === 'object') { + return JSON.stringify(value, null, tabs * 4); + } +} diff --git a/packages/model/src/-private/model.d.ts b/packages/model/src/-private/model.d.ts index 6525673897e..c491dff024d 100644 --- a/packages/model/src/-private/model.d.ts +++ b/packages/model/src/-private/model.d.ts @@ -39,7 +39,10 @@ class Model extends EmberObject { rollbackAttributes(): void; changedAttributes(): Record; [key: string]: unknown; + isSaving: boolean; + isNew: boolean; isDeleted: boolean; + hasDirtyAttributes: boolean; deleteRecord(): void; unloadRecord(): void; serialize(): Record; diff --git a/packages/rest/README.md b/packages/rest/README.md index dcf7b7e5a09..c31d8c9a5e4 100644 --- a/packages/rest/README.md +++ b/packages/rest/README.md @@ -46,7 +46,7 @@ const options = findRecord('ember-developer', '1', { include: ['pets', 'friends' => { url: 'https://api.example.com/v1/emberDevelopers/1?include=friends,pets', method: 'GET', - headers: , // 'Content-Type': 'application/json; charset=utf-8' + headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } diff --git a/packages/rest/src/-private/builders/find-record.ts b/packages/rest/src/-private/builders/find-record.ts index 71dcbe83263..15ea740808e 100644 --- a/packages/rest/src/-private/builders/find-record.ts +++ b/packages/rest/src/-private/builders/find-record.ts @@ -99,7 +99,7 @@ export function findRecord( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url: options.include?.length diff --git a/packages/rest/src/-private/builders/query.ts b/packages/rest/src/-private/builders/query.ts index c3f7af28f31..fb00330ba4d 100644 --- a/packages/rest/src/-private/builders/query.ts +++ b/packages/rest/src/-private/builders/query.ts @@ -77,7 +77,7 @@ export function query( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url: `${url}?${buildQueryParams(query, options.urlParamsSettings)}`, diff --git a/packages/rest/src/-private/builders/save-record.ts b/packages/rest/src/-private/builders/save-record.ts index ca0809e3fff..e9f5e2fe42b 100644 --- a/packages/rest/src/-private/builders/save-record.ts +++ b/packages/rest/src/-private/builders/save-record.ts @@ -91,7 +91,7 @@ export function deleteRecord(record: unknown, options: ConstrainedRequestOptions const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, @@ -160,7 +160,7 @@ export function createRecord(record: unknown, options: ConstrainedRequestOptions const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, @@ -236,7 +236,7 @@ export function updateRecord( const url = buildBaseURL(urlOptions); const headers = new Headers(); - headers.append('Accept', 'application/json; charset=utf-8'); + headers.append('Accept', 'application/json;charset=utf-8'); return { url, diff --git a/packages/rest/src/request.ts b/packages/rest/src/request.ts index 9d1d63258d5..d1c8c34e436 100644 --- a/packages/rest/src/request.ts +++ b/packages/rest/src/request.ts @@ -35,7 +35,7 @@ const options = findRecord('ember-developer', '1', { include: ['pets', 'friends' => { url: 'https://api.example.com/v1/emberDevelopers/1?include=friends,pets', method: 'GET', - headers: , // 'Content-Type': 'application/json; charset=utf-8' + headers: , // 'Content-Type': 'application/json;charset=utf-8' op: 'findRecord'; records: [{ type: 'ember-developer', id: '1' }] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b1b0a87115d..33d28745bee 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1736,6 +1736,9 @@ importers: '@types/ember__owner': specifier: ^4.0.6 version: 4.0.6 + '@warp-drive/diagnostic': + specifier: workspace:5.5.0-alpha.11 + version: file:packages/diagnostic ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.88.2) @@ -1769,9 +1772,6 @@ importers: ember-maybe-import-regenerator: specifier: ^1.0.0 version: 1.0.0(@babel/core@7.23.2) - ember-qunit: - specifier: ^8.0.1 - version: 8.0.1(@babel/core@7.23.2)(@ember/test-helpers@3.2.0)(ember-source@5.3.0)(qunit@2.19.4) ember-resolver: specifier: ^11.0.1 version: 11.0.1(@babel/core@7.23.2)(ember-source@5.3.0) @@ -1784,15 +1784,6 @@ importers: loader.js: specifier: ^4.7.0 version: 4.7.0 - qunit: - specifier: 2.19.4 - version: 2.19.4(patch_hash=h2fz5inojlzu6daraxt5bghsqy) - qunit-console-grouper: - specifier: ^0.3.0 - version: 0.3.0 - qunit-dom: - specifier: ^3.0.0 - version: 3.0.0 silent-error: specifier: ^1.1.1 version: 1.1.1 @@ -1820,6 +1811,8 @@ importers: injected: true '@ember-data/unpublished-test-infra': injected: true + '@warp-drive/diagnostic': + injected: true tests/docs: devDependencies: @@ -2385,6 +2378,9 @@ importers: '@warp-drive/holodeck': specifier: workspace:5.5.0-alpha.11 version: file:packages/holodeck + bun-types: + specifier: ^1.0.6 + version: 1.0.6 ember-auto-import: specifier: ^2.6.3 version: 2.6.3(webpack@5.88.2) diff --git a/tests/builders/README.md b/tests/builders/README.md index 9c4a7ef924e..d506f5d27d5 100644 --- a/tests/builders/README.md +++ b/tests/builders/README.md @@ -2,6 +2,7 @@ Provides testing for the Request and URL Building Utils +- @ember-data/active-record/request - @ember-data/json-api/request - @ember-data/rest/request - @ember-data/request-utils diff --git a/tests/builders/diagnostic.js b/tests/builders/diagnostic.js new file mode 100644 index 00000000000..ede75dbb1ad --- /dev/null +++ b/tests/builders/diagnostic.js @@ -0,0 +1,3 @@ +import launch from '@warp-drive/diagnostic/server/default-setup.js'; + +await launch(); diff --git a/tests/builders/ember-cli-build.js b/tests/builders/ember-cli-build.js index 2fa1e887d48..d4c71986688 100644 --- a/tests/builders/ember-cli-build.js +++ b/tests/builders/ember-cli-build.js @@ -9,6 +9,7 @@ module.exports = function (defaults) { emberData: { compatWith, }, + tests: true, babel: { // this ensures that the same build-time code stripping that is done // for library packages is also done for our tests and dummy app @@ -26,9 +27,6 @@ module.exports = function (defaults) { throwUnlessParallelizable: true, enableTypeScriptTransform: true, }, - 'ember-cli-terser': { - exclude: ['assets/dummy.js', 'assets/tests.js', 'assets/test-support.js'], - }, }); /* @@ -37,6 +35,7 @@ module.exports = function (defaults) { This build file does *not* influence how the addon or the app using it behave. You most likely want to be modifying `./index.js` or app's build file */ + app.import('node_modules/@warp-drive/diagnostic/dist/styles/dom-reporter.css'); return app.toTree(); }; diff --git a/tests/builders/package.json b/tests/builders/package.json index cecd6893eb9..9a7fcbea711 100644 --- a/tests/builders/package.json +++ b/tests/builders/package.json @@ -14,9 +14,9 @@ "test": "tests" }, "scripts": { - "build": "ember build", - "start": "ember test --port=0 --serve --no-launch", - "test": "ember test --test-port=0" + "build": "ember build --output-path=dist-test --suppress-sizes", + "test": "pnpm build && bun ./diagnostic.js", + "test:production": "pnpm build -e production; bun ./diagnostic.js" }, "dependenciesMeta": { "@ember-data/json-api": { @@ -48,6 +48,9 @@ }, "@ember-data/unpublished-test-infra": { "injected": true + }, + "@warp-drive/diagnostic": { + "injected": true } }, "devDependencies": { @@ -72,6 +75,7 @@ "@glimmer/component": "^1.1.2", "@glimmer/tracking": "^1.1.2", "@types/ember__owner": "^4.0.6", + "@warp-drive/diagnostic": "workspace:5.5.0-alpha.11", "ember-auto-import": "^2.6.3", "ember-cli": "~5.3.0", "ember-cli-babel": "^8.2.0", @@ -83,14 +87,10 @@ "ember-inflector": "^4.0.2", "ember-load-initializers": "^2.1.2", "ember-maybe-import-regenerator": "^1.0.0", - "ember-qunit": "^8.0.1", "ember-resolver": "^11.0.1", "ember-source": "~5.3.0", "ember-source-channel-url": "^3.0.0", "loader.js": "^4.7.0", - "qunit": "^2.20.0", - "qunit-console-grouper": "^0.3.0", - "qunit-dom": "^3.0.0", "silent-error": "^1.1.1", "webpack": "^5.88.2" }, diff --git a/tests/builders/testem.js b/tests/builders/testem.js deleted file mode 100644 index a85540f243d..00000000000 --- a/tests/builders/testem.js +++ /dev/null @@ -1,30 +0,0 @@ -/* eslint-disable node/no-unpublished-require */ -const customDotReporter = require('@ember-data/unpublished-test-infra/src/testem/custom-dot-reporter'); - -// eslint-disable-next-line no-console -console.log(`\n\nLaunching with ${process.env.TESTEM_CI_LAUNCHER || 'Chrome'}\n\n`); - -module.exports = { - test_page: 'tests/index.html?hidepassed&nocontainer', - disable_watching: true, - reporter: customDotReporter, - launch_in_ci: [process.env.TESTEM_CI_LAUNCHER || 'Chrome'], - launch_in_dev: ['Chrome'], - browser_start_timeout: 120, - browser_args: { - Chrome: { - ci: [ - '--headless', - '--disable-dev-shm-usage', - '--disable-software-rasterizer', - '--mute-audio', - '--remote-debugging-port=0', - '--window-size=1440,900', - '--no-sandbox', - ], - }, - Firefox: { - ci: ['--headless', '--width=1440', '--height=900'], - }, - }, -}; diff --git a/tests/builders/tests/index.html b/tests/builders/tests/index.html index 86f88bc0808..644b3bd1094 100644 --- a/tests/builders/tests/index.html +++ b/tests/builders/tests/index.html @@ -3,7 +3,7 @@ - Request Builders Tests + Request Builder Tests @@ -12,7 +12,6 @@ - {{content-for "head-footer"}} {{content-for "test-head-footer"}} @@ -21,14 +20,11 @@ {{content-for "body"}} {{content-for "test-body"}} -
-
-
-
-
+
+
+
- diff --git a/tests/builders/tests/integration/create-record-test.ts b/tests/builders/tests/integration/create-record-test.ts index ecb1ee4a378..0c55465f7fe 100644 --- a/tests/builders/tests/integration/create-record-test.ts +++ b/tests/builders/tests/integration/create-record-test.ts @@ -1,6 +1,4 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import JSONAPICache from '@ember-data/json-api'; import { createRecord } from '@ember-data/json-api/request'; @@ -17,6 +15,7 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { @@ -131,8 +130,8 @@ module('Integration - createRecord', function (hooks) { await promise; - assert.strictEqual(user.id, '1', 'The user is updated from the response'); - assert.strictEqual(user.name, 'Chris', 'The user is updated from the response'); + assert.equal(user.id, '1', 'The user is updated from the response'); + assert.equal(user.name, 'Chris', 'The user is updated from the response'); assert.false(user.hasDirtyAttributes, 'The user is no longer dirty'); assert.false(user.isNew, 'The user is no longer new'); assert.false(user.isSaving, 'The user is no longer saving'); @@ -223,15 +222,15 @@ module('Integration - createRecord', function (hooks) { assert.ok(false, 'The promise should reject'); } catch (e: unknown) { assert.true(e instanceof Error, 'The error is an error'); - assert.strictEqual((e as Error).message, 'Something went wrong', 'The error has the expected error message'); + assert.equal((e as Error).message, 'Something went wrong', 'The error has the expected error message'); assert.true( Array.isArray((e as { content: { errors: JsonApiError[] } })?.content?.errors), 'The error has an errors array' ); } - assert.strictEqual(user.id, null, 'The user is not updated from the response'); - assert.strictEqual(user.name, 'John', 'The user is not updated from the response'); + assert.equal(user.id, null, 'The user is not updated from the response'); + assert.equal(user.name, 'John', 'The user is not updated from the response'); assert.true(user.hasDirtyAttributes, 'The user is still dirty'); assert.true(user.isNew, 'The user is still new'); assert.false(user.isDeleted, 'The user is not deleted'); @@ -244,12 +243,8 @@ module('Integration - createRecord', function (hooks) { message: string; }>; - assert.strictEqual(nameErrors.length, 1, 'The user has the expected number of errors'); - assert.strictEqual( - nameErrors[0]?.message, - 'Name must be capitalized', - 'The user has the expected error for the field' - ); + assert.equal(nameErrors.length, 1, 'The user has the expected number of errors'); + assert.equal(nameErrors[0]?.message, 'Name must be capitalized', 'The user has the expected error for the field'); assert.verifySteps([ `willCommit ${identifier.lid}`, diff --git a/tests/builders/tests/integration/delete-record-test.ts b/tests/builders/tests/integration/delete-record-test.ts index 5da75d6cf8e..f40b4e68299 100644 --- a/tests/builders/tests/integration/delete-record-test.ts +++ b/tests/builders/tests/integration/delete-record-test.ts @@ -1,6 +1,4 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import JSONAPICache from '@ember-data/json-api'; import { deleteRecord } from '@ember-data/json-api/request'; @@ -17,6 +15,7 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { @@ -135,8 +134,8 @@ module('Integration - deleteRecord', function (hooks) { assert.true(user.isDeleted, 'The user is deleted'); assert.false(user.isSaving, 'The user is not saving'); assert.true(user.hasDirtyAttributes, 'The user is dirty'); - assert.strictEqual(user.currentState.stateName, 'root.deleted.uncommitted', 'The user is in the correct state'); - assert.strictEqual(user.dirtyType, 'deleted', 'The user is dirty with the correct type'); + assert.equal(user.currentState.stateName, 'root.deleted.uncommitted', 'The user is in the correct state'); + assert.equal(user.dirtyType, 'deleted', 'The user is dirty with the correct type'); const promise = store.request(deleteRecord(user)); assert.true(user.isSaving, 'The user is saving'); @@ -144,16 +143,16 @@ module('Integration - deleteRecord', function (hooks) { await promise; assert.false(user.hasDirtyAttributes, 'The user is not dirty'); - assert.strictEqual(user.currentState.stateName, 'root.deleted.saved', 'The user is in the correct state'); - assert.strictEqual(user.dirtyType, '', 'The user is no longer dirty'); + assert.equal(user.currentState.stateName, 'root.deleted.saved', 'The user is in the correct state'); + assert.equal(user.dirtyType, '', 'The user is no longer dirty'); assert.true(user.isDeleted, 'The user is deleted'); assert.false(user.isSaving, 'The user is no longer saving'); assert.verifySteps([`willCommit ${identifier.lid}`, 'handle deleteRecord request', `didCommit ${identifier.lid}`]); const user2 = store.peekRecord('user', '2') as User; - assert.notStrictEqual(user2, null, 'The user is in the store'); - assert.strictEqual(user2?.name, 'John', 'The user has the expected name'); + assert.notEqual(user2, null, 'The user is in the store'); + assert.equal(user2?.name, 'John', 'The user has the expected name'); }); test('Rejecting while persisting a deletion with a deleteRecord op works as expected', async function (assert) { @@ -231,8 +230,8 @@ module('Integration - deleteRecord', function (hooks) { assert.true(user.isDeleted, 'The user is deleted'); assert.false(user.isSaving, 'The user is not saving'); assert.true(user.hasDirtyAttributes, 'The user is dirty'); - assert.strictEqual(user.currentState.stateName, 'root.deleted.uncommitted', 'The user is in the correct state'); - assert.strictEqual(user.dirtyType, 'deleted', 'The user is dirty with the correct type'); + assert.equal(user.currentState.stateName, 'root.deleted.uncommitted', 'The user is in the correct state'); + assert.equal(user.dirtyType, 'deleted', 'The user is dirty with the correct type'); const validationError: Error & { content: { errors: JsonApiError[] }; @@ -261,7 +260,7 @@ module('Integration - deleteRecord', function (hooks) { assert.ok(false, 'The promise should reject'); } catch (e: unknown) { assert.true(e instanceof Error, 'The error is an error'); - assert.strictEqual((e as Error).message, '405 | Not Authorized', 'The error has the expected error message'); + assert.equal((e as Error).message, '405 | Not Authorized', 'The error has the expected error message'); assert.true( Array.isArray((e as { content: { errors: JsonApiError[] } })?.content?.errors), 'The error has an errors array' @@ -271,9 +270,9 @@ module('Integration - deleteRecord', function (hooks) { assert.false(user.isDestroying, 'The user is not destroying'); assert.false(user.isDestroyed, 'The user is not destroyed'); assert.true(user.hasDirtyAttributes, 'The user is still dirty'); - assert.strictEqual(user.currentState.stateName, 'root.deleted.invalid', 'The user is in the correct state'); - assert.strictEqual(user.dirtyType, 'deleted', 'The user is still dirty'); - assert.strictEqual(user.adapterError?.message, '405 | Not Authorized', 'The user has the expected error message'); + assert.equal(user.currentState.stateName, 'root.deleted.invalid', 'The user is in the correct state'); + assert.equal(user.dirtyType, 'deleted', 'The user is still dirty'); + assert.equal(user.adapterError?.message, '405 | Not Authorized', 'The user has the expected error message'); assert.true(user.isDeleted, 'The user is still deleted'); assert.false(user.isSaving, 'The user is no longer saving'); diff --git a/tests/builders/tests/integration/update-record-test.ts b/tests/builders/tests/integration/update-record-test.ts index d680ff38574..df4a33d3c8a 100644 --- a/tests/builders/tests/integration/update-record-test.ts +++ b/tests/builders/tests/integration/update-record-test.ts @@ -1,6 +1,4 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import JSONAPICache from '@ember-data/json-api'; import { updateRecord } from '@ember-data/json-api/request'; @@ -17,6 +15,7 @@ import type { CacheCapabilitiesManager } from '@ember-data/types/q/cache-store-w import { SingleResourceDocument } from '@ember-data/types/q/ember-data-json-api'; import type { StableExistingRecordIdentifier, StableRecordIdentifier } from '@ember-data/types/q/identifier'; import { JsonApiError } from '@ember-data/types/q/record-data-json-api'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; class TestStore extends DataStore { constructor(args: unknown) { @@ -134,7 +133,7 @@ module('Integration - updateRecord', function (hooks) { await promise; - assert.strictEqual(user.name, 'James Thoburn', 'The user is updated from the response'); + assert.equal(user.name, 'James Thoburn', 'The user is updated from the response'); assert.false(user.hasDirtyAttributes, 'The user is no longer dirty'); assert.false(user.isSaving, 'The user is no longer saving'); @@ -227,7 +226,7 @@ module('Integration - updateRecord', function (hooks) { assert.ok(false, 'The promise should reject'); } catch (e: unknown) { assert.true(e instanceof Error, 'The error is an error'); - assert.strictEqual((e as Error).message, 'Something went wrong', 'The error has the expected error message'); + assert.equal((e as Error).message, 'Something went wrong', 'The error has the expected error message'); assert.true( Array.isArray((e as { content: { errors: JsonApiError[] } })?.content?.errors), 'The error has an errors array' @@ -246,12 +245,8 @@ module('Integration - updateRecord', function (hooks) { message: string; }>; - assert.strictEqual(nameErrors.length, 1, 'The user has the expected number of errors'); - assert.strictEqual( - nameErrors[0]?.message, - 'Name must be capitalized', - 'The user has the expected error for the field' - ); + assert.equal(nameErrors.length, 1, 'The user has the expected number of errors'); + assert.equal(nameErrors[0]?.message, 'Name must be capitalized', 'The user has the expected error for the field'); assert.verifySteps([ `willCommit ${identifier.lid}`, diff --git a/tests/builders/tests/test-helper.js b/tests/builders/tests/test-helper.js index 1b089e27637..7675642ebaf 100644 --- a/tests/builders/tests/test-helper.js +++ b/tests/builders/tests/test-helper.js @@ -1,24 +1,60 @@ import { setApplication } from '@ember/test-helpers'; -import * as QUnit from 'qunit'; +import { setupGlobalHooks } from '@warp-drive/diagnostic'; +import { start } from '@warp-drive/diagnostic/runners/dom'; -import { start } from 'ember-qunit'; - -import configureAsserts from '@ember-data/unpublished-test-infra/test-support/asserts'; +import AbstractTestLoader from 'ember-cli-test-loader/test-support/index'; import Application from '../app'; import config from '../config/environment'; -configureAsserts(QUnit.hooks); +let moduleLoadFailures = []; + +setupGlobalHooks((hooks) => { + hooks.onSuiteFinish(() => { + let length = moduleLoadFailures.length; + + try { + if (length === 0) { + // do nothing + } else if (length === 1) { + throw moduleLoadFailures[0]; + } else { + throw new Error('\n' + moduleLoadFailures.join('\n')); + } + } finally { + // ensure we release previously captured errors. + moduleLoadFailures = []; + } + }); +}); + +export class TestLoader extends AbstractTestLoader { + moduleLoadFailure(moduleName, error) { + moduleLoadFailures.push(error); + } +} -setApplication(Application.create(config.APP)); +/** + Load tests following the default patterns: -QUnit.config.testTimeout = 2000; + * The module name ends with `-test` + * The module name ends with `.jshint` + @method loadTests + */ +export function loadTests() { + new TestLoader().loadModules(); +} + +loadTests(); + +setApplication(Application.create(config.APP)); start({ - setupTestIsolationValidation: true, - setupTestContainer: false, - setupTestAdapter: false, - setupEmberTesting: false, - setupEmberOnerrorValidation: false, + tryCatch: false, + debug: false, + groupLogs: false, + instrument: true, + hideReport: true, + useDiagnostic: true, }); diff --git a/tests/builders/tests/unit/active-record-builder-test.ts b/tests/builders/tests/unit/active-record-builder-test.ts index 9e3b24d08a7..bf7dd499d1b 100644 --- a/tests/builders/tests/unit/active-record-builder-test.ts +++ b/tests/builders/tests/unit/active-record-builder-test.ts @@ -1,15 +1,14 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { createRecord, deleteRecord, findRecord, query, updateRecord } from '@ember-data/active-record/request'; import { setBuildURLConfig } from '@ember-data/request-utils'; import Store, { recordIdentifierFor } from '@ember-data/store'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; -const ACTIVE_RECORD_HEADERS = { accept: 'application/json; charset=utf-8' }; +const ACTIVE_RECORD_HEADERS = { accept: 'application/json;charset=utf-8' }; module('ActiveRecord | Request Builders', function (hooks) { setupTest(hooks); diff --git a/tests/builders/tests/unit/build-base-url-test.ts b/tests/builders/tests/unit/build-base-url-test.ts index b21d794145d..c289dee2bb9 100644 --- a/tests/builders/tests/unit/build-base-url-test.ts +++ b/tests/builders/tests/unit/build-base-url-test.ts @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { buildBaseURL, setBuildURLConfig } from '@ember-data/request-utils'; import { test as debug } from '@ember-data/unpublished-test-infra/test-support/test-in-debug'; @@ -9,7 +9,7 @@ module('buildBaseURL', function (hooks) { }); test('simple cases (no optional options and no global config)', function (assert) { - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRecord', identifier: { type: 'user', id: '1' }, @@ -17,7 +17,7 @@ module('buildBaseURL', function (hooks) { '/user/1', `buildBaseURL works for findRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'updateRecord', identifier: { type: 'user', id: '1' }, @@ -26,7 +26,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for updateRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'deleteRecord', identifier: { type: 'user', id: '1' }, @@ -35,7 +35,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for deleteRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -45,7 +45,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for findRelatedRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedCollection', identifier: { type: 'user', id: '1' }, @@ -55,7 +55,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for findRelatedCollection` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'query', identifier: { type: 'user' }, @@ -64,7 +64,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for query` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findMany', identifiers: [ @@ -78,7 +78,7 @@ module('buildBaseURL', function (hooks) { }); test('resourcePath (no global config)', function (assert) { - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRecord', identifier: { type: 'user', id: '1' }, @@ -87,7 +87,7 @@ module('buildBaseURL', function (hooks) { '/people/1', `buildBaseURL works for findRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'updateRecord', identifier: { type: 'user', id: '1' }, @@ -97,7 +97,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for updateRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'deleteRecord', identifier: { type: 'user', id: '1' }, @@ -107,7 +107,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for deleteRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -118,7 +118,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for findRelatedRecord` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedCollection', identifier: { type: 'user', id: '1' }, @@ -129,7 +129,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for findRelatedCollection` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'query', identifier: { type: 'user' }, @@ -139,7 +139,7 @@ module('buildBaseURL', function (hooks) { `buildBaseURL works for query` ); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findMany', identifiers: [ @@ -154,7 +154,7 @@ module('buildBaseURL', function (hooks) { }); test('namespace uses local when present (no global config)', function (assert) { - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -169,7 +169,7 @@ module('buildBaseURL', function (hooks) { test('namespace (global config)', function (assert) { setBuildURLConfig({ namespace: 'api/v2', host: '' }); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -183,7 +183,7 @@ module('buildBaseURL', function (hooks) { test('namespace uses local when present (global config)', function (assert) { setBuildURLConfig({ namespace: 'api/v2', host: '' }); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -197,7 +197,7 @@ module('buildBaseURL', function (hooks) { }); test('host uses local when present (no global config)', function (assert) { - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -212,7 +212,7 @@ module('buildBaseURL', function (hooks) { test('host (global config)', function (assert) { setBuildURLConfig({ namespace: '', host: 'https://api2.example.com' }); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -226,7 +226,7 @@ module('buildBaseURL', function (hooks) { test('host uses local when present (global config)', function (assert) { setBuildURLConfig({ namespace: '', host: 'https://api2.example.com' }); - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, @@ -240,7 +240,7 @@ module('buildBaseURL', function (hooks) { }); test('host may start with a /', function (assert) { - assert.strictEqual( + assert.equal( buildBaseURL({ op: 'findRelatedRecord', identifier: { type: 'user', id: '1' }, diff --git a/tests/builders/tests/unit/build-query-params-test.ts b/tests/builders/tests/unit/build-query-params-test.ts index 3d682bbe44e..82c1bf078ba 100644 --- a/tests/builders/tests/unit/build-query-params-test.ts +++ b/tests/builders/tests/unit/build-query-params-test.ts @@ -1,10 +1,10 @@ -import { module, test } from 'qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { buildQueryParams } from '@ember-data/request-utils'; module('buildQueryParams', function (hooks) { test('It serializes objects with stable key order', function (assert) { - assert.strictEqual( + assert.equal( buildQueryParams({ foo: 'bar', baz: 'qux', @@ -12,7 +12,7 @@ module('buildQueryParams', function (hooks) { 'baz=qux&foo=bar', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams({ baz: 'qux', foo: 'bar', @@ -30,12 +30,12 @@ module('buildQueryParams', function (hooks) { params2.append('baz', 'qux'); params2.append('foo', 'bar'); - assert.strictEqual(buildQueryParams(params1), 'baz=qux&foo=bar', `buildQueryParams works`); - assert.strictEqual(buildQueryParams(params2), 'baz=qux&foo=bar', `buildQueryParams works`); + assert.equal(buildQueryParams(params1), 'baz=qux&foo=bar', `buildQueryParams works`); + assert.equal(buildQueryParams(params2), 'baz=qux&foo=bar', `buildQueryParams works`); }); test('It serializes objects with stable value order', function (assert) { - assert.strictEqual( + assert.equal( buildQueryParams({ foo: ['c', 'b', 'a'], baz: ['f', 'd', 'e'], @@ -43,7 +43,7 @@ module('buildQueryParams', function (hooks) { 'baz=d%2Ce%2Cf&foo=a%2Cb%2Cc', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams({ foo: ['c', 'b', 'a'], baz: ['f', 'd', 'e'], @@ -69,19 +69,19 @@ module('buildQueryParams', function (hooks) { params2.append('baz', 'd'); params2.append('baz', 'e'); - assert.strictEqual(buildQueryParams(params1), 'baz=d%2Ce%2Cf&foo=a%2Cb%2Cc', `buildQueryParams works`); - assert.strictEqual(buildQueryParams(params2), 'baz=d%2Ce%2Cf&foo=a%2Cb%2Cc', `buildQueryParams works`); + assert.equal(buildQueryParams(params1), 'baz=d%2Ce%2Cf&foo=a%2Cb%2Cc', `buildQueryParams works`); + assert.equal(buildQueryParams(params2), 'baz=d%2Ce%2Cf&foo=a%2Cb%2Cc', `buildQueryParams works`); }); test('It special cases object.include', function (assert) { - assert.strictEqual( + assert.equal( buildQueryParams({ include: ['foo', 'bar'], }), 'include=bar%2Cfoo', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams({ include: 'foo,bar', }), @@ -91,7 +91,7 @@ module('buildQueryParams', function (hooks) { }); test('It allows for customizing the arrayFormat', function (assert) { - assert.strictEqual( + assert.equal( buildQueryParams( { foo: ['c', 'b', 'a'], @@ -102,7 +102,7 @@ module('buildQueryParams', function (hooks) { 'baz%5B%5D=d&baz%5B%5D=e&baz%5B%5D=f&foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams( { foo: ['c', 'b', 'a'], @@ -113,7 +113,7 @@ module('buildQueryParams', function (hooks) { 'baz%5B0%5D=d&baz%5B1%5D=e&baz%5B2%5D=f&foo%5B0%5D=a&foo%5B1%5D=b&foo%5B2%5D=c', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams( { foo: ['c', 'b', 'a'], @@ -124,7 +124,7 @@ module('buildQueryParams', function (hooks) { 'baz=d&baz=e&baz=f&foo=a&foo=b&foo=c', `buildQueryParams works` ); - assert.strictEqual( + assert.equal( buildQueryParams( { foo: ['c', 'b', 'a'], diff --git a/tests/builders/tests/unit/filter-empty-test.ts b/tests/builders/tests/unit/filter-empty-test.ts index fa1c975cba9..8f4aae4e9b5 100644 --- a/tests/builders/tests/unit/filter-empty-test.ts +++ b/tests/builders/tests/unit/filter-empty-test.ts @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { filterEmpty } from '@ember-data/request-utils'; diff --git a/tests/builders/tests/unit/json-api-builder-test.ts b/tests/builders/tests/unit/json-api-builder-test.ts index 79992d1ae38..592770370e4 100644 --- a/tests/builders/tests/unit/json-api-builder-test.ts +++ b/tests/builders/tests/unit/json-api-builder-test.ts @@ -1,10 +1,9 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { createRecord, deleteRecord, findRecord, postQuery, query, updateRecord } from '@ember-data/json-api/request'; import { setBuildURLConfig } from '@ember-data/request-utils'; import Store, { recordIdentifierFor } from '@ember-data/store'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; diff --git a/tests/builders/tests/unit/parse-cache-control-test.ts b/tests/builders/tests/unit/parse-cache-control-test.ts index a4ab7a181cb..ead2c543b15 100644 --- a/tests/builders/tests/unit/parse-cache-control-test.ts +++ b/tests/builders/tests/unit/parse-cache-control-test.ts @@ -1,4 +1,4 @@ -import { module, test } from 'qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { parseCacheControl } from '@ember-data/request-utils'; import { test as debug } from '@ember-data/unpublished-test-infra/test-support/test-in-debug'; diff --git a/tests/builders/tests/unit/rest-builder-test.ts b/tests/builders/tests/unit/rest-builder-test.ts index c9604f2cdeb..c913e694caa 100644 --- a/tests/builders/tests/unit/rest-builder-test.ts +++ b/tests/builders/tests/unit/rest-builder-test.ts @@ -1,15 +1,14 @@ -import { module, test } from 'qunit'; - -import { setupTest } from 'ember-qunit'; +import { module, test } from '@warp-drive/diagnostic'; import { setBuildURLConfig } from '@ember-data/request-utils'; import { createRecord, deleteRecord, findRecord, query, updateRecord } from '@ember-data/rest/request'; import Store, { recordIdentifierFor } from '@ember-data/store'; +import { setupTest } from '@ember-data/unpublished-test-infra/test-support/test-helpers'; import UserSetting from '../../app/models/user-setting'; import { headersToObject } from '../helpers/utils'; -const REST_HEADERS = { accept: 'application/json; charset=utf-8' }; +const REST_HEADERS = { accept: 'application/json;charset=utf-8' }; module('REST | Request Builders', function (hooks) { setupTest(hooks); diff --git a/tests/ember-data__request/diagnostic.js b/tests/ember-data__request/diagnostic.js new file mode 100644 index 00000000000..b207883e528 --- /dev/null +++ b/tests/ember-data__request/diagnostic.js @@ -0,0 +1,23 @@ +/* global Bun */ +import launch from '@warp-drive/diagnostic/server/default-setup.js'; + +/** @type {import('bun-types')} */ + +await launch({ + async setup() { + Bun.spawnSync(['holodeck', 'start'], { + env: process.env, + cwd: process.cwd(), + stdout: 'inherit', + stderr: 'inherit', + }); + }, + async cleanup() { + Bun.spawnSync(['holodeck', 'end'], { + env: process.env, + cwd: process.cwd(), + stdout: 'inherit', + stderr: 'inherit', + }); + }, +}); diff --git a/tests/ember-data__request/ember-cli-build.js b/tests/ember-data__request/ember-cli-build.js index 48dfcde5d3a..d4c71986688 100644 --- a/tests/ember-data__request/ember-cli-build.js +++ b/tests/ember-data__request/ember-cli-build.js @@ -9,6 +9,7 @@ module.exports = function (defaults) { emberData: { compatWith, }, + tests: true, babel: { // this ensures that the same build-time code stripping that is done // for library packages is also done for our tests and dummy app @@ -26,9 +27,6 @@ module.exports = function (defaults) { throwUnlessParallelizable: true, enableTypeScriptTransform: true, }, - 'ember-cli-terser': { - exclude: ['assets/dummy.js', 'assets/tests.js', 'assets/test-support.js'], - }, }); /* diff --git a/tests/ember-data__request/holodeck.mjs b/tests/ember-data__request/holodeck.mjs index afd202cd216..9f9784e0dd7 100644 --- a/tests/ember-data__request/holodeck.mjs +++ b/tests/ember-data__request/holodeck.mjs @@ -4,6 +4,6 @@ import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); -createServer({ +export default createServer({ projectRoot: __dirname, }); diff --git a/tests/ember-data__request/package.json b/tests/ember-data__request/package.json index d139dd58da6..c836b052edd 100644 --- a/tests/ember-data__request/package.json +++ b/tests/ember-data__request/package.json @@ -14,12 +14,9 @@ "test": "tests" }, "scripts": { - "build": "ember build", - "holodeck:start-program": "holodeck start", - "holodeck:end-program": "holodeck end", - "launch:tests": "ember test --port=0 --serve --no-launch", - "start": "holodeck run pnpm launch:tests", - "test": "holodeck run ember test --test-port=0" + "build": "ember build --output-path=dist-test --suppress-sizes", + "test": "pnpm build && bun ./diagnostic.js", + "test:production": "pnpm build -e production; bun ./diagnostic.js" }, "dependenciesMeta": { "@warp-drive/diagnostic": { @@ -72,6 +69,7 @@ "ember-source-channel-url": "^3.0.0", "ember-try": "^3.0.0", "loader.js": "^4.7.0", + "bun-types": "^1.0.6", "silent-error": "^1.1.1", "webpack": "^5.88.2" }, diff --git a/tests/ember-data__request/tests/index.html b/tests/ember-data__request/tests/index.html index 44371a1c0fe..bb9ca9edb6e 100644 --- a/tests/ember-data__request/tests/index.html +++ b/tests/ember-data__request/tests/index.html @@ -25,34 +25,6 @@
- - diff --git a/tests/ember-data__request/tests/integration/response-currying-test.ts b/tests/ember-data__request/tests/integration/response-currying-test.ts index 5e820a50347..69267236137 100644 --- a/tests/ember-data__request/tests/integration/response-currying-test.ts +++ b/tests/ember-data__request/tests/integration/response-currying-test.ts @@ -40,14 +40,10 @@ module('RequestManager | Response Currying', function () { ok: true, redirected: false, headers: [ - ['accept-ranges', 'bytes'], - ['cache-control', 'public, max-age=0'], - ['content-type', 'application/json; charset=UTF-8'], + ['content-type', 'application/json;charset=utf-8'], // ['date', 'Wed, 23 Nov 2022 05:17:11 GMT'], // ['etag', 'W/"39-1849db13af9"'], // ['last-modified', 'Tue, 22 Nov 2022 04:55:48 GMT'], - ['vary', 'Accept-Encoding'], - ['x-powered-by', 'Express'], ], status: 200, statusText: 'OK', @@ -112,14 +108,10 @@ module('RequestManager | Response Currying', function () { ok: true, redirected: false, headers: [ - ['accept-ranges', 'bytes'], - ['cache-control', 'public, max-age=0'], - ['content-type', 'application/json; charset=UTF-8'], + ['content-type', 'application/json;charset=utf-8'], // ['date', 'Wed, 23 Nov 2022 05:17:11 GMT'], // ['etag', 'W/"39-1849db13af9"'], // ['last-modified', 'Tue, 22 Nov 2022 04:55:48 GMT'], - ['vary', 'Accept-Encoding'], - ['x-powered-by', 'Express'], ], status: 200, statusText: 'OK', @@ -166,14 +158,10 @@ module('RequestManager | Response Currying', function () { ok: false, redirected: false, headers: [ - ['accept-ranges', 'bytes'], - ['cache-control', 'public, max-age=0'], - ['content-type', 'application/json; charset=UTF-8'], + ['content-type', 'application/json;charset=utf-8'], // ['date', 'Wed, 23 Nov 2022 05:17:11 GMT'], // ['etag', 'W/"39-1849db13af9"'], // ['last-modified', 'Tue, 22 Nov 2022 04:55:48 GMT'], - ['vary', 'Accept-Encoding'], - ['x-powered-by', 'Express'], ], status: 200, statusText: 'OK', @@ -233,14 +221,10 @@ module('RequestManager | Response Currying', function () { ok: true, redirected: false, headers: [ - ['accept-ranges', 'bytes'], - ['cache-control', 'public, max-age=0'], - ['content-type', 'application/json; charset=UTF-8'], + ['content-type', 'application/json;charset=utf-8'], // ['date', 'Wed, 23 Nov 2022 05:17:11 GMT'], // ['etag', 'W/"39-1849db13af9"'], // ['last-modified', 'Tue, 22 Nov 2022 04:55:48 GMT'], - ['vary', 'Accept-Encoding'], - ['x-powered-by', 'Express'], ], status: 200, statusText: 'OK', diff --git a/tests/ember-data__request/tests/integration/response-test.ts b/tests/ember-data__request/tests/integration/response-test.ts index 9a47f717682..d98b7617f34 100644 --- a/tests/ember-data__request/tests/integration/response-test.ts +++ b/tests/ember-data__request/tests/integration/response-test.ts @@ -34,14 +34,10 @@ module('RequestManager | Response', function () { ok: true, redirected: false, headers: [ - ['accept-ranges', 'bytes'], - ['cache-control', 'public, max-age=0'], - ['content-type', 'application/json; charset=UTF-8'], + ['content-type', 'application/json;charset=utf-8'], // ['date', 'Wed, 23 Nov 2022 05:17:11 GMT'], // ['etag', 'W/"39-1849db13af9"'], // ['last-modified', 'Tue, 22 Nov 2022 04:55:48 GMT'], - ['vary', 'Accept-Encoding'], - ['x-powered-by', 'Express'], ], status: 200, statusText: 'OK', diff --git a/tests/ember-data__request/tests/test-helper.js b/tests/ember-data__request/tests/test-helper.js index 83a5f436843..1177647b20b 100644 --- a/tests/ember-data__request/tests/test-helper.js +++ b/tests/ember-data__request/tests/test-helper.js @@ -1,4 +1,4 @@ -import { configure, setupGlobalHooks } from '@warp-drive/diagnostic'; +import { setupGlobalHooks } from '@warp-drive/diagnostic'; import { start } from '@warp-drive/diagnostic/runners/dom'; import { setTestId } from '@warp-drive/holodeck'; @@ -56,13 +56,12 @@ export function loadTests() { loadTests(); -configure({ +start({ tryCatch: false, debug: false, concurrency: 10, groupLogs: false, instrument: true, hideReport: true, + useDiagnostic: true, }); - -start(); diff --git a/tests/main/holodeck.mjs b/tests/main/holodeck.mjs index b3aef1e4ef9..1a7c32da003 100644 --- a/tests/main/holodeck.mjs +++ b/tests/main/holodeck.mjs @@ -4,7 +4,7 @@ import { fileURLToPath } from 'url'; const __dirname = dirname(fileURLToPath(import.meta.url)); -createServer({ +export default createServer({ projectRoot: __dirname, port: 1136, });