mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 13:22:39 +03:00
c7ef22d4df
fixes https://github.com/TryGhost/Team/issues/2174 The feedback links now use a hash instead of a querystring, so it won't pass by the server. New format: https://site.ghost/post-slug/#/feedback/6359174f2eb251019d14d6fb/0?uuid=13924399-c3ae-413b-a045-0b8294d71f64
46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
const assert = require('assert');
|
|
const {AudienceFeedbackService} = require('../index');
|
|
|
|
describe('audienceFeedbackService', function () {
|
|
it('exported', function () {
|
|
assert.equal(require('../index').AudienceFeedbackService, AudienceFeedbackService);
|
|
});
|
|
|
|
const mockData = {
|
|
uuid: '7b11de3c-dff9-4563-82ae-a281122d201d',
|
|
postId: '634fc3901e0a291855d8b135',
|
|
postTitle: 'somepost',
|
|
score: 1
|
|
};
|
|
|
|
describe('build link', function () {
|
|
it('Can build link to post', async function () {
|
|
const instance = new AudienceFeedbackService({
|
|
urlService: {
|
|
getUrlByResourceId: () => `https://localhost:2368/${mockData.postTitle}/`
|
|
},
|
|
config: {
|
|
baseURL: new URL('https://localhost:2368')
|
|
}
|
|
});
|
|
const link = instance.buildLink(mockData.uuid, mockData.postId, mockData.score);
|
|
const expectedLink = `https://localhost:2368/${mockData.postTitle}/#/feedback/${mockData.postId}/${mockData.score}/?uuid=${mockData.uuid}`;
|
|
assert.equal(link.href, expectedLink);
|
|
});
|
|
|
|
it('Can build link to home page if post wasn\'t published', async function () {
|
|
const instance = new AudienceFeedbackService({
|
|
urlService: {
|
|
getUrlByResourceId: () => `https://localhost:2368/${mockData.postTitle}/404/`
|
|
},
|
|
config: {
|
|
baseURL: new URL('https://localhost:2368')
|
|
}
|
|
});
|
|
const link = instance.buildLink(mockData.uuid, mockData.postId, mockData.score);
|
|
const expectedLink = `https://localhost:2368/#/feedback/${mockData.postId}/${mockData.score}/?uuid=${mockData.uuid}`;
|
|
assert.equal(link.href, expectedLink);
|
|
});
|
|
});
|
|
});
|