Skip to content

Commit

Permalink
Merge pull request #1879 from embroider-build/delete-vite-app
Browse files Browse the repository at this point in the history
Delete vite app from test scenarios
  • Loading branch information
mansona authored Apr 16, 2024
2 parents 649e0eb + 46ce15e commit c5595f2
Show file tree
Hide file tree
Showing 55 changed files with 123 additions and 983 deletions.
1 change: 1 addition & 0 deletions tests/app-template/vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default defineConfig(({ mode }) => {
}),
],
optimizeDeps: optimizeDeps(),
publicDir: resolve(process.cwd(), "public"),
server: {
port: 4200,
watch: {
Expand Down
1 change: 0 additions & 1 deletion tests/scenarios/scenarios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export function baseViteApp() {
}

export const appScenarios = supportMatrix(Scenarios.fromProject(baseApp));
export const viteAppScenarios = supportMatrix(Scenarios.fromProject(baseViteApp)).skip('lts_3_28');

// we're standardizing on Ember's native types, which become available starting
// at 4.8. So we're not going to run type tests on older releases that don't
Expand Down
159 changes: 122 additions & 37 deletions tests/scenarios/vite-app-test.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
import { baseAddon, viteAppScenarios } from './scenarios';
import { baseAddon, appScenarios } from './scenarios';
import type { PreparedApp } from 'scenario-tester';
import QUnit from 'qunit';
import { exec } from 'child_process';
import { readdirSync } from 'fs-extra';
import { join } from 'path';

const { module: Qmodule, test } = QUnit;

// cannot use util.promisify
// because then qunit will exit early with
// an error about an async hold
function execPromise(command: string): Promise<string> {
return new Promise(function (resolve, reject) {
exec(command, (error, stdout) => {
if (error) {
reject(error);
return;
}
resolve(stdout.trim());
});
});
}

viteAppScenarios
// TODO check if we need anything in this test or if things are covered elsewhere
appScenarios
.map('vite-app-basics', project => {
let addon = baseAddon();
addon.pkg.name = 'my-addon';
Expand Down Expand Up @@ -100,6 +85,21 @@ viteAppScenarios
project.addDevDependency(addon2);
project.mergeFiles({
tests: {
acceptance: {
'app-route-test.js': `import { module, test } from 'qunit';
import { visit } from '@ember/test-helpers';
import { setupApplicationTest } from 'app-template/tests/helpers';
module('Acceptance | app route', function (hooks) {
setupApplicationTest(hooks);
test('visiting /', async function (assert) {
await visit('/');
assert.dom().includesText('hey');
});
});
`,
},
integration: {
'test-colocated-addon-component.js': `
import { module, test } from 'qunit';
Expand All @@ -123,9 +123,105 @@ viteAppScenarios
});
`,
'example-test.js': `import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, rerender } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | Example', (hooks) => {
setupRenderingTest(hooks);
test('should have Yay for gts!', async function (assert) {
await render(hbs\`
<Example></Example>
\`);
await rerender();
assert.dom().includesText('Yay for gts!');
});
});
`,
'fany-test-gjs.gjs': `import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, click, rerender, settled } from '@ember/test-helpers';
import Fancy from 'app-template/components/fancy2';
module('Integration | Component | Fany -- from gjs test file', (hooks) => {
setupRenderingTest(hooks);
test('should have Yay for gts!', async function(assert) {
await render(<template>
<Fancy @type="primary2"></Fancy>
</template>);
await rerender()
assert.dom().hasText('Yay for gjs!');
});
});
`,
'fany-test.gts': `import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, rerender } from '@ember/test-helpers';
import Fancy from 'app-template/components/fancy';
module('Integration | Component | Fany -- from gts test file', (hooks) => {
setupRenderingTest(hooks);
test('should have Yay for gts!', async function(assert) {
await render(<template>
<Fancy @type="primary2"></Fancy>
</template>);
await rerender()
assert.dom().hasText('Yay for gts!');
});
});
`,
'fany2-test.js': `import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, rerender } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
module('Integration | Component | Fany2', (hooks) => {
setupRenderingTest(hooks);
test('should have Yay for gjs!', async function (assert) {
await render(hbs\`
<Fancy @type="primary2"></Fancy>
<Fancy2 @type="primary2"></Fancy2>
\`);
await rerender();
assert.dom().includesText('Yay for gts!');
assert.dom().includesText('Yay for gjs!');
});
});
`,
},
},
app: {
components: {
old: {
'component.js': `import Component from '@glimmer/component';
export default class extends Component {
message = 'hi';
}
`,
'component.hbs': `<div>hey {{@message}} <Fancy /></div>`,
},
'example.hbs': `<div>hey {{@message}} <Fancy /></div>`,
'example.js': `import Component from '@glimmer/component';
import Fancy from './fancy';
export default class extends Component {
message = 'hi';
Fancy = Fancy;
}`,
'fancy.gts': `<template>Yay for gts!</template>`,
'fancy2.gjs': `<template>Yay for gjs!</template>`,
},
adapters: {
'post.js': `
import JSONAPIAdapter from '@ember-data/adapter/json-api';
Expand Down Expand Up @@ -156,6 +252,14 @@ viteAppScenarios
}
`,
},
templates: {
'application.hbs': `{{page-title "ViteApp"}}
<Example @message={{this.model.message}} />
<Old @message={{this.model.message}} />
{{outlet}}`,
},
},
public: {
posts: {
Expand Down Expand Up @@ -184,22 +288,6 @@ viteAppScenarios
app = await scenario.prepare();
});

if (process.platform === 'win32') {
test(`correct windows path`, async function (assert) {
// windows sometimes generates short path alias 8.3
// which leads to resolving errors later
// e.g. cannot find owning engine for C:\Users\runneradmin\AppData\Local\Temp\tmp-2256UvRXnGotcjxi\node_modules\.embroider\rewritten-app
// the value in engines are: C:\Users\RUNNER~1\AppData\Local\Temp\tmp-2256UvRXnGotcjxi\node_modules\.embroider\rewritten-app
// it looks like there is no way to fix this in JS with
// e.g fs.realpath, resolve, normalize
// Powershell command can be used, python could also resolve it...
const command = `powershell.exe -command "(Get-Item -LiteralPath '${app.dir}').FullName"`;
const dir = await execPromise(command);
app.dir = dir;
assert.ok(!dir.includes('~'));
});
}

test(`pnpm test:ember`, async function (assert) {
// this will only hang if there is an issue
assert.timeout(5 * 60 * 1000);
Expand All @@ -209,8 +297,6 @@ viteAppScenarios
assert.ok(result.output.includes('should have Yay for gjs!'), 'should have tested');
assert.ok(result.output.includes(' -- from gjs test file'), 'should have tested with gjs file');
assert.ok(result.output.includes(' -- from gts test file'), 'should have tested with gts file');
const depCache = readdirSync(join(app.dir, 'node_modules', '.vite', 'deps'));
assert.ok(depCache.length > 0, 'should have created cached deps');
});

test(`pnpm build`, async function (assert) {
Expand All @@ -219,7 +305,6 @@ viteAppScenarios
const distFiles = readdirSync(join(app.dir, 'dist'));
assert.ok(distFiles.length > 1, 'should have created dist folder');
assert.ok(distFiles.includes('assets'), 'should have created assets folder');
assert.ok(distFiles.includes('ember-welcome-page'), 'should have copied addon asset files');
assert.ok(distFiles.includes('robots.txt'), 'should have copied app assets');

const assetFiles = readdirSync(join(app.dir, 'dist', 'assets'));
Expand Down
19 changes: 0 additions & 19 deletions tests/vite-app/.editorconfig

This file was deleted.

15 changes: 0 additions & 15 deletions tests/vite-app/.ember-cli

This file was deleted.

13 changes: 0 additions & 13 deletions tests/vite-app/.eslintignore

This file was deleted.

58 changes: 0 additions & 58 deletions tests/vite-app/.eslintrc.js

This file was deleted.

47 changes: 0 additions & 47 deletions tests/vite-app/.github/workflows/ci.yml

This file was deleted.

Loading

0 comments on commit c5595f2

Please sign in to comment.