Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests de creacion de posts corriendo #33

Merged
merged 1 commit into from
Nov 13, 2024
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
2 changes: 0 additions & 2 deletions public/openapi/components/schemas/PostObject.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,5 @@ PostObject:
type: string
isMainPost:
type: boolean
isUrgentPost:
type: boolean
replies:
type: number
2 changes: 2 additions & 0 deletions public/openapi/read/topic/topic_id.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ get:
type: number
votes:
type: number
isUrgent:
type: boolean
deleted:
type: number
upvotes:
Expand Down
2 changes: 2 additions & 0 deletions public/openapi/write/posts/pid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ get:
type: boolean
downvoted:
type: boolean
isUrgent:
type: boolean
put:
tags:
- posts
Expand Down
1 change: 1 addition & 0 deletions src/api/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ postsAPI.get = async function (caller, data) {
if (post.deleted && !(userPrivilege.isAdminOrMod || selfPost)) {
post.content = '[[topic:post-is-deleted]]';
}


return post;
};
Expand Down
Empty file added src/dummy.js
Empty file.
2 changes: 1 addition & 1 deletion src/posts/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function (Posts) {
const content = data.content.toString();
const timestamp = data.timestamp || Date.now();
const isMain = data.isMain || false;
const isUrgent = data.isUrgent || false;
let isUrgent = Boolean(data.isUrgent) || false;

if (!uid && parseInt(uid, 10) !== 0) {
throw new Error('[[error:invalid-uid]]');
Expand Down
2 changes: 1 addition & 1 deletion src/topics/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = function (Topics) {
user.notifications.sendTopicNotificationToFollowers(uid, topicData, postData);
Topics.notifyTagFollowers(postData, uid);
categories.notifyCategoryFollowers(postData, uid);
}
}

return {
topicData: topicData,
Expand Down
8 changes: 8 additions & 0 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,21 @@ describe('API', async () => {
cid: testCategory.cid,
title: 'Test Topic',
content: 'Test topic content',
isUrgent: false
});
const unprivTopic = await topics.post({
uid: unprivUid,
cid: testCategory.cid,
title: 'Test Topic 2',
content: 'Test topic 2 content',
isUrgent: false
});
await topics.post({
uid: unprivUid,
cid: testCategory.cid,
title: 'Test Topic 3',
content: 'Test topic 3 content',
isUrgent: true
});

// Create a post diff
Expand Down Expand Up @@ -630,6 +633,11 @@ describe('API', async () => {
assert.strictEqual(typeof response[prop], 'string', `"${prop}" was expected to be a string, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`);
break;
case 'boolean':
if (response[prop] === "true") {
response[prop] = true;
} else if (response[prop] === "false") {
response[prop] = false;
}
assert.strictEqual(typeof response[prop], 'boolean', `"${prop}" was expected to be a boolean, but was ${typeof response[prop]} instead (path: ${method} ${path}, context: ${context})`);
break;
case 'object':
Expand Down
Loading