+ I expect to be blue +
+ +); \ No newline at end of file diff --git a/tests/fixture-ts/testem-proxy.js b/tests/fixture-ts/testem-proxy.js new file mode 100644 index 0000000..d688f53 --- /dev/null +++ b/tests/fixture-ts/testem-proxy.js @@ -0,0 +1,36 @@ +/* eslint-disable */ +const httpProxy = require('http-proxy'); + +/* + This can be installed as a testem middleware to make testem run against an + arbitrary real webserver at targetURL. + + It allows testem to handle the well-known testem-specific paths and proxies + everything else, while rewriting the testem-added prefix out of your + "/tests/index.html" URL. +*/ + +module.exports = function testemProxy(targetURL) { + return function testemProxyHandler(app) { + const proxy = httpProxy.createProxyServer({ + changeOrigin: true, + ignorePath: true, + }); + + proxy.on('error', (err, _req, res) => { + res && res.status && res.status(500).json(err); + }); + + app.all('*', (req, res, next) => { + let url = req.url; + if (url === '/testem.js' || url.startsWith('/testem/')) { + return next(); + } + let m = /^(\/\d+)\/tests\/index.html/.exec(url); + if (m) { + url = url.slice(m[1].length); + } + proxy.web(req, res, { target: targetURL + url }); + }); + }; +}; diff --git a/tests/fixture-ts/tests/acceptance/app-init-test.ts b/tests/fixture-ts/tests/acceptance/app-init-test.ts new file mode 100644 index 0000000..e65bc63 --- /dev/null +++ b/tests/fixture-ts/tests/acceptance/app-init-test.ts @@ -0,0 +1,22 @@ +/* eslint-disable @typescript-eslint/no-unsafe-member-access */ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { module, test } from 'qunit'; +import { getApplication } from '@ember/test-helpers'; +import { assert as debugAssert } from '@ember/debug'; +import { setupApplicationTest } from '<%= name %>/tests/helpers'; + +module('Acceptance | app route', function (hooks) { + setupApplicationTest(hooks); + + test('loaded initializers /', function (assert) { + const app = getApplication(); + + debugAssert(`App failed to initialize`, app); + + assert.strictEqual( + ([...app._applicationInstances][0] as any).__instance_test_init, + 'set in the instance initializer', + ); + assert.strictEqual((app as any).__test_init, 'coming from the initializer'); + }); +}); diff --git a/tests/fixture-ts/tests/acceptance/custom-component-test.ts b/tests/fixture-ts/tests/acceptance/custom-component-test.ts new file mode 100644 index 0000000..24e6db0 --- /dev/null +++ b/tests/fixture-ts/tests/acceptance/custom-component-test.ts @@ -0,0 +1,14 @@ +import { module, test } from 'qunit'; +import { visit, currentURL } from '@ember/test-helpers'; +import { setupApplicationTest } from '<%= name %>/tests/helpers'; + +module('Acceptance | custom-component page', function (hooks) { + setupApplicationTest(hooks); + + test('visiting /custom-component', async function (assert) { + await visit('/custom-component'); + + assert.strictEqual(currentURL(), '/custom-component'); + assert.dom('#custom-component').containsText('I am a custom component'); + }); +}) diff --git a/tests/fixture-ts/tests/acceptance/styles-test.ts b/tests/fixture-ts/tests/acceptance/styles-test.ts new file mode 100644 index 0000000..00169a5 --- /dev/null +++ b/tests/fixture-ts/tests/acceptance/styles-test.ts @@ -0,0 +1,18 @@ +import { module, test } from 'qunit'; +import { visit } from '@ember/test-helpers'; +import { setupApplicationTest } from '<%= name %>/tests/helpers'; + +module('Acceptance | styles', function (hooks) { + setupApplicationTest(hooks); + + test('visiting /styles', async function (assert) { + await visit('/styles'); + + assert.dom('.styles-test').hasStyle( + { + 'background-color': 'rgb(0, 0, 255)', + }, + 'The background should be blue if the app styles are working correctly', + ); + }); +}); diff --git a/tests/fixture-ts/tests/acceptance/welcome-page-test.ts b/tests/fixture-ts/tests/acceptance/welcome-page-test.ts new file mode 100644 index 0000000..0ace2f3 --- /dev/null +++ b/tests/fixture-ts/tests/acceptance/welcome-page-test.ts @@ -0,0 +1,14 @@ +import { module, test } from 'qunit'; +import { visit, currentURL } from '@ember/test-helpers'; +import { setupApplicationTest } from '<%= name %>/tests/helpers'; + +module('Acceptance | welcome page', function (hooks) { + setupApplicationTest(hooks); + + test('visiting /index shows the welcome page', async function (assert) { + await visit('/'); + + assert.strictEqual(currentURL(), '/'); + assert.dom('h1').containsText('Congratulations, you made it!'); + }); +}); diff --git a/tests/fixture/app/router.ts b/tests/fixture/app/router.ts new file mode 100644 index 0000000..8a5b048 --- /dev/null +++ b/tests/fixture/app/router.ts @@ -0,0 +1,12 @@ +import EmberRouter from '@ember/routing/router'; +import config from '<%= name %>/config/environment'; + +export default class Router extends EmberRouter { + location = config.locationType; + rootURL = config.rootURL; +} + +Router.map(function () { + this.route('styles'); + this.route('custom-component'); +}); diff --git a/tests/typescript.test.mjs b/tests/typescript.test.mjs new file mode 100644 index 0000000..e308cc0 --- /dev/null +++ b/tests/typescript.test.mjs @@ -0,0 +1,24 @@ +import { describe, it, expect } from 'vitest'; +import { join } from 'path'; +import { existsSync } from 'fs'; +import { newProjectWithFixtures } from './helpers.mjs'; + +describe('typescript', function () { + let project = newProjectWithFixtures({ + fixturePath: join(__dirname, 'fixture-ts'), + flags: ['--typescript'], + }); + + it('verify files', async function () { + expect( + existsSync(join(project.dir(), 'tsconfig.json')), + 'the root tsconfig.json has been added', + ); + }); + + it('glint passes', async function () { + let result = await project.execa('pnpm', ['glint']); + + console.log(result.stdout); + }); +}); From 88170cd5f994cbaa3e79cb893f5fddd20f317f04 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:16:47 -0500 Subject: [PATCH 2/6] Remove all 'latest' tags --- index.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index a84c590..f820e18 100644 --- a/index.js +++ b/index.js @@ -122,20 +122,20 @@ module.exports = { // Dependencies out of date from upstream // (or waiting for the release train to catch up) - 'eslint@latest', - 'eslint-plugin-ember@latest', - 'eslint-plugin-n@latest', - '@babel/eslint-parser@latest', - '@babel/plugin-transform-runtime@latest', - '@babel/runtime@latest', - 'ember-template-lint@latest', - - '@ember/string@latest', - 'ember-resolver@latest', - 'ember-load-initializers@latest', - 'qunit@latest', - 'qunit-dom@latest', - 'concurrently@latest', + 'eslint@^9.14.0', + 'eslint-plugin-ember@^12.3.1', + 'eslint-plugin-n@^17.13.1', + '@babel/eslint-parser@^7.25.9', + '@babel/plugin-transform-runtime@^7.25.9', + '@babel/runtime@^7.26.0', + 'ember-template-lint@^6.0.0', + + '@ember/string@^4.0.0', + 'ember-resolver@^13.0.2', + 'ember-load-initializers@^3.0.1', + 'qunit@^2.22.0', + 'qunit-dom@^3.30', + 'concurrently@^9.1.0', // Needed for eslint 'globals', @@ -159,9 +159,9 @@ module.exports = { '@glint/environment-ember-template-imports@unstable', '@glint/template@unstable', '@types/eslint__js', - 'typescript-eslint@latest', - '@typescript-eslint/eslint-plugin@latest', - '@typescript-eslint/parser@latest', + 'typescript-eslint@^8.13.0', + '@typescript-eslint/eslint-plugin@^8.13.0', + '@typescript-eslint/parser@^8.13.0', ] : []), ], From da5263408be3c7cd799aa5bd972ecbe6dc16a261 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:18:12 -0500 Subject: [PATCH 3/6] Only remove TS deps when they are expected to need to be removed --- index.js | 57 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/index.js b/index.js index f820e18..0d3b8ee 100644 --- a/index.js +++ b/index.js @@ -73,36 +73,41 @@ module.exports = { 'ember-cli-sri', 'ember-cli-terser', // Linting + // No longer needed because we explicitly define a babel config '@babel/plugin-proposal-decorators', // Upstream TypeScript blueprint is out of date, but // There is concensus on removing all this from the upstream blueprint as well. - '@types/ember', - '@types/ember-data', - '@types/ember-data__adapter', - '@types/ember-data__model', - '@types/ember-data__serializer', - '@types/ember-data__store', - '@types/ember__application', - '@types/ember__array', - '@types/ember__component', - '@types/ember__controller', - '@types/ember__debug', - '@types/ember__destroyable', - '@types/ember__engine', - '@types/ember__error', - '@types/ember__helper', - '@types/ember__modifier', - '@types/ember__object', - '@types/ember__owner', - '@types/ember__polyfills', - '@types/ember__routing', - '@types/ember__runloop', - '@types/ember__service', - '@types/ember__string', - '@types/ember__template', - '@types/ember__test', - '@types/ember__utils', + ...(options.typescript + ? [ + '@types/ember', + '@types/ember-data', + '@types/ember-data__adapter', + '@types/ember-data__model', + '@types/ember-data__serializer', + '@types/ember-data__store', + '@types/ember__application', + '@types/ember__array', + '@types/ember__component', + '@types/ember__controller', + '@types/ember__debug', + '@types/ember__destroyable', + '@types/ember__engine', + '@types/ember__error', + '@types/ember__helper', + '@types/ember__modifier', + '@types/ember__object', + '@types/ember__owner', + '@types/ember__polyfills', + '@types/ember__routing', + '@types/ember__runloop', + '@types/ember__service', + '@types/ember__string', + '@types/ember__template', + '@types/ember__test', + '@types/ember__utils', + ] + : []), ].filter((depToRemove) => existingDeps.includes(depToRemove)), packageManager: options.packageManager, }); From affe4289be13a1ad11637b896cb16e3e2b2317c7 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:20:53 -0500 Subject: [PATCH 4/6] Reduce blueprint diff by perpetuating old patterns (the problem with the upstream blueprint) --- index.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/index.js b/index.js index 0d3b8ee..410898d 100644 --- a/index.js +++ b/index.js @@ -184,15 +184,6 @@ module.exports = { '.eslintignore', // replaced with .prettierrc.cjs '.prettierrc.js', - // ember-data / warp-drive doesn't want folks using models - 'app/models/.gitkeep', - - // We don't need these with gjs/gts - 'app/helpers/.gitkeep', - - // Delete if empty, kept otherwise - 'app/models', - 'app/helpers', ...(options.typescript ? [ From a122c2bc7a100bca6b65b3443cec7c094b4f69c5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:21:53 -0500 Subject: [PATCH 5/6] Fix typo in qunit-dom version --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 410898d..a2d3f2c 100644 --- a/index.js +++ b/index.js @@ -139,7 +139,7 @@ module.exports = { 'ember-resolver@^13.0.2', 'ember-load-initializers@^3.0.1', 'qunit@^2.22.0', - 'qunit-dom@^3.30', + 'qunit-dom@^3.3.0', 'concurrently@^9.1.0', // Needed for eslint From 33c618f56744ce04f129a5bf7a75c68981ed4180 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:37:31 -0500 Subject: [PATCH 6/6] Remove colors, as ember-cli now shipped them... sorta, will be in 6 or 6.1 of ember-cli --- index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.js b/index.js index a2d3f2c..583e1d8 100644 --- a/index.js +++ b/index.js @@ -252,10 +252,6 @@ module.exports = { 'test:ember': 'vite build --mode test && ember test --path dist', }; - json.scripts['test'] += ' --prefixColors auto'; - json.scripts['lint'] += ' --prefixColors auto'; - json.scripts['lint:fix'] += ' --prefixColors auto'; - if (json.scripts['lint:types']) { json.scripts['lint:types'] = 'glint'; }