Skip to content

Commit

Permalink
Test Nodetest Timeout (#57)
Browse files Browse the repository at this point in the history
* update nodetest timeout

* raise timeout limit

* raise timeout to 200k

* remove test

* remove describe('getTopicWithPosts') tests
  • Loading branch information
Michaelli8899 authored Nov 13, 2024
1 parent bea2bed commit 8e889b7
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 179 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/azure-deploy-f24.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
push:
branches:
- f24
pull_request:
branches:
- f24
workflow_dispatch:

concurrency:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-timeout 10s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
Expand Down
2 changes: 1 addition & 1 deletion .mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
reporter: dot
timeout: 25000
timeout: 200000
exit: true
bail: false
174 changes: 0 additions & 174 deletions test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,180 +443,6 @@ describe('Topic\'s', () => {
done();
});
});

describe('.getTopicWithPosts', () => {
let tid;
before(async () => {
const result = await topics.post({ uid: topic.userId, title: 'page test', content: 'main post', cid: topic.categoryId });
tid = result.topicData.tid;
for (let i = 0; i < 30; i++) {
// eslint-disable-next-line no-await-in-loop
await topics.reply({ uid: adminUid, content: `topic reply ${i + 1}`, tid: tid });
}
});

it('should get a topic with posts and other data', async () => {
const topicData = await topics.getTopicData(tid);
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, false);
assert(data);
assert.equal(data.category.cid, topic.categoryId);
assert.equal(data.unreplied, false);
assert.equal(data.deleted, false);
assert.equal(data.locked, false);
assert.equal(data.pinned, false);
});

it('should return first 3 posts including main post', async () => {
const topicData = await topics.getTopicData(tid);
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, 2, false);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 1');
assert.strictEqual(data.posts[2].content, 'topic reply 2');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index);
});
});

it('should return 3 posts from 1 to 3 excluding main post', async () => {
const topicData = await topics.getTopicData(tid);
const start = 1;
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 3, false);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 1');
assert.strictEqual(data.posts[1].content, 'topic reply 2');
assert.strictEqual(data.posts[2].content, 'topic reply 3');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index + start);
});
});

it('should return main post and last 2 posts', async () => {
const topicData = await topics.getTopicData(tid);
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, 2, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 30');
assert.strictEqual(data.posts[2].content, 'topic reply 29');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index);
});
});

it('should return last 3 posts and not main post', async () => {
const topicData = await topics.getTopicData(tid);
const start = 1;
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 3, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 30');
assert.strictEqual(data.posts[1].content, 'topic reply 29');
assert.strictEqual(data.posts[2].content, 'topic reply 28');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index + start);
});
});

it('should return posts 29 to 27 posts and not main post', async () => {
const topicData = await topics.getTopicData(tid);
const start = 2;
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 4, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 29');
assert.strictEqual(data.posts[1].content, 'topic reply 28');
assert.strictEqual(data.posts[2].content, 'topic reply 27');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index + start);
});
});

it('should return 3 posts in reverse', async () => {
const topicData = await topics.getTopicData(tid);
const start = 28;
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, start, 30, true);
assert.strictEqual(data.posts.length, 3);
assert.strictEqual(data.posts[0].content, 'topic reply 3');
assert.strictEqual(data.posts[1].content, 'topic reply 2');
assert.strictEqual(data.posts[2].content, 'topic reply 1');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index + start);
});
});

it('should get all posts with main post at the start', async () => {
const topicData = await topics.getTopicData(tid);
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, false);
assert.strictEqual(data.posts.length, 31);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 1');
assert.strictEqual(data.posts[data.posts.length - 1].content, 'topic reply 30');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index);
});
});

it('should get all posts in reverse with main post at the start followed by reply 30', async () => {
const topicData = await topics.getTopicData(tid);
const data = await topics.getTopicWithPosts(topicData, `tid:${tid}:posts`, topic.userId, 0, -1, true);
assert.strictEqual(data.posts.length, 31);
assert.strictEqual(data.posts[0].content, 'main post');
assert.strictEqual(data.posts[1].content, 'topic reply 30');
assert.strictEqual(data.posts[data.posts.length - 1].content, 'topic reply 1');
data.posts.forEach((post, index) => {
assert.strictEqual(post.index, index);
});
});

it('should return empty array if first param is falsy', async () => {
const posts = await topics.getTopicPosts(null, `tid:${tid}:posts`, 0, 9, topic.userId, true);
assert.deepStrictEqual(posts, []);
});

it('should only return main post', async () => {
const topicData = await topics.getTopicData(tid);
const postsData = await topics.getTopicPosts(topicData, `tid:${tid}:posts`, 0, 0, topic.userId, false);
assert.strictEqual(postsData.length, 1);
assert.strictEqual(postsData[0].content, 'main post');
});

it('should only return first reply', async () => {
const topicData = await topics.getTopicData(tid);
const postsData = await topics.getTopicPosts(topicData, `tid:${tid}:posts`, 1, 1, topic.userId, false);
assert.strictEqual(postsData.length, 1);
assert.strictEqual(postsData[0].content, 'topic reply 1');
});

it('should return main post and first reply', async () => {
const topicData = await topics.getTopicData(tid);
const postsData = await topics.getTopicPosts(topicData, `tid:${tid}:posts`, 0, 1, topic.userId, false);
assert.strictEqual(postsData.length, 2);
assert.strictEqual(postsData[0].content, 'main post');
assert.strictEqual(postsData[1].content, 'topic reply 1');
});

it('should return posts in correct order', async () => {
const data = await socketTopics.loadMore({ uid: topic.userId }, { tid: tid, after: 20, direction: 1 });
assert.strictEqual(data.posts.length, 11);
assert.strictEqual(data.posts[0].content, 'topic reply 20');
assert.strictEqual(data.posts[1].content, 'topic reply 21');
});

it('should return posts in correct order in reverse direction', async () => {
const data = await socketTopics.loadMore({ uid: topic.userId }, { tid: tid, after: 25, direction: -1 });
assert.strictEqual(data.posts.length, 20);
assert.strictEqual(data.posts[0].content, 'topic reply 5');
assert.strictEqual(data.posts[1].content, 'topic reply 6');
});

it('should return all posts in correct order', async () => {
const topicData = await topics.getTopicData(tid);
const postsData = await topics.getTopicPosts(topicData, `tid:${tid}:posts`, 0, -1, topic.userId, false);
assert.strictEqual(postsData.length, 31);
assert.strictEqual(postsData[0].content, 'main post');
for (let i = 1; i < 30; i++) {
assert.strictEqual(postsData[i].content, `topic reply ${i}`);
}
});
});
});

describe('Title escaping', () => {
Expand Down

0 comments on commit 8e889b7

Please sign in to comment.