From c2ff543ae4c11d2f12743f4e6225b91e3dbf1688 Mon Sep 17 00:00:00 2001 From: aalimovs Date: Sun, 28 Jul 2024 12:17:56 +0100 Subject: [PATCH 1/2] Add test with a custom component --- tests/fixture/app/components/custom-component.hbs | 3 +++ tests/fixture/app/router.js | 1 + tests/fixture/app/templates/custom-component.hbs | 1 + .../tests/acceptance/custom-component-test.js | 14 ++++++++++++++ 4 files changed, 19 insertions(+) create mode 100644 tests/fixture/app/components/custom-component.hbs create mode 100644 tests/fixture/app/templates/custom-component.hbs create mode 100644 tests/fixture/tests/acceptance/custom-component-test.js diff --git a/tests/fixture/app/components/custom-component.hbs b/tests/fixture/app/components/custom-component.hbs new file mode 100644 index 0000000..c7cbad7 --- /dev/null +++ b/tests/fixture/app/components/custom-component.hbs @@ -0,0 +1,3 @@ +
+ I am a custom component +
diff --git a/tests/fixture/app/router.js b/tests/fixture/app/router.js index 143e6e6..8a5b048 100644 --- a/tests/fixture/app/router.js +++ b/tests/fixture/app/router.js @@ -8,4 +8,5 @@ export default class Router extends EmberRouter { Router.map(function () { this.route('styles'); + this.route('custom-component'); }); diff --git a/tests/fixture/app/templates/custom-component.hbs b/tests/fixture/app/templates/custom-component.hbs new file mode 100644 index 0000000..1771a5f --- /dev/null +++ b/tests/fixture/app/templates/custom-component.hbs @@ -0,0 +1 @@ + diff --git a/tests/fixture/tests/acceptance/custom-component-test.js b/tests/fixture/tests/acceptance/custom-component-test.js new file mode 100644 index 0000000..24e6db0 --- /dev/null +++ b/tests/fixture/tests/acceptance/custom-component-test.js @@ -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'); + }); +}) From c98650333e8b407ab2eb9fb59867c1e6ca04057d Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Thu, 1 Aug 2024 15:44:39 -0400 Subject: [PATCH 2/2] update vite config to follow latest embroider --- files/vite.config.mjs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/files/vite.config.mjs b/files/vite.config.mjs index 75751c6..c2eff23 100644 --- a/files/vite.config.mjs +++ b/files/vite.config.mjs @@ -13,13 +13,24 @@ import { resolve } from 'path'; import { babel } from '@rollup/plugin-babel'; const root = 'tmp/rewritten-app'; +const extensions = [ + '.mjs', + '.gjs', + '.js', + '.mts', + '.gts', + '.ts', + '.hbs', + '.json', +]; export default defineConfig(({ mode }) => { return { root, - // esbuild in vite does not support decorators - esbuild: false, cacheDir: resolve('node_modules', '.vite'), + resolve: { + extensions, + }, plugins: [ hbs(), templateTag(), @@ -31,12 +42,7 @@ export default defineConfig(({ mode }) => { babel({ babelHelpers: 'runtime', - - // this needs .hbs because our hbs() plugin above converts them to - // javascript but the javascript still also needs babel, but we don't want - // to rename them because vite isn't great about knowing how to hot-reload - // them if we resolve them to made-up names. - extensions: ['.gjs', '.js', '.hbs', '.ts', '.gts'], + extensions, }), ], optimizeDeps: optimizeDeps(),