Show group replies icon for stories with replies

This commit is contained in:
Josh Perez 2022-10-22 02:26:16 -04:00 committed by GitHub
parent ba55285c74
commit 471a9e2e98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 170 additions and 136 deletions

View file

@ -9,7 +9,7 @@ import type { UUIDStringType } from '../../types/UUID';
import type { MessageAttributesType } from '../../model-types.d';
const { removeAll, _getAllMessages, saveMessages, getOlderStories } =
const { removeAll, _getAllMessages, saveMessages, getAllStories } =
dataInterface;
function getUuid(): UUIDStringType {
@ -21,7 +21,7 @@ describe('sql/stories', () => {
await removeAll();
});
describe('getOlderStories', () => {
describe('getAllStories', () => {
it('returns N most recent stories overall, or in converation, or by author', async () => {
assert.lengthOf(await _getAllMessages(), 0);
@ -88,9 +88,7 @@ describe('sql/stories', () => {
assert.lengthOf(await _getAllMessages(), 5);
const stories = await getOlderStories({
limit: 5,
});
const stories = await getAllStories({});
assert.lengthOf(stories, 4, 'expect four total stories');
// They are in ASC order
@ -105,9 +103,8 @@ describe('sql/stories', () => {
'stories last should be story1'
);
const storiesInConversation = await getOlderStories({
const storiesInConversation = await getAllStories({
conversationId,
limit: 5,
});
assert.lengthOf(
storiesInConversation,
@ -127,9 +124,8 @@ describe('sql/stories', () => {
'storiesInConversation last should be story1'
);
const storiesByAuthor = await getOlderStories({
const storiesByAuthor = await getAllStories({
sourceUuid,
limit: 5,
});
assert.lengthOf(storiesByAuthor, 2, 'expect two stories by author');
@ -145,85 +141,5 @@ describe('sql/stories', () => {
'storiesByAuthor last should be story2'
);
});
it('returns N stories older than provided receivedAt/sentAt', async () => {
assert.lengthOf(await _getAllMessages(), 0);
const start = Date.now();
const conversationId = getUuid();
const ourUuid = getUuid();
const story1: MessageAttributesType = {
id: getUuid(),
body: 'message 1',
type: 'incoming',
conversationId,
sent_at: start - 2,
received_at: start - 2,
timestamp: start - 2,
};
const story2: MessageAttributesType = {
id: getUuid(),
body: 'story 2',
type: 'story',
conversationId,
sent_at: start - 1,
received_at: start - 1,
timestamp: start - 1,
};
const story3: MessageAttributesType = {
id: getUuid(),
body: 'story 3',
type: 'story',
conversationId,
sent_at: start - 1,
received_at: start,
timestamp: start,
};
const story4: MessageAttributesType = {
id: getUuid(),
body: 'story 4',
type: 'story',
conversationId,
sent_at: start,
received_at: start,
timestamp: start,
};
const story5: MessageAttributesType = {
id: getUuid(),
body: 'story 5',
type: 'story',
conversationId,
sent_at: start + 1,
received_at: start + 1,
timestamp: start + 1,
};
await saveMessages([story1, story2, story3, story4, story5], {
forceSave: true,
ourUuid,
});
assert.lengthOf(await _getAllMessages(), 5);
const stories = await getOlderStories({
receivedAt: story4.received_at,
sentAt: story4.sent_at,
limit: 5,
});
assert.lengthOf(stories, 2, 'expect two stories');
// They are in ASC order
assert.strictEqual(
stories[0].id,
story2.id,
'stories first should be story3'
);
assert.strictEqual(
stories[1].id,
story3.id,
'stories last should be story2'
);
});
});
});