2018-10-18 02:18:29 +03:00
|
|
|
import mockApiKeys from './config/api-keys';
|
2016-08-17 18:14:33 +03:00
|
|
|
import mockAuthentication from './config/authentication';
|
2016-10-28 16:07:50 +03:00
|
|
|
import mockConfiguration from './config/configuration';
|
2018-10-18 02:18:29 +03:00
|
|
|
import mockIntegrations from './config/integrations';
|
2016-09-26 19:03:53 +03:00
|
|
|
import mockInvites from './config/invites';
|
2019-01-22 20:18:44 +03:00
|
|
|
import mockMembers from './config/members';
|
2019-02-22 06:17:33 +03:00
|
|
|
import mockPages from './config/pages';
|
2016-08-17 18:14:33 +03:00
|
|
|
import mockPosts from './config/posts';
|
|
|
|
import mockRoles from './config/roles';
|
|
|
|
import mockSettings from './config/settings';
|
|
|
|
import mockSlugs from './config/slugs';
|
|
|
|
import mockSubscribers from './config/subscribers';
|
|
|
|
import mockTags from './config/tags';
|
2016-08-17 18:01:46 +03:00
|
|
|
import mockThemes from './config/themes';
|
2017-05-23 11:50:04 +03:00
|
|
|
import mockUploads from './config/uploads';
|
2016-08-17 18:14:33 +03:00
|
|
|
import mockUsers from './config/users';
|
2018-10-18 02:18:29 +03:00
|
|
|
import mockWebhooks from './config/webhooks';
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
// import {versionMismatchResponse} from 'utils';
|
2016-04-15 17:45:50 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
export default function () {
|
2019-01-23 17:24:29 +03:00
|
|
|
// allow any local requests outside of the namespace (configured below) to hit the real server
|
|
|
|
// _must_ be called before the namespace property is set
|
|
|
|
this.passthrough('/ghost/assets/**');
|
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2018-10-18 02:18:29 +03:00
|
|
|
this.namespace = '/ghost/api/v2/admin'; // make this `api`, for example, if your API is namespaced
|
2019-01-24 22:34:32 +03:00
|
|
|
this.timing = 1000; // delay for each request, automatically set to 0 during testing
|
2019-01-22 20:18:44 +03:00
|
|
|
this.logging = true;
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2016-09-24 18:48:06 +03:00
|
|
|
// Mock endpoints here to override real API requests during development, eg...
|
2016-06-30 17:45:02 +03:00
|
|
|
// this.put('/posts/:id/', versionMismatchResponse);
|
2016-09-24 18:48:06 +03:00
|
|
|
// mockTags(this);
|
|
|
|
// this.loadFixtures('settings');
|
2019-01-22 20:18:44 +03:00
|
|
|
mockMembers(this);
|
|
|
|
|
2016-04-13 12:44:09 +03:00
|
|
|
// keep this line, it allows all other API requests to hit the real server
|
|
|
|
this.passthrough();
|
|
|
|
|
|
|
|
// add any external domains to make sure those get passed through too
|
|
|
|
this.passthrough('https://count.ghost.org/');
|
|
|
|
this.passthrough('http://www.gravatar.com/**');
|
2019-01-23 17:24:29 +03:00
|
|
|
this.passthrough('https://cdn.jsdelivr.net/**');
|
2019-02-06 13:40:34 +03:00
|
|
|
this.passthrough('https://api.unsplash.com/**');
|
2016-04-13 12:44:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mock all endpoints here as there is no real API during testing
|
|
|
|
export function testConfig() {
|
2017-01-10 02:00:12 +03:00
|
|
|
this.passthrough('/write-coverage'); // For code coverage
|
2016-04-13 12:44:09 +03:00
|
|
|
// this.urlPrefix = ''; // make this `http://localhost:8080`, for example, if your API is on a different server
|
2018-10-05 21:46:33 +03:00
|
|
|
this.namespace = '/ghost/api/v2/admin'; // make this `api`, for example, if your API is namespaced
|
2016-04-13 12:44:09 +03:00
|
|
|
// this.timing = 400; // delay for each request, automatically set to 0 during testing
|
2019-01-22 20:44:01 +03:00
|
|
|
this.logging = false;
|
2016-04-13 12:44:09 +03:00
|
|
|
|
2018-11-12 19:31:47 +03:00
|
|
|
mockApiKeys(this);
|
2016-08-17 18:14:33 +03:00
|
|
|
mockAuthentication(this);
|
2016-10-28 16:07:50 +03:00
|
|
|
mockConfiguration(this);
|
2018-11-12 19:31:47 +03:00
|
|
|
mockIntegrations(this);
|
2016-09-26 19:03:53 +03:00
|
|
|
mockInvites(this);
|
2019-01-22 20:18:44 +03:00
|
|
|
mockMembers(this);
|
2019-02-22 06:17:33 +03:00
|
|
|
mockPages(this);
|
2016-08-17 18:14:33 +03:00
|
|
|
mockPosts(this);
|
|
|
|
mockRoles(this);
|
|
|
|
mockSettings(this);
|
|
|
|
mockSlugs(this);
|
|
|
|
mockSubscribers(this);
|
|
|
|
mockTags(this);
|
2016-08-17 18:01:46 +03:00
|
|
|
mockThemes(this);
|
2017-05-23 11:50:04 +03:00
|
|
|
mockUploads(this);
|
2016-08-17 18:14:33 +03:00
|
|
|
mockUsers(this);
|
2018-11-12 19:31:47 +03:00
|
|
|
mockWebhooks(this);
|
2015-11-13 14:48:59 +03:00
|
|
|
|
2015-10-13 16:52:41 +03:00
|
|
|
/* Notifications -------------------------------------------------------- */
|
|
|
|
|
2017-01-02 21:49:44 +03:00
|
|
|
this.get('/notifications/');
|
2015-10-13 16:52:41 +03:00
|
|
|
|
2018-10-04 13:02:36 +03:00
|
|
|
/* Integrations - Slack Test Notification ------------------------------- */
|
2016-03-29 11:40:44 +03:00
|
|
|
|
|
|
|
this.post('/slack/test', function () {
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
/* External sites ------------------------------------------------------- */
|
2015-12-07 00:24:06 +03:00
|
|
|
|
2016-08-17 18:14:33 +03:00
|
|
|
let downloadCount = 0;
|
|
|
|
this.get('https://count.ghost.org/', function () {
|
2018-01-05 18:38:23 +03:00
|
|
|
downloadCount += 1;
|
2015-12-07 00:24:06 +03:00
|
|
|
return {
|
2016-08-17 18:14:33 +03:00
|
|
|
count: downloadCount
|
2015-12-07 00:24:06 +03:00
|
|
|
};
|
|
|
|
});
|
2016-03-03 11:52:27 +03:00
|
|
|
|
2017-09-28 05:33:00 +03:00
|
|
|
this.head('http://www.gravatar.com/avatar/:md5', function () {
|
|
|
|
return '';
|
|
|
|
}, 200);
|
|
|
|
|
2016-04-12 14:34:40 +03:00
|
|
|
this.get('http://www.gravatar.com/avatar/:md5', function () {
|
|
|
|
return '';
|
|
|
|
}, 200);
|
2015-10-13 16:52:41 +03:00
|
|
|
}
|