From 75fbd272c994eaa90614586a53a0db3f564b42ea Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Tue, 22 Jan 2019 17:54:50 +0100 Subject: [PATCH] Separated test env into: acceptance, regression and unit tests (#10411) 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.** --- Gruntfile.js | 97 ++-------- core/test/acceptance/README.md | 16 ++ .../old}/admin/configuration_spec.js | 6 +- .../v2 => acceptance/old}/admin/db_spec.js | 12 +- .../old}/admin/integrations_spec.js | 4 +- .../old}/admin/invites_spec.js | 6 +- .../v2 => acceptance/old}/admin/mail_spec.js | 6 +- .../old}/admin/notifications_spec.js | 4 +- .../old}/admin/oembed_spec.js | 4 +- .../v2 => acceptance/old}/admin/posts_spec.js | 6 +- .../old}/admin/redirects_spec.js | 6 +- .../v2 => acceptance/old}/admin/roles_spec.js | 4 +- .../old}/admin/settings_spec.js | 4 +- .../v2 => acceptance/old}/admin/slack_spec.js | 6 +- .../v2 => acceptance/old}/admin/slugs_spec.js | 4 +- .../old}/admin/subscribers_spec.js | 8 +- .../v2 => acceptance/old}/admin/tags_spec.js | 4 +- .../old}/admin/upload_spec.js | 18 +- .../v2 => acceptance/old}/admin/users_spec.js | 8 +- .../api/v2 => acceptance/old}/admin/utils.js | 4 +- .../old}/admin/webhooks_spec.js | 4 +- .../old}/content/authors_spec.js | 8 +- .../old}/content/pages_spec.js | 6 +- .../old}/content/posts_spec.js | 6 +- .../old}/content/settings_spec.js | 8 +- .../old}/content/tags_spec.js | 6 +- .../v2 => acceptance/old}/content/utils.js | 4 +- .../model/model_accesstoken_spec.js | 40 ---- .../model/model_app-fields_spec.js | 53 ------ .../model/model_app-settings_spec.js | 53 ------ .../test/integration/model/model_apps_spec.js | 109 ----------- .../integration/model/model_invite_spec.js | 28 --- .../model/model_permissions_spec.js | 174 ------------------ .../integration/model/model_roles_spec.js | 87 --------- .../test/integration/model/model_tags_spec.js | 141 -------------- core/test/regression/README.md | 6 + .../api}/admin_spec.js | 8 +- .../api/v0.1/authentication_spec.js | 12 +- .../api/v0.1/configuration_spec.js | 4 +- .../api/v0.1/db_spec.js | 8 +- .../api/v0.1/error_spec.js | 4 +- .../api/v0.1/invites_spec.js | 6 +- .../api/v0.1/notifications_spec.js | 4 +- .../api/v0.1/oembed_spec.js | 4 +- .../api/v0.1/posts_spec.js | 4 +- .../api/v0.1/public_api_spec.js | 6 +- .../api/v0.1/redirects_spec.js | 4 +- .../api/v0.1/roles_spec.js | 4 +- .../api/v0.1/schedules_spec.js | 8 +- .../api/v0.1/settings_spec.js | 4 +- .../api/v0.1/slugs_spec.js | 4 +- .../api/v0.1/spam_prevention_spec.js | 6 +- .../api/v0.1/subscribers_spec.js | 6 +- .../api/v0.1/tags_spec.js | 4 +- .../api/v0.1/themes_spec.js | 4 +- .../api/v0.1/upload_icon_spec.js | 4 +- .../api/v0.1/upload_spec.js | 4 +- .../api/v0.1/users_spec.js | 6 +- .../api/v0.1/utils.js | 4 +- .../api/v0.1/webhooks_spec.js | 4 +- .../apps/subscribers/routing_spec.js | 0 .../exporter/exporter_spec.js} | 6 +- .../importer/importer_spec.js} | 8 +- .../migrations}/migration_spec.js | 4 +- .../models}/base/listeners_spec.js | 3 +- .../models}/model_posts_spec.js | 1 + .../models}/model_settings_spec.js | 0 .../models}/model_users_spec.js | 0 .../site}/UrlService_spec.js | 12 +- .../site}/dynamic_routing_spec.js | 8 +- .../site}/frontend_spec.js | 8 +- .../web => regression/site}/site_spec.js | 0 .../update-check}/update_check_spec.js | 16 +- core/test/utils/index.js | 9 + package.json | 1 + 75 files changed, 222 insertions(+), 940 deletions(-) create mode 100644 core/test/acceptance/README.md rename core/test/{functional/api/v2 => acceptance/old}/admin/configuration_spec.js (95%) rename core/test/{functional/api/v2 => acceptance/old}/admin/db_spec.js (96%) rename core/test/{functional/api/v2 => acceptance/old}/admin/integrations_spec.js (99%) rename core/test/{functional/api/v2 => acceptance/old}/admin/invites_spec.js (97%) rename core/test/{functional/api/v2 => acceptance/old}/admin/mail_spec.js (93%) rename core/test/{functional/api/v2 => acceptance/old}/admin/notifications_spec.js (98%) rename core/test/{functional/api/v2 => acceptance/old}/admin/oembed_spec.js (95%) rename core/test/{functional/api/v2 => acceptance/old}/admin/posts_spec.js (99%) rename core/test/{functional/api/v2 => acceptance/old}/admin/redirects_spec.js (98%) rename core/test/{functional/api/v2 => acceptance/old}/admin/roles_spec.js (96%) rename core/test/{functional/api/v2 => acceptance/old}/admin/settings_spec.js (98%) rename core/test/{functional/api/v2 => acceptance/old}/admin/slack_spec.js (89%) rename core/test/{functional/api/v2 => acceptance/old}/admin/slugs_spec.js (97%) rename core/test/{functional/api/v2 => acceptance/old}/admin/subscribers_spec.js (97%) rename core/test/{functional/api/v2 => acceptance/old}/admin/tags_spec.js (98%) rename core/test/{functional/api/v2 => acceptance/old}/admin/upload_spec.js (91%) rename core/test/{functional/api/v2 => acceptance/old}/admin/users_spec.js (99%) rename core/test/{functional/api/v2 => acceptance/old}/admin/utils.js (96%) rename core/test/{functional/api/v2 => acceptance/old}/admin/webhooks_spec.js (98%) rename core/test/{functional/api/v2 => acceptance/old}/content/authors_spec.js (96%) rename core/test/{functional/api/v2 => acceptance/old}/content/pages_spec.js (95%) rename core/test/{functional/api/v2 => acceptance/old}/content/posts_spec.js (99%) rename core/test/{functional/api/v2 => acceptance/old}/content/settings_spec.js (91%) rename core/test/{functional/api/v2 => acceptance/old}/content/tags_spec.js (97%) rename core/test/{functional/api/v2 => acceptance/old}/content/utils.js (95%) delete mode 100644 core/test/integration/model/model_accesstoken_spec.js delete mode 100644 core/test/integration/model/model_app-fields_spec.js delete mode 100644 core/test/integration/model/model_app-settings_spec.js delete mode 100644 core/test/integration/model/model_apps_spec.js delete mode 100644 core/test/integration/model/model_invite_spec.js delete mode 100644 core/test/integration/model/model_permissions_spec.js delete mode 100644 core/test/integration/model/model_roles_spec.js delete mode 100644 core/test/integration/model/model_tags_spec.js create mode 100644 core/test/regression/README.md rename core/test/{functional => regression/api}/admin_spec.js (95%) rename core/test/{functional => regression}/api/v0.1/authentication_spec.js (97%) rename core/test/{functional => regression}/api/v0.1/configuration_spec.js (96%) rename core/test/{functional => regression}/api/v0.1/db_spec.js (97%) rename core/test/{functional => regression}/api/v0.1/error_spec.js (96%) rename core/test/{functional => regression}/api/v0.1/invites_spec.js (97%) rename core/test/{functional => regression}/api/v0.1/notifications_spec.js (98%) rename core/test/{functional => regression}/api/v0.1/oembed_spec.js (95%) rename core/test/{functional => regression}/api/v0.1/posts_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/public_api_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/redirects_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/roles_spec.js (96%) rename core/test/{functional => regression}/api/v0.1/schedules_spec.js (95%) rename core/test/{functional => regression}/api/v0.1/settings_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/slugs_spec.js (97%) rename core/test/{functional => regression}/api/v0.1/spam_prevention_spec.js (96%) rename core/test/{functional => regression}/api/v0.1/subscribers_spec.js (98%) rename core/test/{functional => regression}/api/v0.1/tags_spec.js (98%) rename core/test/{functional => regression}/api/v0.1/themes_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/upload_icon_spec.js (98%) rename core/test/{functional => regression}/api/v0.1/upload_spec.js (98%) rename core/test/{functional => regression}/api/v0.1/users_spec.js (99%) rename core/test/{functional => regression}/api/v0.1/utils.js (96%) rename core/test/{functional => regression}/api/v0.1/webhooks_spec.js (97%) rename core/test/{functional => regression}/apps/subscribers/routing_spec.js (100%) rename core/test/{integration/export_spec.js => regression/exporter/exporter_spec.js} (88%) rename core/test/{integration/data/importer/importers/data_spec.js => regression/importer/importer_spec.js} (99%) rename core/test/{integration => regression/migrations}/migration_spec.js (99%) rename core/test/{integration/model => regression/models}/base/listeners_spec.js (99%) rename core/test/{integration/model => regression/models}/model_posts_spec.js (99%) rename core/test/{integration/model => regression/models}/model_settings_spec.js (100%) rename core/test/{integration/model => regression/models}/model_users_spec.js (100%) rename core/test/{integration/services/url => regression/site}/UrlService_spec.js (98%) rename core/test/{functional => regression/site}/dynamic_routing_spec.js (99%) rename core/test/{functional => regression/site}/frontend_spec.js (99%) rename core/test/{integration/web => regression/site}/site_spec.js (100%) rename core/test/{integration => regression/update-check}/update_check_spec.js (98%) diff --git a/Gruntfile.js b/Gruntfile.js index d3ae934af1..eaf7aace53 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -139,8 +139,6 @@ var config = require('./core/server/config'), }, // ### grunt-mocha-cli - // Configuration for the mocha test runner, used to run unit, integration and route tests as part of - // `grunt validate`. See [grunt validate](#validate) and its sub tasks for more information. mochacli: { options: { ui: 'bdd', @@ -151,24 +149,21 @@ var config = require('./core/server/config'), exit: true }, - // #### All Unit tests unit: { src: [ 'core/test/unit/**/*_spec.js' ] }, - // #### All Integration tests - integration: { + acceptance: { src: [ - 'core/test/integration/**/*_spec.js' + 'core/test/acceptance/**/*_spec.js' ] }, - // #### All functional tests - functional: { + regression: { src: [ - 'core/test/functional/**/*_spec.js' + 'core/test/regression/**/*_spec.js' ] }, @@ -194,8 +189,8 @@ var config = require('./core/server/config'), }, coverage_all: { src: [ - 'core/test/integration', - 'core/test/functional', + 'core/test/acceptance', + 'core/test/regression', 'core/test/unit' ], options: { @@ -444,8 +439,7 @@ var config = require('./core/server/config'), // It works for any path relative to the core/test folder. It will also run all the tests in a single directory // You can also run a test with grunt test:core/test/unit/... to get bash autocompletion // - // `grunt test:integration/api` - runs the api integration tests - // `grunt test:integration` - runs the integration tests in the root folder and excludes all api & model tests + // `grunt test:regression/api` - runs the api regression tests grunt.registerTask('test', 'Run a particular spec file from the core/test directory e.g. `grunt test:unit/apps_spec.js`', function (test) { if (!test) { grunt.fail.fatal('No test provided. `grunt test` expects a filename. e.g.: `grunt test:unit/apps_spec.js`. Did you mean `npm test` or `grunt validate`?'); @@ -494,16 +488,11 @@ var config = require('./core/server/config'), return grunt.task.run(['lint']); } - grunt.task.run(['test-all']); + grunt.task.run(['test-acceptance', 'test-unit']); }); - // ### Test-All - // **Main testing task** - // - // `grunt test-all` will lint and test your pre-built local Ghost codebase. - // grunt.registerTask('test-all', 'Run all server tests', - ['test-functional', 'test-unit', 'test-integration']); + ['test-acceptance', 'test-unit', 'test-regression']); // ### Lint // @@ -537,75 +526,21 @@ var config = require('./core/server/config'), ['test-setup', 'mochacli:unit'] ); - // ### Integration tests *(sub task)* - // `grunt test-integration` will run just the integration tests - // - // Provided you already have a `config.*.json` file, you can run just the model integration tests by running: - // - // `grunt test:integration/model` - // - // Or just the api integration tests by running: - // - // `grunt test:integration/api` - // - // Integration tests are run with [mocha](http://mochajs.org/) using - // [should](https://github.com/visionmedia/should.js) to describe the tests in a highly readable style. - // Integration tests are different to the unit tests because they make requests to the database. - // - // If you need to run an individual integration test file you can use the `grunt test:` task: - // - // `grunt test:integration/api/api_tags_spec.js` - // - // Their purpose is to test that both the api and models behave as expected when the database layer is involved. - // These tests are run against sqlite3 and mysql on travis and ensure that differences between the databases - // don't cause bugs. - // - // A coverage report can be generated for these tests using the `grunt test-coverage` task. - grunt.registerTask('test-integration', 'Run integration tests (mocha + db access)', - ['test-setup', 'mochacli:integration'] + grunt.registerTask('test-regression', 'Run regression tests.', + ['test-setup', 'mochacli:regression'] ); - // ### Route tests *(sub task)* - // `grunt test-functional` will run just the route tests - // - // If you need to run an individual route test file, you can use the `grunt test:` task: - // - // `grunt test:functional/admin_spec.js` - // - // Route tests are run with [mocha](http://mochajs.org/) using - // [should](https://github.com/visionmedia/should.js) and [supertest](https://github.com/visionmedia/supertest) - // to describe and create the tests. - // - // Supertest enables us to describe requests that we want to make, and also describe the response we expect to - // receive back. It works directly with express, so we don't have to run a server to run the tests. - // - // The purpose of the route tests is to ensure that all of the routes (pages, and API requests) in Ghost - // are working as expected, including checking the headers and status codes received. It is very easy and - // quick to test many permutations of routes / urls in the system. - grunt.registerTask('test-functional', 'Run functional tests (mocha)', - ['test-setup', 'mochacli:functional'] - ); - - // Shortcut - grunt.registerTask('test-func', 'Run functional tests (mocha)', - ['test-setup', 'mochacli:functional'] + grunt.registerTask('test-acceptance', 'Run acceptance tests', + ['test-setup', 'mochacli:acceptance'] ); // ### Coverage - // `grunt coverage` will generate a report for the Unit Tests. - // - // This is not currently done as part of CI or any build, but is a tool we have available to keep an eye on how - // well the unit and integration tests are covering the code base. - // Ghost does not have a minimum coverage level - we're more interested in ensuring important and useful areas - // of the codebase are covered, than that the whole codebase is covered to a particular level. - // - // Key areas for coverage are: helpers and theme elements, apps / GDK, the api and model layers. - - grunt.registerTask('coverage', 'Generate unit and integration (mocha) tests coverage report', + // `grunt coverage` will generate a report for the code coverage. + grunt.registerTask('coverage', 'Generate unit tests coverage report', ['test-setup', 'mocha_istanbul:coverage'] ); - grunt.registerTask('coverage-all', 'Generate unit and integration tests coverage report', + grunt.registerTask('coverage-all', 'Generate full coverage report', ['test-setup', 'mocha_istanbul:coverage_all'] ); diff --git a/core/test/acceptance/README.md b/core/test/acceptance/README.md new file mode 100644 index 0000000000..9131e07e39 --- /dev/null +++ b/core/test/acceptance/README.md @@ -0,0 +1,16 @@ +## Acceptance Tests + +This folder should only contain a set of basic API use cases. + +We are currently refactoring the test env. The "old" folder currently contains all API tests for the +stable API version (v2). The goal is: + +- either keep a test if it's a basic use case e.g. upload an image, schedule a post, download a theme +- otherwise move the test to regression api v2 tests + +We probably need a differentiation for the acceptance tests for session and api_key authentication. + +Before we move tests: + +- we have to re-work how are test utility is structured +- we have to reduce tests diff --git a/core/test/functional/api/v2/admin/configuration_spec.js b/core/test/acceptance/old/admin/configuration_spec.js similarity index 95% rename from core/test/functional/api/v2/admin/configuration_spec.js rename to core/test/acceptance/old/admin/configuration_spec.js index aa2b919114..45fbc54be2 100644 --- a/core/test/functional/api/v2/admin/configuration_spec.js +++ b/core/test/acceptance/old/admin/configuration_spec.js @@ -1,8 +1,8 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; @@ -70,7 +70,7 @@ describe('Configuration API', function () { // Check a few values props.environment.should.match(/^testing/); - props.version.should.eql(require('../../../../../../package.json').version); + props.version.should.eql(require('../../../../../package.json').version); done(); }); }); diff --git a/core/test/functional/api/v2/admin/db_spec.js b/core/test/acceptance/old/admin/db_spec.js similarity index 96% rename from core/test/functional/api/v2/admin/db_spec.js rename to core/test/acceptance/old/admin/db_spec.js index 891a2f5ba9..25f6f4c417 100644 --- a/core/test/functional/api/v2/admin/db_spec.js +++ b/core/test/acceptance/old/admin/db_spec.js @@ -4,10 +4,10 @@ const fs = require('fs-extra'); const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const config = require('../../../../../../core/server/config'); -const models = require('../../../../../../core/server/models'); -const common = require('../../../../../server/lib/common'); -const testUtils = require('../../../../utils'); +const config = require('../../../../server/config'); +const models = require('../../../../server/models'); +const common = require('../../../../server/lib/common'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); let ghost = testUtils.startGhost; @@ -96,7 +96,7 @@ describe('DB API', () => { .set('Origin', config.get('url')) .set('Accept', 'application/json') .expect('Content-Type', /json/) - .attach('importfile', path.join(__dirname, '/../../../../utils/fixtures/export/default_export.json')) + .attach('importfile', path.join(__dirname, '/../../../utils/fixtures/export/default_export.json')) .expect(200) .then((res) => { const jsonResponse = res.body; @@ -132,7 +132,7 @@ describe('DB API', () => { return request.post(localUtils.API.getApiQuery('db/')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('importfile', path.join(__dirname, '/../../../../utils/fixtures/csv/single-column-with-header.csv')) + .attach('importfile', path.join(__dirname, '/../../../utils/fixtures/csv/single-column-with-header.csv')) .expect(415); }); diff --git a/core/test/functional/api/v2/admin/integrations_spec.js b/core/test/acceptance/old/admin/integrations_spec.js similarity index 99% rename from core/test/functional/api/v2/admin/integrations_spec.js rename to core/test/acceptance/old/admin/integrations_spec.js index 6ceba269a4..f4d87c8862 100644 --- a/core/test/functional/api/v2/admin/integrations_spec.js +++ b/core/test/acceptance/old/admin/integrations_spec.js @@ -1,7 +1,7 @@ const should = require('should'); const supertest = require('supertest'); -const config = require('../../../../../../core/server/config'); -const testUtils = require('../../../../utils'); +const config = require('../../../../server/config'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v2/admin/invites_spec.js b/core/test/acceptance/old/admin/invites_spec.js similarity index 97% rename from core/test/functional/api/v2/admin/invites_spec.js rename to core/test/acceptance/old/admin/invites_spec.js index 8cc318197f..cd05e8bf04 100644 --- a/core/test/functional/api/v2/admin/invites_spec.js +++ b/core/test/acceptance/old/admin/invites_spec.js @@ -1,10 +1,10 @@ const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); -const mailService = require('../../../../../../core/server/services/mail'); +const config = require('../../../../server/config'); +const mailService = require('../../../../server/services/mail'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/mail_spec.js b/core/test/acceptance/old/admin/mail_spec.js similarity index 93% rename from core/test/functional/api/v2/admin/mail_spec.js rename to core/test/acceptance/old/admin/mail_spec.js index 842dd8fc42..130f0b4d5a 100644 --- a/core/test/functional/api/v2/admin/mail_spec.js +++ b/core/test/acceptance/old/admin/mail_spec.js @@ -1,10 +1,10 @@ const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); -const mailService = require('../../../../../../core/server/services/mail'); +const config = require('../../../../server/config'); +const mailService = require('../../../../server/services/mail'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/notifications_spec.js b/core/test/acceptance/old/admin/notifications_spec.js similarity index 98% rename from core/test/functional/api/v2/admin/notifications_spec.js rename to core/test/acceptance/old/admin/notifications_spec.js index 55cdfee67d..28511b7699 100644 --- a/core/test/functional/api/v2/admin/notifications_spec.js +++ b/core/test/acceptance/old/admin/notifications_spec.js @@ -1,8 +1,8 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/oembed_spec.js b/core/test/acceptance/old/admin/oembed_spec.js similarity index 95% rename from core/test/functional/api/v2/admin/oembed_spec.js rename to core/test/acceptance/old/admin/oembed_spec.js index 0a79e15f2f..c9fa8df8ed 100644 --- a/core/test/functional/api/v2/admin/oembed_spec.js +++ b/core/test/acceptance/old/admin/oembed_spec.js @@ -1,8 +1,8 @@ const nock = require('nock'); const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); -const config = require('../../../../../../core/server/config'); +const testUtils = require('../../../utils'); +const config = require('../../../../server/config'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v2/admin/posts_spec.js b/core/test/acceptance/old/admin/posts_spec.js similarity index 99% rename from core/test/functional/api/v2/admin/posts_spec.js rename to core/test/acceptance/old/admin/posts_spec.js index 91127535fa..a1676b43d6 100644 --- a/core/test/functional/api/v2/admin/posts_spec.js +++ b/core/test/acceptance/old/admin/posts_spec.js @@ -3,10 +3,10 @@ const supertest = require('supertest'); const _ = require('lodash'); const ObjectId = require('bson-objectid'); const moment = require('moment-timezone'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); -const models = require('../../../../../../core/server/models'); +const config = require('../../../../server/config'); +const models = require('../../../../server/models'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/redirects_spec.js b/core/test/acceptance/old/admin/redirects_spec.js similarity index 98% rename from core/test/functional/api/v2/admin/redirects_spec.js rename to core/test/acceptance/old/admin/redirects_spec.js index 688407e6ae..d752cfe47f 100644 --- a/core/test/functional/api/v2/admin/redirects_spec.js +++ b/core/test/acceptance/old/admin/redirects_spec.js @@ -3,10 +3,10 @@ const supertest = require('supertest'); const fs = require('fs-extra'); const Promise = require('bluebird'); const path = require('path'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const configUtils = require('../../../../utils/configUtils'); -const config = require('../../../../../../core/server/config'); +const configUtils = require('../../../utils/configUtils'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/roles_spec.js b/core/test/acceptance/old/admin/roles_spec.js similarity index 96% rename from core/test/functional/api/v2/admin/roles_spec.js rename to core/test/acceptance/old/admin/roles_spec.js index 618ddd03f7..d68eb31aaf 100644 --- a/core/test/functional/api/v2/admin/roles_spec.js +++ b/core/test/acceptance/old/admin/roles_spec.js @@ -1,7 +1,7 @@ const should = require('should'); const supertest = require('supertest'); -const config = require('../../../../../../core/server/config'); -const testUtils = require('../../../../utils'); +const config = require('../../../../server/config'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v2/admin/settings_spec.js b/core/test/acceptance/old/admin/settings_spec.js similarity index 98% rename from core/test/functional/api/v2/admin/settings_spec.js rename to core/test/acceptance/old/admin/settings_spec.js index cf75d34fca..c1f92f2884 100644 --- a/core/test/functional/api/v2/admin/settings_spec.js +++ b/core/test/acceptance/old/admin/settings_spec.js @@ -3,8 +3,8 @@ const _ = require('lodash'); const supertest = require('supertest'); const os = require('os'); const fs = require('fs-extra'); -const config = require('../../../../../../core/server/config'); -const testUtils = require('../../../../utils'); +const config = require('../../../../server/config'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/slack_spec.js b/core/test/acceptance/old/admin/slack_spec.js similarity index 89% rename from core/test/functional/api/v2/admin/slack_spec.js rename to core/test/acceptance/old/admin/slack_spec.js index bbdc3b0817..c7269015f5 100644 --- a/core/test/functional/api/v2/admin/slack_spec.js +++ b/core/test/acceptance/old/admin/slack_spec.js @@ -1,10 +1,10 @@ const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../server/config'); -const common = require('../../../../../server/lib/common'); +const config = require('../../../../server/config'); +const common = require('../../../../server/lib/common'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/slugs_spec.js b/core/test/acceptance/old/admin/slugs_spec.js similarity index 97% rename from core/test/functional/api/v2/admin/slugs_spec.js rename to core/test/acceptance/old/admin/slugs_spec.js index f36b8300e2..ad0cc1aa4a 100644 --- a/core/test/functional/api/v2/admin/slugs_spec.js +++ b/core/test/acceptance/old/admin/slugs_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../../utils'), + testUtils = require('../../../utils'), localUtils = require('./utils'), - config = require('../../../../../server/config'), + config = require('../../../../server/config'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v2/admin/subscribers_spec.js b/core/test/acceptance/old/admin/subscribers_spec.js similarity index 97% rename from core/test/functional/api/v2/admin/subscribers_spec.js rename to core/test/acceptance/old/admin/subscribers_spec.js index ca3b6d2bc4..58bce3d36f 100644 --- a/core/test/functional/api/v2/admin/subscribers_spec.js +++ b/core/test/acceptance/old/admin/subscribers_spec.js @@ -2,10 +2,10 @@ const path = require('path'); const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); -const labs = require('../../../../../../core/server/services/labs'); +const config = require('../../../../server/config'); +const labs = require('../../../../server/services/labs'); const ghost = testUtils.startGhost; @@ -208,7 +208,7 @@ describe('Subscribers API', function () { it('importCSV', function () { return request .post(localUtils.API.getApiQuery(`subscribers/csv/`)) - .attach('subscribersfile', path.join(__dirname, '/../../../../utils/fixtures/csv/single-column-with-header.csv')) + .attach('subscribersfile', path.join(__dirname, '/../../../utils/fixtures/csv/single-column-with-header.csv')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) .expect('Cache-Control', testUtils.cacheRules.private) diff --git a/core/test/functional/api/v2/admin/tags_spec.js b/core/test/acceptance/old/admin/tags_spec.js similarity index 98% rename from core/test/functional/api/v2/admin/tags_spec.js rename to core/test/acceptance/old/admin/tags_spec.js index 4c5dd9135b..aaaef8b784 100644 --- a/core/test/functional/api/v2/admin/tags_spec.js +++ b/core/test/acceptance/old/admin/tags_spec.js @@ -1,8 +1,8 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; describe('Tag API V2', function () { diff --git a/core/test/functional/api/v2/admin/upload_spec.js b/core/test/acceptance/old/admin/upload_spec.js similarity index 91% rename from core/test/functional/api/v2/admin/upload_spec.js rename to core/test/acceptance/old/admin/upload_spec.js index 96161dd4ac..b5c19923db 100644 --- a/core/test/functional/api/v2/admin/upload_spec.js +++ b/core/test/acceptance/old/admin/upload_spec.js @@ -3,8 +3,8 @@ const fs = require('fs-extra'); const should = require('should'); const supertest = require('supertest'); const localUtils = require('./utils'); -const testUtils = require('../../../../utils'); -const config = require('../../../../../../core/server/config'); +const testUtils = require('../../../utils'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; @@ -33,7 +33,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/ghost-logo.png')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/ghost-logo.png')) .expect(201) .end(function (err, res) { if (err) { @@ -49,7 +49,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/ghosticon.jpg')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/ghosticon.jpg')) .expect(201) .end(function (err, res) { if (err) { @@ -65,7 +65,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/loadingcat.gif')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/loadingcat.gif')) .expect(201) .end(function (err, res) { if (err) { @@ -81,7 +81,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads/profile-image')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/loadingcat_square.gif')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/loadingcat_square.gif')) .expect(201) .end(function (err, res) { if (err) { @@ -114,7 +114,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/csv/single-column-with-header.csv')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/csv/single-column-with-header.csv')) .expect(415) .end(function (err) { if (err) { @@ -130,7 +130,7 @@ describe('Upload API', function () { .set('Origin', config.get('url')) .set('content-type', 'image/png') .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/ghost-logo.pngx')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/ghost-logo.pngx')) .expect(415) .end(function (err) { if (err) { @@ -145,7 +145,7 @@ describe('Upload API', function () { request.post(localUtils.API.getApiQuery('uploads/profile-image')) .set('Origin', config.get('url')) .expect('Content-Type', /json/) - .attach('uploadimage', path.join(__dirname, '/../../../../utils/fixtures/images/favicon_not_square.png')) + .attach('uploadimage', path.join(__dirname, '/../../../utils/fixtures/images/favicon_not_square.png')) .expect(422) .end(function (err) { if (err) { diff --git a/core/test/functional/api/v2/admin/users_spec.js b/core/test/acceptance/old/admin/users_spec.js similarity index 99% rename from core/test/functional/api/v2/admin/users_spec.js rename to core/test/acceptance/old/admin/users_spec.js index c8d8749440..900c58a9ef 100644 --- a/core/test/functional/api/v2/admin/users_spec.js +++ b/core/test/acceptance/old/admin/users_spec.js @@ -4,11 +4,11 @@ const supertest = require('supertest'); const moment = require('moment'); const Promise = require('bluebird'); const ObjectId = require('bson-objectid'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); -const db = require('../../../../../../core/server/data/db'); -const models = require('../../../../../../core/server/models'); +const config = require('../../../../server/config'); +const db = require('../../../../server/data/db'); +const models = require('../../../../server/models'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/admin/utils.js b/core/test/acceptance/old/admin/utils.js similarity index 96% rename from core/test/functional/api/v2/admin/utils.js rename to core/test/acceptance/old/admin/utils.js index e7d6678e3f..7bee3a4ea1 100644 --- a/core/test/functional/api/v2/admin/utils.js +++ b/core/test/acceptance/old/admin/utils.js @@ -1,7 +1,7 @@ const url = require('url'); const _ = require('lodash'); -const testUtils = require('../../../../utils'); -const schema = require('../../../../../server/data/schema').tables; +const testUtils = require('../../../utils'); +const schema = require('../../../../server/data/schema').tables; const API_URL = '/ghost/api/v2/admin/'; const expectedProperties = { diff --git a/core/test/functional/api/v2/admin/webhooks_spec.js b/core/test/acceptance/old/admin/webhooks_spec.js similarity index 98% rename from core/test/functional/api/v2/admin/webhooks_spec.js rename to core/test/acceptance/old/admin/webhooks_spec.js index 9ac8dda6bd..c66dd4798e 100644 --- a/core/test/functional/api/v2/admin/webhooks_spec.js +++ b/core/test/acceptance/old/admin/webhooks_spec.js @@ -1,8 +1,8 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../../core/server/config'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/content/authors_spec.js b/core/test/acceptance/old/content/authors_spec.js similarity index 96% rename from core/test/functional/api/v2/content/authors_spec.js rename to core/test/acceptance/old/content/authors_spec.js index b81086b30c..ec5953306d 100644 --- a/core/test/functional/api/v2/content/authors_spec.js +++ b/core/test/acceptance/old/content/authors_spec.js @@ -2,10 +2,10 @@ const should = require('should'); const supertest = require('supertest'); const _ = require('lodash'); const url = require('url'); -const configUtils = require('../../../../utils/configUtils'); -const config = require('../../../../../../core/server/config'); -const models = require('../../../../../../core/server/models'); -const testUtils = require('../../../../utils'); +const configUtils = require('../../../utils/configUtils'); +const config = require('../../../../server/config'); +const models = require('../../../../server/models'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/content/pages_spec.js b/core/test/acceptance/old/content/pages_spec.js similarity index 95% rename from core/test/functional/api/v2/content/pages_spec.js rename to core/test/acceptance/old/content/pages_spec.js index 2e3d4bf422..62e64da1ca 100644 --- a/core/test/functional/api/v2/content/pages_spec.js +++ b/core/test/acceptance/old/content/pages_spec.js @@ -1,10 +1,10 @@ const url = require('url'); const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const configUtils = require('../../../../utils/configUtils'); -const config = require('../../../../../../core/server/config'); +const configUtils = require('../../../utils/configUtils'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/content/posts_spec.js b/core/test/acceptance/old/content/posts_spec.js similarity index 99% rename from core/test/functional/api/v2/content/posts_spec.js rename to core/test/acceptance/old/content/posts_spec.js index 61439cc227..b04f1c3805 100644 --- a/core/test/functional/api/v2/content/posts_spec.js +++ b/core/test/acceptance/old/content/posts_spec.js @@ -4,10 +4,10 @@ const _ = require('lodash'); const url = require('url'); const cheerio = require('cheerio'); const moment = require('moment'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const configUtils = require('../../../../utils/configUtils'); -const config = require('../../../../../../core/server/config'); +const configUtils = require('../../../utils/configUtils'); +const config = require('../../../../server/config'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/content/settings_spec.js b/core/test/acceptance/old/content/settings_spec.js similarity index 91% rename from core/test/functional/api/v2/content/settings_spec.js rename to core/test/acceptance/old/content/settings_spec.js index dabe78c760..dae61f9a47 100644 --- a/core/test/functional/api/v2/content/settings_spec.js +++ b/core/test/acceptance/old/content/settings_spec.js @@ -1,13 +1,13 @@ const should = require('should'); const supertest = require('supertest'); const _ = require('lodash'); -const testUtils = require('../../../../utils'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); -const config = require('../../../../../server/config'); +const config = require('../../../../server/config'); // Values to test against -const publicSettings = require('../../../../../server/services/settings/public'); -const defaultSettings = require('../../../../../server/data/schema').defaultSettings.blog; +const publicSettings = require('../../../../server/services/settings/public'); +const defaultSettings = require('../../../../server/data/schema').defaultSettings.blog; const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v2/content/tags_spec.js b/core/test/acceptance/old/content/tags_spec.js similarity index 97% rename from core/test/functional/api/v2/content/tags_spec.js rename to core/test/acceptance/old/content/tags_spec.js index f678eb52a2..9e5e13802d 100644 --- a/core/test/functional/api/v2/content/tags_spec.js +++ b/core/test/acceptance/old/content/tags_spec.js @@ -2,9 +2,9 @@ const should = require('should'); const supertest = require('supertest'); const _ = require('lodash'); const url = require('url'); -const configUtils = require('../../../../utils/configUtils'); -const config = require('../../../../../../core/server/config'); -const testUtils = require('../../../../utils'); +const configUtils = require('../../../utils/configUtils'); +const config = require('../../../../server/config'); +const testUtils = require('../../../utils'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v2/content/utils.js b/core/test/acceptance/old/content/utils.js similarity index 95% rename from core/test/functional/api/v2/content/utils.js rename to core/test/acceptance/old/content/utils.js index 6da3f963f8..0b741533b5 100644 --- a/core/test/functional/api/v2/content/utils.js +++ b/core/test/acceptance/old/content/utils.js @@ -1,7 +1,7 @@ const url = require('url'); const _ = require('lodash'); -const testUtils = require('../../../../utils'); -const schema = require('../../../../../server/data/schema').tables; +const testUtils = require('../../../utils'); +const schema = require('../../../../server/data/schema').tables; const API_URL = '/ghost/api/v2/content/'; const expectedProperties = { diff --git a/core/test/integration/model/model_accesstoken_spec.js b/core/test/integration/model/model_accesstoken_spec.js deleted file mode 100644 index f7b3f611a3..0000000000 --- a/core/test/integration/model/model_accesstoken_spec.js +++ /dev/null @@ -1,40 +0,0 @@ -var should = require('should'), - sinon = require('sinon'), - testUtils = require('../../utils'), - common = require('../../../server/lib/common'), - constants = require('../../../server/lib/constants'), - AccesstokenModel = require('../../../server/models/accesstoken').Accesstoken; - -describe('Accesstoken Model', function () { - // Keep the DB clean - before(testUtils.teardown); - afterEach(testUtils.teardown); - - afterEach(function () { - sinon.restore(); - }); - - beforeEach(testUtils.setup('owner', 'clients')); - - it('on creation emits token.added event', function (done) { - // Setup - const eventSpy = sinon.spy(common.events, 'emit'); - - // Test - // Stub refreshtoken - AccesstokenModel.add({ - token: 'foobartoken', - user_id: testUtils.DataGenerator.Content.users[0].id, - client_id: testUtils.DataGenerator.forKnex.clients[0].id, - expires: Date.now() + constants.ONE_MONTH_MS - }) - .then(function (token) { - should.exist(token); - // Assert - eventSpy.calledOnce.should.be.true(); - eventSpy.calledWith('token.added').should.be.true(); - - done(); - }).catch(done); - }); -}); diff --git a/core/test/integration/model/model_app-fields_spec.js b/core/test/integration/model/model_app-fields_spec.js deleted file mode 100644 index 74d5d2517d..0000000000 --- a/core/test/integration/model/model_app-fields_spec.js +++ /dev/null @@ -1,53 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - - // Stuff we are testing - AppFieldsModel = require('../../../server/models/app-field').AppField, - context = testUtils.context.admin; - -describe('App Fields Model', function () { - // Keep the DB clean - before(testUtils.teardown); - after(testUtils.teardown); - before(testUtils.setup('app_field')); - - before(function () { - should.exist(AppFieldsModel); - }); - - it('can findAll', function (done) { - AppFieldsModel.findAll().then(function (results) { - should.exist(results); - - results.length.should.be.above(0); - - done(); - }).catch(done); - }); - - it('can findOne', function (done) { - AppFieldsModel.findOne({id: testUtils.DataGenerator.Content.app_fields[0].id}).then(function (foundAppField) { - should.exist(foundAppField); - - foundAppField.get('created_at').should.be.an.instanceof(Date); - - done(); - }).catch(done); - }); - - it('can edit', function (done) { - AppFieldsModel.findOne({id: testUtils.DataGenerator.Content.app_fields[0].id}).then(function (foundAppField) { - should.exist(foundAppField); - - return foundAppField.set({value: '350'}).save(null, context); - }).then(function () { - return AppFieldsModel.findOne({id: testUtils.DataGenerator.Content.app_fields[0].id}); - }).then(function (updatedAppField) { - should.exist(updatedAppField); - - updatedAppField.get('value').should.equal('350'); - - done(); - }).catch(done); - }); -}); diff --git a/core/test/integration/model/model_app-settings_spec.js b/core/test/integration/model/model_app-settings_spec.js deleted file mode 100644 index bcd433fa5c..0000000000 --- a/core/test/integration/model/model_app-settings_spec.js +++ /dev/null @@ -1,53 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - - // Stuff we are testing - AppSettingModel = require('../../../server/models/app-setting').AppSetting, - context = testUtils.context.admin; - -describe('App Setting Model', function () { - // Keep the DB clean - before(testUtils.teardown); - after(testUtils.teardown); - before(testUtils.setup('app_setting')); - - before(function () { - should.exist(AppSettingModel); - }); - - it('can findAll', function (done) { - AppSettingModel.findAll().then(function (results) { - should.exist(results); - - results.length.should.be.above(0); - - done(); - }).catch(done); - }); - - it('can findOne', function (done) { - AppSettingModel.findOne({id: testUtils.DataGenerator.Content.app_settings[0].id}).then(function (foundAppSetting) { - should.exist(foundAppSetting); - - foundAppSetting.get('created_at').should.be.an.instanceof(Date); - - done(); - }).catch(done); - }); - - it('can edit', function (done) { - AppSettingModel.findOne({id: testUtils.DataGenerator.Content.app_settings[0].id}).then(function (foundAppSetting) { - should.exist(foundAppSetting); - - return foundAppSetting.set({value: '350'}).save(null, context); - }).then(function () { - return AppSettingModel.findOne({id: testUtils.DataGenerator.Content.app_settings[0].id}); - }).then(function (updatedAppSetting) { - should.exist(updatedAppSetting); - - updatedAppSetting.get('value').should.equal('350'); - - done(); - }).catch(done); - }); -}); diff --git a/core/test/integration/model/model_apps_spec.js b/core/test/integration/model/model_apps_spec.js deleted file mode 100644 index 46a8c859e9..0000000000 --- a/core/test/integration/model/model_apps_spec.js +++ /dev/null @@ -1,109 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - sequence = require('../../../server/lib/promise/sequence'), - _ = require('lodash'), - - // Stuff we are testing - AppModel = require('../../../server/models/app').App, - context = testUtils.context.admin; - -describe('App Model', function () { - // Keep the DB clean - before(testUtils.teardown); - after(testUtils.teardown); - before(testUtils.setup('app')); - - before(function () { - should.exist(AppModel); - }); - - it('can findAll', function (done) { - AppModel.findAll().then(function (results) { - should.exist(results); - - results.length.should.be.above(0); - - done(); - }).catch(done); - }); - - it('can findOne', function (done) { - AppModel.findOne({id: testUtils.DataGenerator.Content.apps[0].id}).then(function (foundApp) { - should.exist(foundApp); - - foundApp.get('created_at').should.be.an.instanceof(Date); - - done(); - }).catch(done); - }); - - it('can edit', function (done) { - AppModel.findOne({id: testUtils.DataGenerator.Content.apps[0].id}).then(function (foundApp) { - should.exist(foundApp); - - return foundApp.set({name: 'New App'}).save(null, context); - }).then(function () { - return AppModel.findOne({id: testUtils.DataGenerator.Content.apps[0].id}); - }).then(function (updatedApp) { - should.exist(updatedApp); - - updatedApp.get('name').should.equal('New App'); - - done(); - }).catch(done); - }); - - it('can add', function (done) { - var newApp = testUtils.DataGenerator.forKnex.createApp(testUtils.DataGenerator.Content.apps[1]); - - AppModel.add(newApp, context).then(function (createdApp) { - should.exist(createdApp); - - createdApp.attributes.name.should.equal(newApp.name); - - done(); - }).catch(done); - }); - - it('can destroy', function (done) { - var firstApp = {id: testUtils.DataGenerator.Content.apps[0].id}; - - AppModel.findOne(firstApp).then(function (foundApp) { - should.exist(foundApp); - foundApp.attributes.id.should.equal(firstApp.id); - - return AppModel.destroy(firstApp); - }).then(function (response) { - response.toJSON().should.be.empty(); - - return AppModel.findOne(firstApp); - }).then(function (newResults) { - should.equal(newResults, null); - - done(); - }).catch(done); - }); - - it('can generate a slug', function (done) { - // Create 12 apps - sequence(_.times(12, function (i) { - return function () { - return AppModel.add({ - name: 'Kudos ' + i, - version: '0.0.1', - status: 'installed' - }, context); - }; - })).then(function (createdApps) { - // Should have created 12 apps - createdApps.length.should.equal(12); - - // Should have matching slugs - _(createdApps).each(function (app, i) { - app.get('slug').should.equal('kudos-' + i); - }); - - done(); - }).catch(done); - }); -}); diff --git a/core/test/integration/model/model_invite_spec.js b/core/test/integration/model/model_invite_spec.js deleted file mode 100644 index e7e7fcb3a4..0000000000 --- a/core/test/integration/model/model_invite_spec.js +++ /dev/null @@ -1,28 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - models = require('../../../server/models'); - -describe('Invite Model', function () { - before(testUtils.teardown); - afterEach(testUtils.teardown); - - describe('add invite', function () { - beforeEach(testUtils.setup()); - - it('create invite', function (done) { - models.Invite.add({ - email: 'test@test.de', - role_id: testUtils.roles.ids.admin - }, testUtils.context.internal) - .then(function (invite) { - should.exist(invite); - should.exist(invite.get('token')); - should.exist(invite.get('expires')); - should.exist(invite.get('email')); - should.exist(invite.get('role_id')); - done(); - }) - .catch(done); - }); - }); -}); diff --git a/core/test/integration/model/model_permissions_spec.js b/core/test/integration/model/model_permissions_spec.js deleted file mode 100644 index 10a6824ed1..0000000000 --- a/core/test/integration/model/model_permissions_spec.js +++ /dev/null @@ -1,174 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - - // Stuff we are testing - PermissionModel = require('../../../server/models/permission').Permission, - context = testUtils.context.admin; - -describe('Permission Model', function () { - // Keep the DB clean - before(testUtils.teardown); - after(testUtils.teardown); - before(testUtils.setup('permission')); - - before(function () { - should.exist(PermissionModel); - }); - - it('can findAll', function (done) { - PermissionModel.findAll().then(function (foundPermissions) { - should.exist(foundPermissions); - - foundPermissions.models.length.should.be.above(0); - - done(); - }).catch(done); - }); - - it('can findOne', function (done) { - PermissionModel.findOne({id: testUtils.DataGenerator.Content.permissions[0].id}).then(function (foundPermission) { - should.exist(foundPermission); - foundPermission.get('created_at').should.be.an.instanceof(Date); - - done(); - }).catch(done); - }); - - it('can edit', function (done) { - PermissionModel.findOne({id: testUtils.DataGenerator.Content.permissions[0].id}).then(function (foundPermission) { - should.exist(foundPermission); - - return foundPermission.set({name: 'updated'}).save(null, context); - }).then(function () { - return PermissionModel.findOne({id: testUtils.DataGenerator.Content.permissions[0].id}); - }).then(function (updatedPermission) { - should.exist(updatedPermission); - - updatedPermission.get('name').should.equal('updated'); - - done(); - }).catch(done); - }); - - it('can add', function (done) { - var newPerm = { - name: 'testperm1', - object_type: 'test', - action_type: 'test' - }; - - PermissionModel.add(newPerm, context).then(function (createdPerm) { - should.exist(createdPerm); - - createdPerm.attributes.name.should.equal(newPerm.name); - - done(); - }).catch(done); - }); - - it('can destroy', function (done) { - var firstPermission = {id: testUtils.DataGenerator.Content.permissions[0].id}; - - PermissionModel.findOne(firstPermission).then(function (foundPermission) { - should.exist(foundPermission); - foundPermission.attributes.id.should.equal(firstPermission.id); - - return PermissionModel.destroy(firstPermission); - }).then(function (response) { - response.toJSON({shallow: true}).should.be.empty(); - return PermissionModel.findOne(firstPermission); - }).then(function (newResults) { - should.equal(newResults, null); - - done(); - }).catch(done); - }); - - // it('can add user to role', function (done) { - // var existingUserRoles; - - // Models.User.findOne({id: 1}, { withRelated: ['roles'] }).then(function (foundUser) { - // var testRole = new Models.Role({ - // name: 'testrole1', - // description: 'testrole1 description' - // }); - - // should.exist(foundUser); - - // should.exist(foundUser.roles()); - - // existingUserRoles = foundUser.related('roles').length; - - // return testRole.save(null, context).then(function () { - // return foundUser.roles().attach(testRole); - // }); - // }).then(function () { - // return Models.User.findOne({id: 1}, { withRelated: ['roles'] }); - // }).then(function (updatedUser) { - // should.exist(updatedUser); - - // updatedUser.related('roles').length.should.equal(existingUserRoles + 1); - - // done(); - // }).catch(done); - // }); - - // it('can add user permissions', function (done) { - // Models.User.findOne({id: 1}, { withRelated: ['permissions']}).then(function (testUser) { - // var testPermission = new Models.Permission({ - // name: 'test edit posts', - // action_type: 'edit', - // object_type: 'post' - // }); - - // testUser.related('permissions').length.should.equal(0); - - // return testPermission.save(null, context).then(function () { - // return testUser.permissions().attach(testPermission); - // }); - // }).then(function () { - // return Models.User.findOne({id: 1}, { withRelated: ['permissions']}); - // }).then(function (updatedUser) { - // should.exist(updatedUser); - - // updatedUser.related('permissions').length.should.equal(1); - - // done(); - // }).catch(done); - // }); - - // it('can add role permissions', function (done) { - // var testRole = new Models.Role({ - // name: 'test2', - // description: 'test2 description' - // }); - - // testRole.save(null, context) - // .then(function () { - // return testRole.load('permissions'); - // }) - // .then(function () { - // var rolePermission = new Models.Permission({ - // name: 'test edit posts', - // action_type: 'edit', - // object_type: 'post' - // }); - - // testRole.related('permissions').length.should.equal(0); - - // return rolePermission.save(null, context).then(function () { - // return testRole.permissions().attach(rolePermission); - // }); - // }) - // .then(function () { - // return Models.Role.findOne({id: testRole.id}, { withRelated: ['permissions']}); - // }) - // .then(function (updatedRole) { - // should.exist(updatedRole); - - // updatedRole.related('permissions').length.should.equal(1); - - // done(); - // }).catch(done); - // }); -}); diff --git a/core/test/integration/model/model_roles_spec.js b/core/test/integration/model/model_roles_spec.js deleted file mode 100644 index f09ce1cf0a..0000000000 --- a/core/test/integration/model/model_roles_spec.js +++ /dev/null @@ -1,87 +0,0 @@ -var should = require('should'), - testUtils = require('../../utils'), - - // Stuff we are testing - RoleModel = require('../../../server/models/role').Role, - context = testUtils.context.admin; - -describe('Role Model', function () { - // Keep the DB clean - before(testUtils.teardown); - afterEach(testUtils.teardown); - - beforeEach(testUtils.setup('role')); - - before(function () { - should.exist(RoleModel); - }); - - it('can findAll', function (done) { - RoleModel.findAll().then(function (foundRoles) { - should.exist(foundRoles); - - foundRoles.models.length.should.be.above(0); - - done(); - }).catch(done); - }); - - it('can findOne', function (done) { - RoleModel.findOne({id: testUtils.DataGenerator.Content.roles[0].id}).then(function (foundRole) { - should.exist(foundRole); - foundRole.get('created_at').should.be.an.instanceof(Date); - - done(); - }).catch(done); - }); - - it('can edit', function (done) { - RoleModel.findOne({id: testUtils.DataGenerator.Content.roles[0].id}).then(function (foundRole) { - should.exist(foundRole); - - return foundRole.set({name: 'updated'}).save(null, context); - }).then(function () { - return RoleModel.findOne({id: testUtils.DataGenerator.Content.roles[0].id}); - }).then(function (updatedRole) { - should.exist(updatedRole); - - updatedRole.get('name').should.equal('updated'); - - done(); - }).catch(done); - }); - - it('can add', function (done) { - var newRole = { - name: 'test1', - description: 'test1 description' - }; - - RoleModel.add(newRole, context).then(function (createdRole) { - should.exist(createdRole); - - createdRole.attributes.name.should.equal(newRole.name); - createdRole.attributes.description.should.equal(newRole.description); - - done(); - }).catch(done); - }); - - it('can destroy', function (done) { - var firstRole = {id: testUtils.DataGenerator.Content.roles[0].id}; - - RoleModel.findOne(firstRole).then(function (foundRole) { - should.exist(foundRole); - foundRole.attributes.id.should.equal(firstRole.id); - - return RoleModel.destroy(firstRole); - }).then(function (response) { - response.toJSON().permissions.should.be.empty(); - return RoleModel.findOne(firstRole); - }).then(function (newResults) { - should.equal(newResults, null); - - done(); - }).catch(done); - }); -}); diff --git a/core/test/integration/model/model_tags_spec.js b/core/test/integration/model/model_tags_spec.js deleted file mode 100644 index 69f33b31bc..0000000000 --- a/core/test/integration/model/model_tags_spec.js +++ /dev/null @@ -1,141 +0,0 @@ -var should = require('should'), - sinon = require('sinon'), - _ = require('lodash'), - testUtils = require('../../utils'), - - // Stuff we are testing - db = require('../../../server/data/db'), - models = require('../../../server/models'), - common = require('../../../server/lib/common'), - context = testUtils.context.admin; - -describe('Tag Model', function () { - var eventSpy; - - // Keep the DB clean - before(testUtils.teardown); - after(testUtils.teardown); - before(testUtils.setup('users:roles', 'posts')); - - afterEach(function () { - sinon.restore(); - }); - - beforeEach(function () { - eventSpy = sinon.spy(common.events, 'emit'); - }); - - describe('findPage', function () { - it('with limit all', function (done) { - models.Tag.findPage({limit: 'all'}) - .then(function (results) { - results.meta.pagination.page.should.equal(1); - results.meta.pagination.limit.should.equal('all'); - results.meta.pagination.pages.should.equal(1); - results.data.length.should.equal(5); - - done(); - }) - .catch(done); - }); - - it('with include count.posts', function (done) { - models.Tag.findPage({limit: 'all', withRelated: ['count.posts']}) - .then(function (results) { - results.meta.pagination.page.should.equal(1); - results.meta.pagination.limit.should.equal('all'); - results.meta.pagination.pages.should.equal(1); - results.data.length.should.equal(5); - should.exist(results.data[0].toJSON().count.posts); - - done(); - }) - .catch(done); - }); - }); - - describe('findOne', function () { - it('with slug', function (done) { - var firstTag; - - models.Tag.findPage() - .then(function (results) { - should.exist(results); - should.exist(results.data); - results.data.length.should.be.above(0); - firstTag = results.data[0].toJSON(); - - return models.Tag.findOne({slug: firstTag.slug}); - }) - .then(function (found) { - should.exist(found); - - done(); - }) - .catch(done); - }); - }); - - describe('add', function () { - it('uses Date objects for dateTime fields', function (done) { - models.Tag.add(_.omit(testUtils.DataGenerator.forModel.tags[0], 'id'), context) - .then(function (tag) { - return models.Tag.findOne({id: tag.id}); - }) - .then(function (tag) { - should.exist(tag); - tag.get('created_at').should.be.an.instanceof(Date); - - done(); - }) - .catch(done); - }); - - it('returns count.posts if include count.posts', function (done) { - models.Tag.findOne({slug: 'kitchen-sink'}, {withRelated: ['count.posts']}) - .then(function (tag) { - should.exist(tag); - tag.toJSON().count.posts.should.equal(2); - - done(); - }) - .catch(done); - }); - - it('can strip invisible unicode from slug', function () { - const tag = Object.assign(_.omit(testUtils.DataGenerator.forModel.tags[0], 'id'), { - slug: 'abc\u0008', - }); - return models.Tag.add(tag, context) - .then(function (newTag) { - should.exist(newTag); - newTag.get('slug').should.equal('abc'); - }); - }); - }); - - describe('destroy', function () { - it('can destroy Tag (using transaction)', function () { - var firstTag = testUtils.DataGenerator.Content.tags[0].id; - - return db.knex('posts_tags').where('tag_id', firstTag) - .then(function (response) { - response.length.should.eql(2); - }) - .then(function () { - return db.knex.transaction(function (transacting) { - return models.Tag.destroy({ - id: firstTag, - transacting: transacting - }); - }); - }) - .then(function () { - return db.knex('posts_tags').where('tag_id', firstTag); - }) - .then(function (response) { - response.length.should.eql(0); - }); - }); - }); -}); diff --git a/core/test/regression/README.md b/core/test/regression/README.md new file mode 100644 index 0000000000..1ccf1d8854 --- /dev/null +++ b/core/test/regression/README.md @@ -0,0 +1,6 @@ +## Regression Tests + +This folder should contain packages which we test in a cron job once per day. +These tests should ensure that we don't break Ghost. + +The goal is that most of these packages use Ghost's API's to test behaviours, otherwise transform the tests into unit tests. diff --git a/core/test/functional/admin_spec.js b/core/test/regression/api/admin_spec.js similarity index 95% rename from core/test/functional/admin_spec.js rename to core/test/regression/api/admin_spec.js index 0d8b5a0dc6..6a73e650b3 100644 --- a/core/test/functional/admin_spec.js +++ b/core/test/regression/api/admin_spec.js @@ -5,11 +5,11 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../utils'), - configUtils = require('../utils/configUtils'), + testUtils = require('../../utils/index'), + configUtils = require('../../utils/configUtils'), ghost = testUtils.startGhost, - common = require('../../server/lib/common'), - config = require('../../server/config'), + common = require('../../../server/lib/common/index'), + config = require('../../../server/config/index'), request; common.i18n.init(); diff --git a/core/test/functional/api/v0.1/authentication_spec.js b/core/test/regression/api/v0.1/authentication_spec.js similarity index 97% rename from core/test/functional/api/v0.1/authentication_spec.js rename to core/test/regression/api/v0.1/authentication_spec.js index b8bdae9d0e..8890d55f31 100644 --- a/core/test/functional/api/v0.1/authentication_spec.js +++ b/core/test/regression/api/v0.1/authentication_spec.js @@ -1,14 +1,14 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), moment = require('moment'), user = testUtils.DataGenerator.forModel.users[0], - models = require('../../../../../core/server/models'), - constants = require('../../../../../core/server/lib/constants'), - config = require('../../../../../core/server/config'), - security = require('../../../../../core/server/lib/security'), - settingsCache = require('../../../../../core/server/services/settings/cache'), + models = require('../../../../server/models/index'), + constants = require('../../../../server/lib/constants'), + config = require('../../../../server/config/index'), + security = require('../../../../server/lib/security/index'), + settingsCache = require('../../../../server/services/settings/cache'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/configuration_spec.js b/core/test/regression/api/v0.1/configuration_spec.js similarity index 96% rename from core/test/functional/api/v0.1/configuration_spec.js rename to core/test/regression/api/v0.1/configuration_spec.js index af21de27b4..7910c4bd35 100644 --- a/core/test/functional/api/v0.1/configuration_spec.js +++ b/core/test/regression/api/v0.1/configuration_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/db_spec.js b/core/test/regression/api/v0.1/db_spec.js similarity index 97% rename from core/test/functional/api/v0.1/db_spec.js rename to core/test/regression/api/v0.1/db_spec.js index 3221b250cd..2290def399 100644 --- a/core/test/functional/api/v0.1/db_spec.js +++ b/core/test/regression/api/v0.1/db_spec.js @@ -1,14 +1,14 @@ const should = require('should'); const supertest = require('supertest'); const Promise = require('bluebird'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const path = require('path'); const sinon = require('sinon'); -const config = require('../../../../../core/server/config'); -const models = require('../../../../../core/server/models'); +const config = require('../../../../server/config/index'); +const models = require('../../../../server/models/index'); const fs = require('fs-extra'); const _ = require('lodash'); -const common = require('../../../../server/lib/common'); +const common = require('../../../../server/lib/common/index'); const localUtils = require('./utils'); let ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v0.1/error_spec.js b/core/test/regression/api/v0.1/error_spec.js similarity index 96% rename from core/test/functional/api/v0.1/error_spec.js rename to core/test/regression/api/v0.1/error_spec.js index 5942c724c8..ccbb4bbf89 100644 --- a/core/test/functional/api/v0.1/error_spec.js +++ b/core/test/regression/api/v0.1/error_spec.js @@ -4,9 +4,9 @@ // But then again testing real code, rather than mock code, might be more useful... var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/invites_spec.js b/core/test/regression/api/v0.1/invites_spec.js similarity index 97% rename from core/test/functional/api/v0.1/invites_spec.js rename to core/test/regression/api/v0.1/invites_spec.js index d259474816..c79321a3f5 100644 --- a/core/test/functional/api/v0.1/invites_spec.js +++ b/core/test/regression/api/v0.1/invites_spec.js @@ -1,10 +1,10 @@ const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); -const config = require('../../../../../core/server/config'); -const mailService = require('../../../../../core/server/services/mail'); +const config = require('../../../../server/config/index'); +const mailService = require('../../../../server/services/mail/index'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v0.1/notifications_spec.js b/core/test/regression/api/v0.1/notifications_spec.js similarity index 98% rename from core/test/functional/api/v0.1/notifications_spec.js rename to core/test/regression/api/v0.1/notifications_spec.js index c436e31a62..cd87213543 100644 --- a/core/test/functional/api/v0.1/notifications_spec.js +++ b/core/test/regression/api/v0.1/notifications_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/oembed_spec.js b/core/test/regression/api/v0.1/oembed_spec.js similarity index 95% rename from core/test/functional/api/v0.1/oembed_spec.js rename to core/test/regression/api/v0.1/oembed_spec.js index ef30b974ce..644b90c5bd 100644 --- a/core/test/functional/api/v0.1/oembed_spec.js +++ b/core/test/regression/api/v0.1/oembed_spec.js @@ -1,8 +1,8 @@ -const config = require('../../../../../core/server/config'); +const config = require('../../../../server/config/index'); const nock = require('nock'); const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v0.1/posts_spec.js b/core/test/regression/api/v0.1/posts_spec.js similarity index 99% rename from core/test/functional/api/v0.1/posts_spec.js rename to core/test/regression/api/v0.1/posts_spec.js index 830fb3962c..b15f1d4305 100644 --- a/core/test/functional/api/v0.1/posts_spec.js +++ b/core/test/regression/api/v0.1/posts_spec.js @@ -3,9 +3,9 @@ var should = require('should'), moment = require('moment'), _ = require('lodash'), ObjectId = require('bson-objectid'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, markdownToMobiledoc = testUtils.DataGenerator.markdownToMobiledoc, request; diff --git a/core/test/functional/api/v0.1/public_api_spec.js b/core/test/regression/api/v0.1/public_api_spec.js similarity index 99% rename from core/test/functional/api/v0.1/public_api_spec.js rename to core/test/regression/api/v0.1/public_api_spec.js index 23f02e1922..93a3d3c5ed 100644 --- a/core/test/functional/api/v0.1/public_api_spec.js +++ b/core/test/regression/api/v0.1/public_api_spec.js @@ -4,11 +4,11 @@ var should = require('should'), url = require('url'), cheerio = require('cheerio'), moment = require('moment'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), configUtils = require('../../../utils/configUtils'), - config = require('../../../../../core/server/config'), - models = require('../../../../../core/server/models'), + config = require('../../../../server/config/index'), + models = require('../../../../server/models/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/redirects_spec.js b/core/test/regression/api/v0.1/redirects_spec.js similarity index 99% rename from core/test/functional/api/v0.1/redirects_spec.js rename to core/test/regression/api/v0.1/redirects_spec.js index 0a406a4dec..f4e4f1583e 100644 --- a/core/test/functional/api/v0.1/redirects_spec.js +++ b/core/test/regression/api/v0.1/redirects_spec.js @@ -3,10 +3,10 @@ var should = require('should'), fs = require('fs-extra'), Promise = require('bluebird'), path = require('path'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), configUtils = require('../../../utils/configUtils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request, accesstoken; diff --git a/core/test/functional/api/v0.1/roles_spec.js b/core/test/regression/api/v0.1/roles_spec.js similarity index 96% rename from core/test/functional/api/v0.1/roles_spec.js rename to core/test/regression/api/v0.1/roles_spec.js index af299f44b7..74e976fcca 100644 --- a/core/test/functional/api/v0.1/roles_spec.js +++ b/core/test/regression/api/v0.1/roles_spec.js @@ -1,8 +1,8 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); -const config = require('../../../../../core/server/config'); +const config = require('../../../../server/config/index'); const ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/api/v0.1/schedules_spec.js b/core/test/regression/api/v0.1/schedules_spec.js similarity index 95% rename from core/test/functional/api/v0.1/schedules_spec.js rename to core/test/regression/api/v0.1/schedules_spec.js index 7795226590..88bded4a88 100644 --- a/core/test/functional/api/v0.1/schedules_spec.js +++ b/core/test/regression/api/v0.1/schedules_spec.js @@ -3,11 +3,11 @@ const supertest = require('supertest'); const Promise = require('bluebird'); const sinon = require('sinon'); const moment = require('moment-timezone'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); -const SchedulingDefault = require('../../../../../core/server/adapters/scheduling/SchedulingDefault'); -const models = require('../../../../../core/server/models'); -const config = require('../../../../../core/server/config'); +const SchedulingDefault = require('../../../../server/adapters/scheduling/SchedulingDefault'); +const models = require('../../../../server/models/index'); +const config = require('../../../../server/config/index'); const ghost = testUtils.startGhost; describe('Schedules API', function () { diff --git a/core/test/functional/api/v0.1/settings_spec.js b/core/test/regression/api/v0.1/settings_spec.js similarity index 99% rename from core/test/functional/api/v0.1/settings_spec.js rename to core/test/regression/api/v0.1/settings_spec.js index ba59197113..ef8206ae07 100644 --- a/core/test/functional/api/v0.1/settings_spec.js +++ b/core/test/regression/api/v0.1/settings_spec.js @@ -3,9 +3,9 @@ var should = require('should'), supertest = require('supertest'), os = require('os'), fs = require('fs-extra'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/slugs_spec.js b/core/test/regression/api/v0.1/slugs_spec.js similarity index 97% rename from core/test/functional/api/v0.1/slugs_spec.js rename to core/test/regression/api/v0.1/slugs_spec.js index 94592ae85f..15633ff070 100644 --- a/core/test/functional/api/v0.1/slugs_spec.js +++ b/core/test/regression/api/v0.1/slugs_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/spam_prevention_spec.js b/core/test/regression/api/v0.1/spam_prevention_spec.js similarity index 96% rename from core/test/functional/api/v0.1/spam_prevention_spec.js rename to core/test/regression/api/v0.1/spam_prevention_spec.js index 387ef83567..30d2246336 100644 --- a/core/test/functional/api/v0.1/spam_prevention_spec.js +++ b/core/test/regression/api/v0.1/spam_prevention_spec.js @@ -1,9 +1,9 @@ const should = require('should'); const supertest = require('supertest'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); -const db = require('../../../../../core/server/data/db'); -const config = require('../../../../../core/server/config'); +const db = require('../../../../server/data/db/index'); +const config = require('../../../../server/config/index'); const executeRequests = (attempts, requestFn, ...args) => { if (attempts === 0) { diff --git a/core/test/functional/api/v0.1/subscribers_spec.js b/core/test/regression/api/v0.1/subscribers_spec.js similarity index 98% rename from core/test/functional/api/v0.1/subscribers_spec.js rename to core/test/regression/api/v0.1/subscribers_spec.js index 02f89ec067..a7ed7d11de 100644 --- a/core/test/functional/api/v0.1/subscribers_spec.js +++ b/core/test/regression/api/v0.1/subscribers_spec.js @@ -2,10 +2,10 @@ const should = require('should'); const supertest = require('supertest'); const sinon = require('sinon'); const path = require('path'); -const testUtils = require('../../../utils'); +const testUtils = require('../../../utils/index'); const localUtils = require('./utils'); -const config = require('../../../../../core/server/config'); -const labs = require('../../../../../core/server/services/labs'); +const config = require('../../../../server/config/index'); +const labs = require('../../../../server/services/labs'); const ghost = testUtils.startGhost; diff --git a/core/test/functional/api/v0.1/tags_spec.js b/core/test/regression/api/v0.1/tags_spec.js similarity index 98% rename from core/test/functional/api/v0.1/tags_spec.js rename to core/test/regression/api/v0.1/tags_spec.js index afcca90dfc..cd0b079cf1 100644 --- a/core/test/functional/api/v0.1/tags_spec.js +++ b/core/test/regression/api/v0.1/tags_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/themes_spec.js b/core/test/regression/api/v0.1/themes_spec.js similarity index 99% rename from core/test/functional/api/v0.1/themes_spec.js rename to core/test/regression/api/v0.1/themes_spec.js index 18a778202d..7d4c191a9e 100644 --- a/core/test/functional/api/v0.1/themes_spec.js +++ b/core/test/regression/api/v0.1/themes_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, fs = require('fs-extra'), path = require('path'), diff --git a/core/test/functional/api/v0.1/upload_icon_spec.js b/core/test/regression/api/v0.1/upload_icon_spec.js similarity index 98% rename from core/test/functional/api/v0.1/upload_icon_spec.js rename to core/test/regression/api/v0.1/upload_icon_spec.js index a4c8abe266..d283a1e213 100644 --- a/core/test/functional/api/v0.1/upload_icon_spec.js +++ b/core/test/regression/api/v0.1/upload_icon_spec.js @@ -1,11 +1,11 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), path = require('path'), fs = require('fs-extra'), ghost = testUtils.startGhost, - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), request; describe('Upload Icon API', function () { diff --git a/core/test/functional/api/v0.1/upload_spec.js b/core/test/regression/api/v0.1/upload_spec.js similarity index 98% rename from core/test/functional/api/v0.1/upload_spec.js rename to core/test/regression/api/v0.1/upload_spec.js index a7a43b253c..46bd4b1fe1 100644 --- a/core/test/functional/api/v0.1/upload_spec.js +++ b/core/test/regression/api/v0.1/upload_spec.js @@ -1,11 +1,11 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), path = require('path'), fs = require('fs-extra'), ghost = testUtils.startGhost, - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), request; describe('Upload API', function () { diff --git a/core/test/functional/api/v0.1/users_spec.js b/core/test/regression/api/v0.1/users_spec.js similarity index 99% rename from core/test/functional/api/v0.1/users_spec.js rename to core/test/regression/api/v0.1/users_spec.js index 2f810d93b6..e3031e6f65 100644 --- a/core/test/functional/api/v0.1/users_spec.js +++ b/core/test/regression/api/v0.1/users_spec.js @@ -3,11 +3,11 @@ var should = require('should'), supertest = require('supertest'), moment = require('moment'), Promise = require('bluebird'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), ObjectId = require('bson-objectid'), - config = require('../../../../../core/server/config'), - models = require('../../../../../core/server/models'), + config = require('../../../../server/config/index'), + models = require('../../../../server/models/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/api/v0.1/utils.js b/core/test/regression/api/v0.1/utils.js similarity index 96% rename from core/test/functional/api/v0.1/utils.js rename to core/test/regression/api/v0.1/utils.js index fde24bfe82..9b77e024cc 100644 --- a/core/test/functional/api/v0.1/utils.js +++ b/core/test/regression/api/v0.1/utils.js @@ -1,7 +1,7 @@ const url = require('url'); const _ = require('lodash'); -const testUtils = require('../../../utils'); -const schema = require('../../../../server/data/schema').tables; +const testUtils = require('../../../utils/index'); +const schema = require('../../../../server/data/schema/index').tables; const API_URL = '/ghost/api/v0.1/'; const expectedProperties = { diff --git a/core/test/functional/api/v0.1/webhooks_spec.js b/core/test/regression/api/v0.1/webhooks_spec.js similarity index 97% rename from core/test/functional/api/v0.1/webhooks_spec.js rename to core/test/regression/api/v0.1/webhooks_spec.js index e0da006439..b4281c6970 100644 --- a/core/test/functional/api/v0.1/webhooks_spec.js +++ b/core/test/regression/api/v0.1/webhooks_spec.js @@ -1,8 +1,8 @@ var should = require('should'), supertest = require('supertest'), - testUtils = require('../../../utils'), + testUtils = require('../../../utils/index'), localUtils = require('./utils'), - config = require('../../../../../core/server/config'), + config = require('../../../../server/config/index'), ghost = testUtils.startGhost, request; diff --git a/core/test/functional/apps/subscribers/routing_spec.js b/core/test/regression/apps/subscribers/routing_spec.js similarity index 100% rename from core/test/functional/apps/subscribers/routing_spec.js rename to core/test/regression/apps/subscribers/routing_spec.js diff --git a/core/test/integration/export_spec.js b/core/test/regression/exporter/exporter_spec.js similarity index 88% rename from core/test/integration/export_spec.js rename to core/test/regression/exporter/exporter_spec.js index 2ff1cc3c98..0dc1690799 100644 --- a/core/test/integration/export_spec.js +++ b/core/test/regression/exporter/exporter_spec.js @@ -1,11 +1,11 @@ var should = require('should'), sinon = require('sinon'), - testUtils = require('../utils'), + testUtils = require('../../utils'), _ = require('lodash'), // Stuff we are testing - exporter = require('../../server/data/exporter'), - ghostVersion = require('../../server/lib/ghost-version'); + exporter = require('../../../server/data/exporter'), + ghostVersion = require('../../../server/lib/ghost-version'); describe('Exporter', function () { before(testUtils.teardown); diff --git a/core/test/integration/data/importer/importers/data_spec.js b/core/test/regression/importer/importer_spec.js similarity index 99% rename from core/test/integration/data/importer/importers/data_spec.js rename to core/test/regression/importer/importer_spec.js index f58a331ea5..f2a16a02d3 100644 --- a/core/test/integration/data/importer/importers/data_spec.js +++ b/core/test/regression/importer/importer_spec.js @@ -1,6 +1,6 @@ var should = require('should'), sinon = require('sinon'), - testUtils = require('../../../../utils'), + testUtils = require('../../utils'), Promise = require('bluebird'), moment = require('moment'), ObjectId = require('bson-objectid'), @@ -9,9 +9,9 @@ var should = require('should'), validator = require('validator'), // Stuff we are testing - db = require('../../../../../server/data/db'), - models = require('../../../../../server/models'), - importer = require('../../../../../server/data/importer'), + db = require('../../../server/data/db'), + models = require('../../../server/models'), + importer = require('../../../server/data/importer'), dataImporter = importer.importers[1], importOptions = { returnImportedData: true diff --git a/core/test/integration/migration_spec.js b/core/test/regression/migrations/migration_spec.js similarity index 99% rename from core/test/integration/migration_spec.js rename to core/test/regression/migrations/migration_spec.js index 745e6214d7..f4111776c1 100644 --- a/core/test/integration/migration_spec.js +++ b/core/test/regression/migrations/migration_spec.js @@ -1,9 +1,9 @@ var should = require('should'), sinon = require('sinon'), - testUtils = require('../utils'), + testUtils = require('../../utils'), _ = require('lodash'), Promise = require('bluebird'), - Models = require('../../server/models'); + Models = require('../../../server/models'); describe('Database Migration (special functions)', function () { before(testUtils.teardown); diff --git a/core/test/integration/model/base/listeners_spec.js b/core/test/regression/models/base/listeners_spec.js similarity index 99% rename from core/test/integration/model/base/listeners_spec.js rename to core/test/regression/models/base/listeners_spec.js index a42c9b2d3d..5a2984695d 100644 --- a/core/test/integration/model/base/listeners_spec.js +++ b/core/test/regression/models/base/listeners_spec.js @@ -21,6 +21,7 @@ describe('Models: listeners', function () { }; before(testUtils.teardown); + beforeEach(testUtils.setup('owner', 'user-token:0', 'settings')); beforeEach(function () { @@ -253,7 +254,6 @@ describe('Models: listeners', function () { post1 = posts[0], listenerHasFinished = false; - sinon.spy(common.logging, 'error'); sinon.spy(models.Post, 'findAll'); // simulate a delay, so that the edit operation from the test here interrupts @@ -301,7 +301,6 @@ describe('Models: listeners', function () { interval = setInterval(function () { if (listenerHasFinished) { clearInterval(interval); - common.logging.error.called.should.eql(false); return done(); } }, 1000); diff --git a/core/test/integration/model/model_posts_spec.js b/core/test/regression/models/model_posts_spec.js similarity index 99% rename from core/test/integration/model/model_posts_spec.js rename to core/test/regression/models/model_posts_spec.js index ef29616d0e..0aa9f7645d 100644 --- a/core/test/integration/model/model_posts_spec.js +++ b/core/test/regression/models/model_posts_spec.js @@ -25,6 +25,7 @@ describe('Post Model', function () { var eventsTriggered = {}; before(testUtils.teardown); + before(testUtils.stopGhost); after(testUtils.teardown); before(testUtils.setup('users:roles')); diff --git a/core/test/integration/model/model_settings_spec.js b/core/test/regression/models/model_settings_spec.js similarity index 100% rename from core/test/integration/model/model_settings_spec.js rename to core/test/regression/models/model_settings_spec.js diff --git a/core/test/integration/model/model_users_spec.js b/core/test/regression/models/model_users_spec.js similarity index 100% rename from core/test/integration/model/model_users_spec.js rename to core/test/regression/models/model_users_spec.js diff --git a/core/test/integration/services/url/UrlService_spec.js b/core/test/regression/site/UrlService_spec.js similarity index 98% rename from core/test/integration/services/url/UrlService_spec.js rename to core/test/regression/site/UrlService_spec.js index b63a979d5f..424a8ae6d6 100644 --- a/core/test/integration/services/url/UrlService_spec.js +++ b/core/test/regression/site/UrlService_spec.js @@ -2,12 +2,12 @@ const _ = require('lodash'); const should = require('should'); const sinon = require('sinon'); const rewire = require('rewire'); -const testUtils = require('../../../utils'); -const configUtils = require('../../../utils/configUtils'); -const models = require('../../../../server/models'); -const common = require('../../../../server/lib/common'); -const themes = require('../../../../server/services/themes'); -const UrlService = rewire('../../../../server/services/url/UrlService'); +const testUtils = require('../../utils'); +const configUtils = require('../../utils/configUtils'); +const models = require('../../../server/models'); +const common = require('../../../server/lib/common'); +const themes = require('../../../server/services/themes'); +const UrlService = rewire('../../../server/services/url/UrlService'); describe('Integration: services/url/UrlService', function () { let urlService; diff --git a/core/test/functional/dynamic_routing_spec.js b/core/test/regression/site/dynamic_routing_spec.js similarity index 99% rename from core/test/functional/dynamic_routing_spec.js rename to core/test/regression/site/dynamic_routing_spec.js index ac2437df82..ff9b38afaf 100644 --- a/core/test/functional/dynamic_routing_spec.js +++ b/core/test/regression/site/dynamic_routing_spec.js @@ -7,11 +7,11 @@ const should = require('should'), sinon = require('sinon'), moment = require('moment'), path = require('path'), - testUtils = require('../utils'), + testUtils = require('../../utils'), cheerio = require('cheerio'), - config = require('../../server/config'), - api = require('../../server/api'), - settingsCache = require('../../server/services/settings/cache'), + config = require('../../../server/config'), + api = require('../../../server/api'), + settingsCache = require('../../../server/services/settings/cache'), ghost = testUtils.startGhost; let request; diff --git a/core/test/functional/frontend_spec.js b/core/test/regression/site/frontend_spec.js similarity index 99% rename from core/test/functional/frontend_spec.js rename to core/test/regression/site/frontend_spec.js index b533df5784..8f7720ecef 100644 --- a/core/test/functional/frontend_spec.js +++ b/core/test/regression/site/frontend_spec.js @@ -8,10 +8,10 @@ var should = require('should'), moment = require('moment'), cheerio = require('cheerio'), _ = require('lodash'), - testUtils = require('../utils'), - configUtils = require('../utils/configUtils'), - config = require('../../server/config'), - settingsCache = require('../../server/services/settings/cache'), + testUtils = require('../../utils'), + configUtils = require('../../utils/configUtils'), + config = require('../../../server/config'), + settingsCache = require('../../../server/services/settings/cache'), origCache = _.cloneDeep(settingsCache), ghost = testUtils.startGhost, request; diff --git a/core/test/integration/web/site_spec.js b/core/test/regression/site/site_spec.js similarity index 100% rename from core/test/integration/web/site_spec.js rename to core/test/regression/site/site_spec.js diff --git a/core/test/integration/update_check_spec.js b/core/test/regression/update-check/update_check_spec.js similarity index 98% rename from core/test/integration/update_check_spec.js rename to core/test/regression/update-check/update_check_spec.js index 01431f5649..25094261a2 100644 --- a/core/test/integration/update_check_spec.js +++ b/core/test/regression/update-check/update_check_spec.js @@ -5,18 +5,18 @@ const rewire = require('rewire'); const sinon = require('sinon'); const moment = require('moment'); const uuid = require('uuid'); -const testUtils = require('../utils'); -const configUtils = require('../utils/configUtils'); -const packageInfo = require('../../../package'); -const api = require('../../server/api').v2; +const testUtils = require('../../utils'); +const configUtils = require('../../utils/configUtils'); +const packageInfo = require('../../../../package'); +const api = require('../../../server/api').v2; -let updateCheck = rewire('../../server/update-check'); -let NotificationsAPI = rewire('../../server/api/v2/notifications'); +let updateCheck = rewire('../../../server/update-check'); +let NotificationsAPI = rewire('../../../server/api/v2/notifications'); describe('Update Check', function () { beforeEach(function () { - updateCheck = rewire('../../server/update-check'); - NotificationsAPI = rewire('../../server/api/v2/notifications'); + updateCheck = rewire('../../../server/update-check'); + NotificationsAPI = rewire('../../../server/api/v2/notifications'); }); afterEach(function () { diff --git a/core/test/utils/index.js b/core/test/utils/index.js index f413b3a0f9..119e82d27e 100644 --- a/core/test/utils/index.js +++ b/core/test/utils/index.js @@ -1025,6 +1025,15 @@ startGhost = function startGhost(options) { module.exports = { startGhost: startGhost, + stopGhost: () => { + if (ghostServer && ghostServer.httpServer) { + return ghostServer.stop() + .then(() => { + urlService.resetGenerators(); + }); + } + }, + integrationTesting: { overrideGhostConfig: function overrideGhostConfig(configUtils) { configUtils.set('paths:contentPath', path.join(__dirname, 'fixtures')); diff --git a/package.json b/package.json index 631554b300..30d4e2bf0c 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "start": "node index", "dev": "DEBUG=ghost:* grunt dev", "test": "grunt validate --verbose", + "test:regression": "grunt test-regression --verbose", "setup": "yarn install && knex-migrator init && grunt symlink && grunt init || true", "lint": "grunt lint" },