mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-23 02:41:50 +03:00
75fbd272c9
refs #9178 `yarn test` only runs acceptance and unit tests. We will setup a cronjob in Travis and run the regression tests once per day. You can manually run them with `yarn test:regression` This separation is just a first step into the right direction. Travis will no longer run for 10-13minutes. The goal is to run common API use cases and unit tests in Travis and locally by default. ## After this separation we still need to: - re-work our test utility - remove some tests - define which tests are our common API use cases - rewrite some tests - make testing easier (starting/stopping Ghost, fixtures and resetting services or event listeners, it's a pain and takes sometimes ages to fix tests) --- **Acceptance:** - common/basic API use cases against the current **stable** API **Unit:** - all unit tests (no database access) - proper mocking **Regression:** - packages we don't want to run for each PR or commit - tests which protect Ghost from breaking components and behaviour - it is wishful that regression tests are using Ghost's API's (frontend, apps, core) --- **This PR requires an update to our docs.**
88 lines
2.5 KiB
JavaScript
88 lines
2.5 KiB
JavaScript
const url = require('url');
|
|
const _ = require('lodash');
|
|
const testUtils = require('../../../utils');
|
|
const schema = require('../../../../server/data/schema').tables;
|
|
const API_URL = '/ghost/api/v2/content/';
|
|
|
|
const expectedProperties = {
|
|
// API top level
|
|
posts: ['posts', 'meta'],
|
|
tags: ['tags', 'meta'],
|
|
authors: ['authors', 'meta'],
|
|
pagination: ['page', 'limit', 'pages', 'total', 'next', 'prev'],
|
|
|
|
post: _(schema.posts)
|
|
.keys()
|
|
// by default we only return html
|
|
.without('mobiledoc', 'plaintext')
|
|
// v2 doesn't return author_id OR author
|
|
.without('author_id', 'author')
|
|
// and always returns computed properties: url, primary_tag, primary_author
|
|
.concat('url', 'primary_tag', 'primary_author')
|
|
// v2 API doesn't return unused fields
|
|
.without('locale', 'visibility')
|
|
// These fields aren't useful as they always have known values
|
|
.without('status')
|
|
// @TODO: https://github.com/TryGhost/Ghost/issues/10335
|
|
// .without('page')
|
|
// v2 returns a calculated excerpt field
|
|
.concat('excerpt')
|
|
,
|
|
author: _(schema.users)
|
|
.keys()
|
|
.without(
|
|
'password',
|
|
'email',
|
|
'ghost_auth_access_token',
|
|
'ghost_auth_id',
|
|
'created_at',
|
|
'created_by',
|
|
'updated_at',
|
|
'updated_by',
|
|
'last_seen',
|
|
'status'
|
|
)
|
|
// v2 API doesn't return unused fields
|
|
.without('accessibility', 'locale', 'tour', 'visibility')
|
|
,
|
|
tag: _(schema.tags)
|
|
.keys()
|
|
// v2 Tag API doesn't return parent_id or parent
|
|
.without('parent_id', 'parent')
|
|
// v2 Tag API doesn't return date fields
|
|
.without('created_at', 'updated_at')
|
|
};
|
|
|
|
_.each(expectedProperties, (value, key) => {
|
|
if (!value.__wrapped__) {
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* @deprecated: x_by
|
|
*/
|
|
expectedProperties[key] = value
|
|
.without(
|
|
'created_by',
|
|
'updated_by',
|
|
'published_by'
|
|
)
|
|
.value();
|
|
});
|
|
|
|
module.exports = {
|
|
API: {
|
|
getApiQuery(route) {
|
|
return url.resolve(API_URL, route);
|
|
},
|
|
|
|
checkResponse(...args) {
|
|
this.expectedProperties = expectedProperties;
|
|
return testUtils.API.checkResponse.call(this, ...args);
|
|
}
|
|
},
|
|
getValidKey() {
|
|
return testUtils.DataGenerator.Content.api_keys[1].secret;
|
|
}
|
|
};
|