Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import RoleSelector from './role-selector';
import StaffToken from './staff-token';
import {SettingGroup, SettingGroupContent, TextArea, TextField} from '@tryghost/admin-x-design-system';
import {type UserDetailProps} from '../user-detail-modal';
import {getHomepageUrl} from '@tryghost/admin-x-framework/api/site';
import {hasAdminAccess} from '@tryghost/admin-x-framework/api/users';
import {useGlobalData} from '../../../providers/global-data-provider';

const BasicInputs: React.FC<UserDetailProps> = ({errors, clearError, user, setUserData}) => {
const {currentUser} = useGlobalData();
const {currentUser, siteData} = useGlobalData();
const homepageUrl = getHomepageUrl(siteData!);

return (
<SettingGroupContent>
Expand Down Expand Up @@ -36,7 +38,7 @@ const BasicInputs: React.FC<UserDetailProps> = ({errors, clearError, user, setUs
onKeyDown={() => clearError('name')}
/>
<TextField
hint={`https://example.com/author/${user.slug}`}
hint={`${homepageUrl}author/${user.slug}`}
maxLength={191}
title="Slug"
value={user.slug}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ test.describe('User profile', async () => {
await modal.getByLabel('Full name').fill('New Admin');
await modal.getByLabel('Email').fill('newadmin@test.com');
await modal.getByLabel('Slug').fill('newadmin');
await expect(modal.getByText('https://example.com/author/newadmin')).toBeVisible();
await expect(modal.getByText('http://test.com/author/newadmin')).toBeVisible();
await modal.getByLabel('Location').fill('some location');
await modal.getByLabel('Bio').fill('some bio');

Expand Down
2 changes: 1 addition & 1 deletion ghost/admin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghost-admin",
"version": "6.19.0",
"version": "6.19.1",
"description": "Ember.js admin client for Ghost",
"author": "Ghost Foundation",
"homepage": "http://ghost.org",
Expand Down
8 changes: 4 additions & 4 deletions ghost/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghost",
"version": "6.19.0",
"version": "6.19.1",
"description": "The professional publishing platform",
"author": "Ghost Foundation",
"homepage": "https://ghost.org",
Expand Down Expand Up @@ -330,19 +330,19 @@
"test:browser": {
"dependsOn": [
"build:assets",
"ghost-admin:build"
"@tryghost/admin:build"
]
},
"test:browser:admin": {
"dependsOn": [
"build:assets",
"ghost-admin:build"
"@tryghost/admin:build"
]
},
"test:browser:portal": {
"dependsOn": [
"build:assets",
"ghost-admin:build"
"@tryghost/admin:build"
]
}
}
Expand Down
13 changes: 6 additions & 7 deletions ghost/core/test/e2e-api/admin/members-exporter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {agentProvider, mockManager, fixtureManager, matchers} = require('../../ut
const {anyContentVersion, anyString} = matchers;

const crypto = require('crypto');
const should = require('should');
const Papa = require('papaparse');
const models = require('../../../core/server/models');
const moment = require('moment');
Expand All @@ -25,12 +24,12 @@ let tiers, labels, newsletters;

function basicAsserts(member, row) {
// Basic checks
should(row.email).eql(member.get('email'));
should(row.name).eql(member.get('name'));
should(row.note).eql(member.get('note') || '');
assert.equal(row.email, member.get('email'));
assert.equal(row.name, member.get('name'));
assert.equal(row.note, member.get('note') || '');

assert.equal(row.deleted_at, '');
should(row.created_at).eql(moment(member.get('created_at')).toISOString());
assert.equal(row.created_at, moment(member.get('created_at')).toISOString());
}

/**
Expand Down Expand Up @@ -120,7 +119,7 @@ describe('Members API — exportCSV', function () {
basicAsserts(member, row);
assert.equal(row.subscribed_to_emails, 'false');
assert.equal(row.complimentary_plan, '');
should(row.tiers.split(',').sort().join(',')).eql(tiersList);
assert.equal(row.tiers.split(',').sort().join(','), tiersList);
}, [`filter=tier:[${tiers[0].get('slug')}]`, 'filter=subscribed:false']);
});

Expand Down Expand Up @@ -157,7 +156,7 @@ describe('Members API — exportCSV', function () {
basicAsserts(member, row);
assert.equal(row.subscribed_to_emails, 'false');
assert.equal(row.complimentary_plan, '');
should(row.labels.split(',').sort().join(',')).eql(labelsList);
assert.equal(row.labels.split(',').sort().join(','), labelsList);
assert.equal(row.tiers, '');
}, [`filter=label:${labels[0].get('slug')}`, 'filter=subscribed:false']);
});
Expand Down
6 changes: 3 additions & 3 deletions ghost/core/test/e2e-api/admin/members-importer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('Members Importer API', function () {
// .expect('Content-Type', /json/)
// .expect('Cache-Control', testUtils.cacheRules.private)
// .then((res) => {
// should.not.exist(res.headers['x-cache-invalidate']);
// assert(!res.headers['x-cache-invalidate']);

// const jsonResponse = res.body;

Expand All @@ -130,7 +130,7 @@ describe('Members Importer API', function () {
// .expect('Cache-Control', testUtils.cacheRules.private)
// .expect(200)
// .then((res) => {
// should.not.exist(res.headers['x-cache-invalidate']);
// assert(!res.headers['x-cache-invalidate']);
// const jsonResponse = res.body;
// assertExists(jsonResponse);
// assertExists(jsonResponse.members);
Expand All @@ -147,7 +147,7 @@ describe('Members Importer API', function () {
// .expect('Cache-Control', testUtils.cacheRules.private)
// .expect(200)
// .then((res) => {
// should.not.exist(res.headers['x-cache-invalidate']);
// assert(!res.headers['x-cache-invalidate']);
// const jsonResponse = res.body;
// assertExists(jsonResponse);
// assertExists(jsonResponse.meta);
Expand Down
6 changes: 3 additions & 3 deletions ghost/core/test/e2e-api/admin/members.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {queryStringToken} = regexes;
const ObjectId = require('bson-objectid').default;

const assert = require('node:assert/strict');
const {assertExists, assertObjectMatches} = require('../../utils/assertions');
const {assertExists, assertArrayContainsDeep, assertObjectMatches} = require('../../utils/assertions');
const nock = require('nock');
const sinon = require('sinon');
const should = require('should');
Expand Down Expand Up @@ -480,7 +480,7 @@ describe('Members API - member attribution', function () {
})
.expect(({body}) => {
assert.equal(body.events.find(e => e.type !== 'signup_event'), undefined);
should(body.events.map(e => e.data.attribution)).containDeep(signupAttributions);
assertArrayContainsDeep(body.events.map(e => e.data.attribution), signupAttributions);
});
});
});
Expand Down Expand Up @@ -1860,7 +1860,7 @@ describe('Members API', function () {
// Check that the product that we are going to add is not the same as the existing one
const product = await getOtherPaidProduct();
assert.equal(memberWithPaidSubscription.tiers.length, 1);
should(memberWithPaidSubscription.tiers[0].id).not.eql(product.id);
assert.notEqual(memberWithPaidSubscription.tiers[0].id, product.id);

// Add it manually
await models.Member.edit({
Expand Down
9 changes: 4 additions & 5 deletions ghost/core/test/e2e-api/admin/offers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const assert = require('node:assert/strict');
const {assertObjectMatches} = require('../../utils/assertions');
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyContentVersion, anyEtag, anyObjectId, anyLocationFor, anyErrorId, anyISODateTime} = matchers;
const should = require('should');
const models = require('../../../core/server/models');
const sinon = require('sinon');
const logging = require('@tryghost/logging');
Expand Down Expand Up @@ -297,8 +296,8 @@ describe('Offers API', function () {
}]
})
.expect(({body}) => {
body.offers[0].redemption_type.should.eql('retention');
should(body.offers[0].tier).be.null();
assert.equal(body.offers[0].redemption_type, 'retention');
assert.equal(body.offers[0].tier, null);
});
});

Expand Down Expand Up @@ -646,7 +645,7 @@ describe('Offers API', function () {
})
})
.expect(({body}) => {
body.offers[0].should.match(updatedOffer);
assertObjectMatches(body.offers[0], updatedOffer);
});
});

Expand Down Expand Up @@ -809,7 +808,7 @@ describe('Offers API', function () {
})
})
.expect(({body}) => {
body.offers[0].tier.id.should.eql(defaultTier.id);
assert.equal(body.offers[0].tier.id, defaultTier.id);
});
});
});
10 changes: 4 additions & 6 deletions ghost/core/test/e2e-api/admin/themes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ describe('Themes API', function () {
tmpFolderContents.splice(i, 1);
}
}
tmpFolderContents.should.be.an.Array().with.lengthOf(12);

assert.deepEqual(tmpFolderContents, [
'broken-theme',
'casper',
Expand Down Expand Up @@ -234,7 +232,7 @@ describe('Themes API', function () {
localUtils.API.checkResponse(jsonResponse.themes[0], 'theme', ['warnings']);
assert.equal(jsonResponse.themes[0].name, 'warnings');
assert.equal(jsonResponse.themes[0].active, false);
jsonResponse.themes[0].warnings.should.be.an.Array();
assert(Array.isArray(jsonResponse.themes[0].warnings));

// Delete the theme to clean up after the test
await ownerRequest
Expand Down Expand Up @@ -285,7 +283,7 @@ describe('Themes API', function () {
assertExists(testTheme2);
localUtils.API.checkResponse(testTheme2, 'theme', ['warnings', 'templates']);
assert.equal(testTheme2.active, true);
testTheme2.warnings.should.be.an.Array();
assert(Array.isArray(testTheme2.warnings));

// Result should be the same
const activeThemeResult = await ownerRequest
Expand Down Expand Up @@ -323,7 +321,7 @@ describe('Themes API', function () {
localUtils.API.checkResponse(jsonResponse.themes[0], 'theme', ['warnings']);
assert.equal(jsonResponse.themes[0].name, 'test');
assert.equal(jsonResponse.themes[0].active, false);
jsonResponse.themes[0].warnings.should.be.an.Array();
assert(Array.isArray(jsonResponse.themes[0].warnings));

// Delete the theme to clean up after the test
await ownerRequest
Expand Down Expand Up @@ -366,7 +364,7 @@ describe('Themes API', function () {
localUtils.API.checkResponse(jsonResponse.themes[0], 'theme', ['warnings']);
assert.equal(jsonResponse.themes[0].name, 'starter');
assert.equal(jsonResponse.themes[0].active, false);
jsonResponse.themes[0].warnings.should.be.an.Array();
assert(Array.isArray(jsonResponse.themes[0].warnings));

// Delete the theme to clean up after the test
await ownerRequest
Expand Down
4 changes: 2 additions & 2 deletions ghost/core/test/e2e-api/content/tags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ describe('Tags Content API', function () {

const jsonResponse = res.body;

assertExists(jsonResponse.tags);
jsonResponse.tags.should.be.an.Array().with.lengthOf(5);
assert(Array.isArray(jsonResponse.tags));
assert.equal(jsonResponse.tags.length, 5);

// Each tag should have the correct count
assert.equal(_.find(jsonResponse.tags, {name: 'Getting Started'}).count.posts, 7);
Expand Down
24 changes: 12 additions & 12 deletions ghost/core/test/e2e-api/members-comments/comments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ async function testCanCommentOnPost(member) {

// Check last_updated_at changed?
member = await models.Member.findOne({id: member.id});
should.notEqual(member.get('last_seen_at'), null, 'The member should have a `last_seen_at` property after posting a comment.');
assert.notEqual(member.get('last_seen_at'), null, 'The member should have a `last_seen_at` property after posting a comment.');

// Check last_commented_at changed?
should.notEqual(member.get('last_commented_at'), null, 'The member should have a `last_commented_at` property after posting a comment.');
assert.notEqual(member.get('last_commented_at'), null, 'The member should have a `last_commented_at` property after posting a comment.');
}

async function testCanReply(member, emailMatchers = {}) {
Expand Down Expand Up @@ -294,10 +294,10 @@ async function testCanReply(member, emailMatchers = {}) {

// Check last_updated_at changed?
member = await models.Member.findOne({id: member.id});
should.notEqual(member.get('last_seen_at').getTime(), date.getTime(), 'Should update `last_seen_at` property after posting a comment.');
assert.notEqual(member.get('last_seen_at').getTime(), date.getTime(), 'Should update `last_seen_at` property after posting a comment.');

// Check last_commented_at changed?
should.notEqual(member.get('last_commented_at').getTime(), date.getTime(), 'Should update `last_commented_at` property after posting a comment.');
assert.notEqual(member.get('last_commented_at').getTime(), date.getTime(), 'Should update `last_commented_at` property after posting a comment.');
}

async function testCannotCommentOnPost(status = 403) {
Expand Down Expand Up @@ -435,7 +435,7 @@ describe('Comments API', function () {

// go through all comments and check if the deleted comment is not there
data2.body.comments.forEach((comment) => {
should(comment.html).not.eql('This is a deleted comment');
assert.notEqual(comment.html, 'This is a deleted comment');
});

assert.equal(data2.body.comments.length, 0);
Expand Down Expand Up @@ -477,8 +477,8 @@ describe('Comments API', function () {

// check if hidden and deleted comments have their html removed
data2.body.comments.forEach((comment) => {
should.notEqual(comment.html, 'This is a hidden comment');
should.notEqual(comment.html, 'This is a deleted comment');
assert.notEqual(comment.html, 'This is a hidden comment');
assert.notEqual(comment.html, 'This is a deleted comment');
});

// check if hiddenComment.id and deletedComment.id are in the response
Expand Down Expand Up @@ -845,7 +845,7 @@ describe('Comments API', function () {
// get the LAST comment from data2
let lastComment = data2.body.comments[data2.body.comments.length - 1];

should(lastComment.id).eql(oldestComment.id);
assert.equal(lastComment.id, oldestComment.id);
});

it('Can reply to your own comment', async function () {
Expand Down Expand Up @@ -1107,7 +1107,7 @@ describe('Comments API', function () {
assert.equal(body.meta.pagination.next, null);

// Check liked + likes working for replies too
should(body.comments[2].id).eql(replies[2].get('id'));
assert.equal(body.comments[2].id, replies[2].get('id'));
assert.equal(body.comments[2].count.likes, 1);
assert.equal(body.comments[2].liked, true);
});
Expand Down Expand Up @@ -1170,7 +1170,7 @@ describe('Comments API', function () {
assert.equal(reports.models.length, 1);

const report = reports.models[0];
report.get('member_id').should.eql(loggedInMember.id);
assert.equal(report.get('member_id'), loggedInMember.id);

mockManager.assert.sentEmail({
subject: '🚩 A comment has been reported on your post',
Expand All @@ -1196,7 +1196,7 @@ describe('Comments API', function () {
assert.equal(reports.models.length, 1);

const report = reports.models[0];
report.get('member_id').should.eql(loggedInMember.id);
assert.equal(report.get('member_id'), loggedInMember.id);

emailMockReceiver.assertSentEmailCount(0);
});
Expand Down Expand Up @@ -1481,7 +1481,7 @@ describe('Comments API', function () {
});

// in_reply_to is set
newComment.in_reply_to_id.should.eql(reply.get('id'));
assert.equal(newComment.in_reply_to_id, reply.get('id'));
assert.equal(newComment.in_reply_to_snippet, 'This is a reply');

// replied-to comment author is notified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ describe('Create Stripe Checkout Session', function () {
.reply((uri, body) => {
if (uri === '/v1/checkout/sessions') {
const parsed = new URLSearchParams(body);
should(parsed.get('metadata[attribution_url]')).eql(url);
assert.equal(parsed.get('metadata[attribution_url]'), url);
assert.equal(parsed.get('metadata[attribution_type]'), 'post');
should(parsed.get('metadata[attribution_id]')).eql(post.id);
assert.equal(parsed.get('metadata[attribution_id]'), post.id);

return [200, {id: 'cs_123', url: 'https://site.com'}];
}
Expand Down
Loading
Loading