Skip to content

Commit f142986

Browse files
authored
Removed duplicate automations endpoint tests (TryGhost#27777)
towards https://linear.app/ghost/issue/NY-1265 _This is a test-only change._ We decided that these tests are mostly redundant with the E2E tests. Let's remove them.
1 parent e1cd50f commit f142986

1 file changed

Lines changed: 1 addition & 87 deletions

File tree

ghost/core/test/unit/api/endpoints/automations.test.js

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,22 @@
11
const assert = require('node:assert/strict');
22
const sinon = require('sinon');
33
const domainEvents = require('@tryghost/domain-events');
4-
const models = require('../../../../core/server/models');
54
const automationsController = require('../../../../core/server/api/endpoints/automations');
65
const StartAutomationsPollEvent = require('../../../../core/server/services/automations/events/start-automations-poll-event');
76

87
describe('Automations controller', function () {
9-
before(function () {
10-
models.init();
11-
});
12-
13-
function createMockAutomation(id, name, slug, status) {
14-
return {
15-
get(key) {
16-
switch (key) {
17-
case 'id':
18-
return id;
19-
case 'name':
20-
return name;
21-
case 'slug':
22-
return slug;
23-
case 'status':
24-
return status;
25-
default:
26-
throw new Error(`Unexpected field: ${key}`);
27-
}
28-
}
29-
};
30-
}
8+
// Other endpoints are tested in E2E tests.
319

3210
let dispatchStub;
3311

3412
beforeEach(function () {
35-
sinon.stub(models.WelcomeEmailAutomation, 'findAll').resolves([
36-
createMockAutomation('automation-id-1', 'Welcome Email (Free)', 'member-welcome-email-free', 'active'),
37-
createMockAutomation('automation-id-2', 'Welcome Email (Premium)', 'member-welcome-email-premium', 'inactive')
38-
]);
39-
4013
dispatchStub = sinon.stub(domainEvents, 'dispatch');
4114
});
4215

4316
afterEach(function () {
4417
sinon.restore();
4518
});
4619

47-
describe('browse', function () {
48-
it('returns only id, name, slug, and status fields', async function () {
49-
const result = await automationsController.browse.query({});
50-
51-
assert.deepEqual(result.data, [{
52-
id: 'automation-id-1',
53-
name: 'Welcome Email (Free)',
54-
slug: 'member-welcome-email-free',
55-
status: 'active'
56-
}, {
57-
id: 'automation-id-2',
58-
name: 'Welcome Email (Premium)',
59-
slug: 'member-welcome-email-premium',
60-
status: 'inactive'
61-
}]);
62-
});
63-
});
64-
65-
describe('read', function () {
66-
it('returns a placeholder automation for the requested id', function () {
67-
const result = automationsController.read.query({
68-
data: {
69-
id: '67f3f3f3f3f3f3f3f3f3f3f3'
70-
}
71-
});
72-
73-
assert.deepEqual(result, {
74-
id: '67f3f3f3f3f3f3f3f3f3f3f3',
75-
slug: 'member-welcome-email-free',
76-
name: 'Welcome email',
77-
status: 'active',
78-
created_at: '2026-05-05T00:00:00.000Z',
79-
updated_at: '2026-05-05T00:00:00.000Z',
80-
actions: [{
81-
id: '67f3f3f3f3f3f3f3f3f3f3f4',
82-
type: 'delay',
83-
data: {
84-
delay_hours: 24
85-
}
86-
}, {
87-
id: '67f3f3f3f3f3f3f3f3f3f3f5',
88-
type: 'send email',
89-
data: {
90-
email_subject: 'Welcome!',
91-
email_lexical: '{"root":{"children":[]}}',
92-
email_sender_name: null,
93-
email_sender_email: null,
94-
email_sender_reply_to: null,
95-
email_design_setting_id: '680000000000000000000001'
96-
}
97-
}],
98-
edges: [{
99-
source_action_id: '67f3f3f3f3f3f3f3f3f3f3f4',
100-
target_action_id: '67f3f3f3f3f3f3f3f3f3f3f5'
101-
}]
102-
});
103-
});
104-
});
105-
10620
describe('poll', function () {
10721
it('dispatches a StartAutomationsPollEvent', function () {
10822
const result = automationsController.poll.query({});

0 commit comments

Comments
 (0)