Skip to content

Commit

Permalink
mirage: Replace ember-cli-mirage with direct miragejs usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Jan 9, 2025
1 parent 9bce0eb commit 9734c63
Show file tree
Hide file tree
Showing 114 changed files with 111 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ module.exports = {

// mirage files
{
files: ['mirage/**/*.js'],
files: ['tests/mirage/**/*.js'],
rules: {
// disabled because of different `.find()` meaning
'unicorn/no-array-callback-reference': 'off',
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
files_ignore: |
app/**
e2e/**
mirage/**
public/**
tests/**
.eslintrc
Expand Down
2 changes: 0 additions & 2 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ module.exports = function (environment) {

if (environment === 'production') {
// here you can enable a production-specific feature
delete ENV['ember-cli-mirage'];

ENV.sentry = {
dsn: process.env.SENTRY_DSN_WEB,
};
Expand Down
2 changes: 1 addition & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ These files have to do with the frontend:
- `.ember-cli` - Settings for the `ember` command line interface
- `ember-cli-build.js` - Contains the build specification for Broccoli
- `.eslintrc.js` - Defines Javascript coding style guidelines (enforced during CI???)
- `mirage/` - A mock backend used during development and testing
- `node_modules/` - npm dependencies - (ignored in `.gitignore`)
- `package.json` - Defines the npm package and its dependencies
- `package-lock.json` - Locks dependencies to specific versions providing consistency across
development and deployment
- `public/` - Static files that are merged into `dist/` during build
- `testem.js` - Integration with Test'em Scripts
- `tests/` - Frontend tests
- `tests/mirage/` - A mock backend used during development and testing
- `vendor/` - frontend dependencies not distributed by npm; not currently used

## Deployment - Heroku
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
"ember-cli-head": "2.0.0",
"ember-cli-htmlbars": "6.3.0",
"ember-cli-inject-live-reload": "2.1.0",
"ember-cli-mirage": "3.0.4",
"ember-cli-notifications": "9.1.0",
"ember-click-outside": "6.1.1",
"ember-concurrency": "4.0.2",
Expand All @@ -98,6 +97,7 @@
"ember-event-helpers": "0.1.1",
"ember-exam": "9.0.0",
"ember-fetch": "8.1.2",
"ember-inflector": "5.0.2",
"ember-keyboard": "9.0.1",
"ember-link": "3.3.0",
"ember-load-initializers": "3.0.1",
Expand Down Expand Up @@ -142,8 +142,7 @@
"ember-get-config": "2.1.1",
"ember-inflector": "5.0.2",
"ember-modifier": "4.2.0",
"ember-svg-jar>cheerio": "1.0.0-rc.12",
"miragejs": "0.1.48"
"ember-svg-jar>cheerio": "1.0.0-rc.12"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
62 changes: 3 additions & 59 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/acceptance/front-page-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { getPageTitle } from 'ember-page-title/test-support';

import { setupApplicationTest } from 'crates-io/tests/helpers';

import { summary } from '../../mirage/route-handlers/summary';
import axeConfig from '../axe-config';
import { summary } from '../mirage/route-handlers/summary';

module('Acceptance | front page', function (hooks) {
setupApplicationTest(hooks);
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/search-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { getPageTitle } from 'ember-page-title/test-support';

import { setupApplicationTest } from 'crates-io/tests/helpers';

import { list as listCrates } from '../../mirage/route-handlers/crates';
import axeConfig from '../axe-config';
import { list as listCrates } from '../mirage/route-handlers/crates';

module('Acceptance | search', function (hooks) {
setupApplicationTest(hooks);
Expand Down
22 changes: 20 additions & 2 deletions tests/helpers/setup-mirage.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
import { setupMirage } from 'ember-cli-mirage/test-support';
import { settled } from '@ember/test-helpers';

import window from 'ember-window-mock';
import { setupWindowMock } from 'ember-window-mock/test-support';

import makeServer from '../mirage/config';
import { setupFakeTimers } from './fake-timers';

export default function (hooks) {
setupMirage(hooks);
setupWindowMock(hooks);
setupFakeTimers(hooks, '2017-11-20T12:00:00');

// To have deterministic visual tests, the seed has to be constant
hooks.beforeEach(function () {
this.server = makeServer({
environment: 'test',
});

if (location.search.includes('mirageLogging')) {
this.server.logging = true;
}

this.authenticateAs = user => {
this.server.create('mirage-session', { user });
window.localStorage.setItem('isLoggedIn', '1');
};
});

hooks.afterEach(async function () {
await settled();

if (this.server) {
this.server.shutdown();
delete this.server;
}
});
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/categories/:id', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/categories', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/category_slugs', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | PUT /api/v1/confirm/:token', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

const ADD_USER_BODY = JSON.stringify({ owners: ['john-doe'] });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | DELETE /api/v1/crates/:name', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates/:id/downloads', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';
import { setupTest } from '../../../../helpers';
import setupMirage from '../../../../helpers/setup-mirage';

module('Mirage | DELETE /api/v1/crates/:crateId/follow', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';
import { setupTest } from '../../../../helpers';
import setupMirage from '../../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates/:crateId/following', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';
import { setupTest } from '../../../../helpers';
import setupMirage from '../../../../helpers/setup-mirage';

module('Mirage | PUT /api/v1/crates/:crateId/follow', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates/:id', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates/:id/owner_team', function (hooks) {
setupTest(hooks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { module, test } from 'qunit';

import fetch from 'fetch';

import { setupTest } from '../../helpers';
import setupMirage from '../../helpers/setup-mirage';
import { setupTest } from '../../../helpers';
import setupMirage from '../../../helpers/setup-mirage';

module('Mirage | GET /api/v1/crates/:id/owner_user', function (hooks) {
setupTest(hooks);
Expand Down
Loading

0 comments on commit 9734c63

Please sign in to comment.