-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ember): Update ember tests to use E2E structure (#11827)
This gets rid of the Ember canary tests that are always failing, probably due to ember-try (which we use there) not playing nicely with the monorepo etc. Instead, this now uses the proper E2E setup. I added two tests, for classic ember and modern embroider-based ember. While doing this I also noticed two bugs I fixed along the way :O This also removed the ember canary tests, IMHO the e2e tests are good enough for us there now.
- Loading branch information
Showing
97 changed files
with
2,623 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
dev-packages/e2e-tests/test-applications/ember-classic/.editorconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.hbs] | ||
insert_final_newline = false | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false |
15 changes: 15 additions & 0 deletions
15
dev-packages/e2e-tests/test-applications/ember-classic/.ember-cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
/** | ||
Ember CLI sends analytics information by default. The data is completely | ||
anonymous, but there are times when you might want to disable this behavior. | ||
|
||
Setting `disableAnalytics` to true will prevent any data from being sent. | ||
*/ | ||
"disableAnalytics": false, | ||
|
||
/** | ||
Setting `isTypeScriptProject` to true will force the blueprint generators to generate TypeScript | ||
rather than JavaScript by default, when a TypeScript version of a given blueprint is available. | ||
*/ | ||
"isTypeScriptProject": false | ||
} |
32 changes: 32 additions & 0 deletions
32
dev-packages/e2e-tests/test-applications/ember-classic/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist/ | ||
/tmp/ | ||
|
||
# dependencies | ||
/bower_components/ | ||
/node_modules/ | ||
|
||
# misc | ||
/.env* | ||
/.pnp* | ||
/.sass-cache | ||
/.eslintcache | ||
/connect.lock | ||
/coverage/ | ||
/libpeerconnection.log | ||
/npm-debug.log* | ||
/testem.log | ||
/yarn-error.log | ||
|
||
# ember-try | ||
/.node_modules.ember-try/ | ||
/bower.json.ember-try | ||
/npm-shrinkwrap.json.ember-try | ||
/package.json.ember-try | ||
/package-lock.json.ember-try | ||
/yarn.lock.ember-try | ||
|
||
# broccoli-debug | ||
/DEBUG/ |
2 changes: 2 additions & 0 deletions
2
dev-packages/e2e-tests/test-applications/ember-classic/.npmrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@sentry:registry=http://127.0.0.1:4873 | ||
@sentry-internal:registry=http://127.0.0.1:4873 |
3 changes: 3 additions & 0 deletions
3
dev-packages/e2e-tests/test-applications/ember-classic/.watchmanconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"ignore_dirs": ["tmp", "dist"] | ||
} |
56 changes: 56 additions & 0 deletions
56
dev-packages/e2e-tests/test-applications/ember-classic/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# ember-classic | ||
|
||
This README outlines the details of collaborating on this Ember application. A short introduction of this app could | ||
easily go here. | ||
|
||
## Prerequisites | ||
|
||
You will need the following things properly installed on your computer. | ||
|
||
- [Git](https://git-scm.com/) | ||
- [Node.js](https://nodejs.org/) (with npm) | ||
- [Ember CLI](https://cli.emberjs.com/release/) | ||
- [Google Chrome](https://google.com/chrome/) | ||
|
||
## Installation | ||
|
||
- `git clone <repository-url>` this repository | ||
- `cd ember-classic` | ||
- `npm install` | ||
|
||
## Running / Development | ||
|
||
- `ember serve` | ||
- Visit your app at [http://localhost:4200](http://localhost:4200). | ||
- Visit your tests at [http://localhost:4200/tests](http://localhost:4200/tests). | ||
|
||
### Code Generators | ||
|
||
Make use of the many generators for code, try `ember help generate` for more details | ||
|
||
### Running Tests | ||
|
||
- `ember test` | ||
- `ember test --server` | ||
|
||
### Linting | ||
|
||
- `npm run lint` | ||
- `npm run lint:fix` | ||
|
||
### Building | ||
|
||
- `ember build` (development) | ||
- `ember build --environment production` (production) | ||
|
||
### Deploying | ||
|
||
Specify what it takes to deploy your app. | ||
|
||
## Further Reading / Useful Links | ||
|
||
- [ember.js](https://emberjs.com/) | ||
- [ember-cli](https://cli.emberjs.com/release/) | ||
- Development Browser Extensions | ||
- [ember inspector for chrome](https://chrome.google.com/webstore/detail/ember-inspector/bmdblncegkenkacieihfhpjfppoconhi) | ||
- [ember inspector for firefox](https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/) |
20 changes: 20 additions & 0 deletions
20
dev-packages/e2e-tests/test-applications/ember-classic/app/app.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Application from '@ember/application'; | ||
import * as Sentry from '@sentry/ember'; | ||
import loadInitializers from 'ember-load-initializers'; | ||
import Resolver from 'ember-resolver'; | ||
|
||
import config from './config/environment'; | ||
|
||
Sentry.init({ | ||
replaysSessionSampleRate: 1, | ||
replaysOnErrorSampleRate: 1, | ||
tunnel: `http://localhost:3031/`, // proxy server | ||
}); | ||
|
||
export default class App extends Application { | ||
public modulePrefix = config.modulePrefix; | ||
public podModulePrefix = config.podModulePrefix; | ||
public Resolver = Resolver; | ||
} | ||
|
||
loadInitializers(App, config.modulePrefix); |
3 changes: 3 additions & 0 deletions
3
dev-packages/e2e-tests/test-applications/ember-classic/app/components/link.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<a href={{this.href}} class={{if this.isActive 'active'}} {{on 'click' this.onClick}}> | ||
{{yield}} | ||
</a> |
33 changes: 33 additions & 0 deletions
33
dev-packages/e2e-tests/test-applications/ember-classic/app/components/link.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { action } from '@ember/object'; | ||
import type RouterService from '@ember/routing/router-service'; | ||
import { inject as service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
|
||
interface Args { | ||
route: string; | ||
} | ||
|
||
/* | ||
Note: We use this custom component instead of the built-in `<LinkTo>`, | ||
as that is an ember component in older versions, and a glimmer component in newer versions. | ||
Since glimmer components are, as of now, not instrumented, this leads to different test results. | ||
*/ | ||
export default class LinkComponent extends Component<Args> { | ||
@service public declare router: RouterService; | ||
|
||
public get href(): string { | ||
return this.router.urlFor(this.args.route); | ||
} | ||
|
||
public get isActive(): boolean { | ||
return this.router.currentRouteName === this.args.route; | ||
} | ||
|
||
@action | ||
public onClick(event: MouseEvent): void { | ||
event.preventDefault(); | ||
|
||
void this.router.transitionTo(this.args.route); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...packages/e2e-tests/test-applications/ember-classic/app/components/slow-loading-gc-list.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable ember/no-empty-glimmer-component-classes */ | ||
import Component from '@glimmer/component'; | ||
|
||
export default class SlowLoadingGCList extends Component {} |
25 changes: 25 additions & 0 deletions
25
dev-packages/e2e-tests/test-applications/ember-classic/app/components/slow-loading-list.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable ember/no-classic-classes */ | ||
/* eslint-disable ember/no-classic-components */ | ||
import Component from '@ember/component'; | ||
import { computed } from '@ember/object'; | ||
|
||
interface Args { | ||
title?: string; | ||
items: number; | ||
} | ||
|
||
export default Component.extend({ | ||
tagName: '', | ||
|
||
_title: computed('title', function () { | ||
return (this as Args).title || 'Slow Loading List'; | ||
}), | ||
|
||
rowItems: computed('items', function () { | ||
return new Array((this as Args).items).fill(0).map((_, index) => { | ||
return { | ||
index: index + 1, | ||
}; | ||
}); | ||
}), | ||
}); |
6 changes: 6 additions & 0 deletions
6
dev-packages/e2e-tests/test-applications/ember-classic/app/components/test-section.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* eslint-disable ember/no-classic-classes */ | ||
/* eslint-disable ember/no-classic-components */ | ||
/* eslint-disable ember/require-tagless-components */ | ||
import Component from '@ember/component'; | ||
|
||
export default Component.extend({}); |
17 changes: 17 additions & 0 deletions
17
dev-packages/e2e-tests/test-applications/ember-classic/app/config/environment.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Type declarations for | ||
* import config from './config/environment' | ||
* | ||
* For now these need to be managed by the developer | ||
* since different ember addons can materialize new entries. | ||
*/ | ||
declare const config: { | ||
environment: string; | ||
modulePrefix: string; | ||
podModulePrefix: string; | ||
locationType: 'history' | 'hash' | 'none' | 'auto'; | ||
rootURL: string; | ||
APP: Record<string, unknown>; | ||
}; | ||
|
||
export default config; |
63 changes: 63 additions & 0 deletions
63
dev-packages/e2e-tests/test-applications/ember-classic/app/controllers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
import { scheduleOnce } from '@ember/runloop'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { Promise } from 'rsvp'; | ||
|
||
export default class IndexController extends Controller { | ||
@tracked public showComponents = false; | ||
|
||
@action | ||
public createError(): void { | ||
// @ts-expect-error this is fine | ||
this.nonExistentFunction(); | ||
} | ||
|
||
@action | ||
public createEmberError(): void { | ||
throw new Error('Whoops, looks like you have an EmberError'); | ||
} | ||
|
||
@action | ||
public createCaughtEmberError(): void { | ||
try { | ||
throw new Error('Looks like you have a caught EmberError'); | ||
} catch (e) { | ||
// do nothing | ||
} | ||
} | ||
|
||
@action | ||
public createFetchError(): void { | ||
void fetch('http://doesntexist.example'); | ||
} | ||
|
||
@action | ||
public createAfterRenderError(): void { | ||
function throwAfterRender(): void { | ||
throw new Error('After Render Error'); | ||
} | ||
scheduleOnce('afterRender', null, throwAfterRender); | ||
} | ||
|
||
@action | ||
public createRSVPRejection(): Promise<void> { | ||
const promise = new Promise<void>((resolve, reject) => { | ||
reject('Promise rejected'); | ||
}); | ||
return promise; | ||
} | ||
|
||
@action | ||
public createRSVPError(): Promise<void> { | ||
const promise = new Promise<void>(() => { | ||
throw new Error('Error within RSVP Promise'); | ||
}); | ||
return promise; | ||
} | ||
|
||
@action | ||
public toggleShowComponents(): void { | ||
this.showComponents = !this.showComponents; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
dev-packages/e2e-tests/test-applications/ember-classic/app/controllers/slow-loading-route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Controller from '@ember/controller'; | ||
import { action } from '@ember/object'; | ||
import type RouterService from '@ember/routing/router-service'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class SlowLoadingRouteController extends Controller { | ||
@service public declare router: RouterService; | ||
|
||
@action | ||
public back(): void { | ||
void this.router.transitionTo('tracing'); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/e2e-tests/test-applications/ember-classic/app/controllers/slow-loading-route/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default class SlowLoadingRouteController extends Controller { | ||
public slowLoadingTemplateOnlyItems = new Array(2000).fill(0).map((_, index) => index); | ||
} |
Oops, something went wrong.