From ca4c8cf46db28efb17758476e8c3372d1e8160c7 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Thu, 10 Mar 2022 12:04:44 -0800 Subject: [PATCH 1/5] msglist tests [nfc]: Use Redux state in inputs, not background data See https://github.com/zulip/zulip-mobile/pull/5225#discussion_r803329533 --- .../generateInboundEventEditSequence-test.js | 144 +++++++++++------- 1 file changed, 87 insertions(+), 57 deletions(-) diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index 87c08aa50cf..c6710243b2a 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -14,11 +14,21 @@ import { keyFromNarrow, ALL_PRIVATE_NARROW, } from '../../utils/narrow'; -import type { Message, Outbox, FlagsState } from '../../types'; +import type { + PerAccountState, + GlobalSettingsState, + Debug, + Narrow, + Message, + Outbox, + FlagsState, +} from '../../types'; import type { ReadWrite } from '../../generics'; import { getEditSequence } from '../generateInboundEventEditSequence'; import { applyEditSequence } from '../js/handleInboundEvents'; import getMessageListElements from '../../message/getMessageListElements'; +import { getGlobalSettings, getDebug } from '../../selectors'; +import { getBackgroundData } from '../backgroundData'; // Tell ESLint to recognize `check` as a helper function that runs // assertions. @@ -184,10 +194,9 @@ const pmMessages6 = [ }), ]; -const plusBackgroundData = { - ...eg.plusBackgroundData, - streams: new Map([stream1, stream2].map(s => [s.stream_id, s])), -}; +const baseState = eg.reduxStatePlus({ + streams: [stream1, stream2], +}); /** * Highlight changes in content-HTML generation. @@ -224,7 +233,19 @@ const plusBackgroundData = { * and `messageListElementHtml`. */ describe('messages -> piece descriptors -> content HTML is stable/sensible', () => { - const check = ({ backgroundData = plusBackgroundData, narrow, messages }) => { + const check = ({ + state = eg.plusReduxState, + globalSettings = getGlobalSettings(eg.plusReduxState), + debug = getDebug(eg.plusReduxState), + narrow, + messages, + }: {| + state?: PerAccountState, + globalSettings?: GlobalSettingsState, + debug?: Debug, + narrow: Narrow, + messages: $ReadOnlyArray, + |}) => { invariant( messages.every((message, i, allMessages) => { const prevMessage: Message | void = allMessages[i - 1]; @@ -245,8 +266,16 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () // Simulate applying an edit-sequence event to the DOM. applyEditSequence( getEditSequence( - { backgroundData, elements: [], _: mock_ }, - { backgroundData, elements: getMessageListElements(messages, narrow), _: mock_ }, + { + backgroundData: getBackgroundData(state, globalSettings, debug), + elements: [], + _: mock_, + }, + { + backgroundData: getBackgroundData(state, globalSettings, debug), + elements: getMessageListElements(messages, narrow), + _: mock_, + }, ), ); @@ -417,15 +446,10 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () check({ narrow: HOME_NARROW, - backgroundData: { - ...eg.plusBackgroundData, - ownUser: stableSelfUser, - allUsersById: new Map([ - [singleMessageSender.user_id, singleMessageSender], - [stableSelfUser.user_id, stableSelfUser], - [stableOtherUser.user_id, stableOtherUser], - ]), - }, + state: eg.reduxStatePlus({ + realm: { ...eg.plusReduxState.realm, user_id: stableSelfUser.user_id }, + users: [singleMessageSender, stableSelfUser, stableOtherUser], + }), messages: [ { ...baseSingleMessage, @@ -486,14 +510,14 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () }); }); - Object.keys(eg.baseReduxState.flags).forEach(flag => { + Object.keys(eg.plusReduxState.flags).forEach(flag => { test(`message with flag: ${flag}`, () => { const flags: ReadWrite = { ...eg.plusBackgroundData.flags }; flags[flag] = { [baseSingleMessage.id]: true }; check({ narrow: HOME_NARROW, messages: [baseSingleMessage], - backgroundData: { ...eg.plusBackgroundData, flags }, + state: eg.reduxStatePlus({ flags }), }); }); }); @@ -502,10 +526,9 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () check({ narrow: HOME_NARROW, messages: [baseSingleMessage], - backgroundData: { - ...eg.plusBackgroundData, + state: eg.reduxStatePlus({ mutedUsers: Immutable.Map([[baseSingleMessage.sender_id, 1644366787]]), - }, + }), }); }); @@ -519,15 +542,14 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () check({ narrow: HOME_NARROW, messages: [baseSingleMessage], - backgroundData: { - ...eg.plusBackgroundData, + state: eg.reduxStatePlus({ userStatuses: Immutable.Map([ [ baseSingleMessage.sender_id, { away: false, status_text: null, status_emoji: statusEmoji }, ], ]), - }, + }), }); }); }); @@ -547,19 +569,34 @@ describe('getEditSequence correct for interesting changes', () => { return msglistElementsDiv.cloneNode(true); }; + type CheckArg = {| + state?: PerAccountState, + globalSettings?: GlobalSettingsState, + debug?: Debug, + narrow?: Narrow, + messages: $ReadOnlyArray, + |}; + const check = ( - // TODO: Test with a variety of different things in background data + // TODO: Test with a variety of different things in state/globalState { - backgroundData: oldBackgroundData = plusBackgroundData, + state: oldState = baseState, + globalSettings: oldGlobalSettings = getGlobalSettings(eg.plusReduxState), + debug: oldDebug = getDebug(eg.plusReduxState), narrow: oldNarrow = HOME_NARROW, messages: oldMessages, - }, + }: CheckArg, { - backgroundData: newBackgroundData = plusBackgroundData, + state: newState = baseState, + globalSettings: newGlobalSettings = getGlobalSettings(eg.plusReduxState), + debug: newDebug = getDebug(eg.plusReduxState), narrow: newNarrow = HOME_NARROW, messages: newMessages, - }, + }: CheckArg, ) => { + const oldBackgroundData = getBackgroundData(oldState, oldGlobalSettings, oldDebug); + const newBackgroundData = getBackgroundData(newState, newGlobalSettings, newDebug); + const oldElements = getMessageListElements(oldMessages, oldNarrow); const newElements = getMessageListElements(newMessages, newNarrow); @@ -801,17 +838,15 @@ describe('getEditSequence correct for interesting changes', () => { check( { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, - flags: { ...eg.plusBackgroundData.flags, starred: {} }, - }, + state: eg.reduxStatePlus({ + flags: { ...eg.plusReduxState.flags, starred: {} }, + }), }, { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, - flags: { ...eg.plusBackgroundData.flags, starred: { [message.id]: true } }, - }, + state: eg.reduxStatePlus({ + flags: { ...eg.plusReduxState.flags, starred: { [message.id]: true } }, + }), }, ); }); @@ -821,17 +856,15 @@ describe('getEditSequence correct for interesting changes', () => { check( { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, - flags: { ...eg.plusBackgroundData.flags, starred: { [message.id]: true } }, - }, + state: eg.reduxStatePlus({ + flags: { ...eg.plusReduxState.flags, starred: { [message.id]: true } }, + }), }, { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, - flags: { ...eg.plusBackgroundData.flags, starred: {} }, - }, + state: eg.reduxStatePlus({ + flags: { ...eg.plusReduxState.flags, starred: {} }, + }), }, ); }); @@ -844,14 +877,13 @@ describe('getEditSequence correct for interesting changes', () => { check( { messages: [message], - backgroundData: { ...eg.plusBackgroundData, mutedUsers: Immutable.Map() }, + state: eg.reduxStatePlus({ mutedUsers: Immutable.Map() }), }, { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, + state: eg.reduxStatePlus({ mutedUsers: Immutable.Map([[message.sender_id, 1644366787]]), - }, + }), }, ); }); @@ -861,14 +893,13 @@ describe('getEditSequence correct for interesting changes', () => { check( { messages: [message], - backgroundData: { - ...eg.plusBackgroundData, + state: eg.reduxStatePlus({ mutedUsers: Immutable.Map([[message.sender_id, 1644366787]]), - }, + }), }, { messages: [message], - backgroundData: { ...eg.plusBackgroundData, mutedUsers: Immutable.Map() }, + state: eg.reduxStatePlus({ mutedUsers: Immutable.Map() }), }, ); }); @@ -892,8 +923,7 @@ describe('getEditSequence correct for interesting changes', () => { check( ...[emojiStatusA, emojiStatusB].map(emojiStatus => ({ messages: [message], - backgroundData: { - ...eg.plusBackgroundData, + state: eg.reduxStatePlus({ userStatuses: Immutable.Map([ [ message.sender_id, @@ -904,7 +934,7 @@ describe('getEditSequence correct for interesting changes', () => { }, ], ]), - }, + }), })), ); }); From 932c28dd0571c42c9ec5974ab39508fea52144c8 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 11 Mar 2022 11:44:58 -0800 Subject: [PATCH 2/5] msglist tests: Fix flake; make test data more representative One of the `check` functions hasn't been using our `baseState` that we put together with stream1 and stream2, to give background for the messages in those streams (streamMessages1, streamMessages2, etc.) that we pass to `check`. So, use that `baseState`. Also, the question of whether those streams are subscribed has effectively been left up to chance: if `eg.plusReduxState` *happens* to have a `subscriptions` entry for stream1 or stream2 (i.e., one where the stream_id matches), then we render a stream header as "subscribed"; otherwise not [1]. `eg.plusReduxState` currently has two `subscriptions` entries, both with random stream_ids. Most of the time they differ from stream1 and stream2 (effectively making those streams "unsubscribed"), but we saw a flake in CI for #5290 where they must've collided. Settle the question by saying the streams are actually subscribed, which is the common case. [1] If "subscribed", the background color is the stream's color (#123456 in current example data); otherwise, the fallback hsl(0, 0%, 80%). And the text color is `foregroundColorFromBackground` of that. --- ...oundEventEditSequence-test.js.snap.android | 60 +++++++++---------- ...eInboundEventEditSequence-test.js.snap.ios | 60 +++++++++---------- .../generateInboundEventEditSequence-test.js | 6 +- 3 files changed, 65 insertions(+), 61 deletions(-) diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android index 046f2913f6f..40241d2c2a7 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android @@ -88,8 +88,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 5, 1995
-
+
# stream 1
topic 1
@@ -132,8 +132,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -181,8 +181,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 19, 1995
-
+
# stream 1
topic 1
@@ -205,8 +205,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 2
@@ -237,8 +237,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -261,8 +261,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 2
topic 2
@@ -293,8 +293,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -608,8 +608,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 5, 1995
-
+
# stream 1
topic 1
@@ -688,8 +688,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 19, 1995
-
+
# stream 1
topic 1
@@ -712,8 +712,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 2
@@ -876,8 +876,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -900,8 +900,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 2
topic 2
@@ -924,8 +924,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 1
@@ -996,8 +996,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 1
@@ -1958,8 +1958,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other Dec 31, 1969
-
+
# nonrandom stream
example topic
diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios index 046f2913f6f..40241d2c2a7 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios @@ -88,8 +88,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 5, 1995
-
+
# stream 1
topic 1
@@ -132,8 +132,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -181,8 +181,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 19, 1995
-
+
# stream 1
topic 1
@@ -205,8 +205,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 2
@@ -237,8 +237,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -261,8 +261,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 2
topic 2
@@ -293,8 +293,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -608,8 +608,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 5, 1995
-
+
# stream 1
topic 1
@@ -688,8 +688,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Feb 19, 1995
-
+
# stream 1
topic 1
@@ -712,8 +712,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 2
@@ -876,8 +876,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N Mar 5, 1995
-
+
# stream 1
topic 1
@@ -900,8 +900,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 2
topic 2
@@ -924,8 +924,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 1
@@ -996,8 +996,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible HOME_N
-
+
# stream 1
topic 1
@@ -1958,8 +1958,8 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other Dec 31, 1969
-
+
# nonrandom stream
example topic
diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index c6710243b2a..7911c76a6c6 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -196,6 +196,10 @@ const pmMessages6 = [ const baseState = eg.reduxStatePlus({ streams: [stream1, stream2], + subscriptions: [ + eg.makeSubscription({ stream: stream1 }), + eg.makeSubscription({ stream: stream2 }), + ], }); /** @@ -234,7 +238,7 @@ const baseState = eg.reduxStatePlus({ */ describe('messages -> piece descriptors -> content HTML is stable/sensible', () => { const check = ({ - state = eg.plusReduxState, + state = baseState, globalSettings = getGlobalSettings(eg.plusReduxState), debug = getDebug(eg.plusReduxState), narrow, From 371e9b48e44baf1e8542da271a463df4e3e29b62 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 11 Mar 2022 12:05:01 -0800 Subject: [PATCH 3/5] msglist tests: Remove some accidental clobbering of `plusReduxState` On principle; not because there's anything in these particular fields that we really want. The principle is that we strictly want to add to the "standard example data" that `plusReduxState` exists to offer; we have no reason to erase or corrupt it. --- src/webview/__tests__/generateInboundEventEditSequence-test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index 7911c76a6c6..716b47cce95 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -195,8 +195,9 @@ const pmMessages6 = [ ]; const baseState = eg.reduxStatePlus({ - streams: [stream1, stream2], + streams: [...eg.plusReduxState.streams, stream1, stream2], subscriptions: [ + ...eg.plusReduxState.subscriptions, eg.makeSubscription({ stream: stream1 }), eg.makeSubscription({ stream: stream2 }), ], From 137c02010bbe4b38631ab9326ae3c56e5233c8d8 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 11 Mar 2022 12:14:42 -0800 Subject: [PATCH 4/5] msglist tests: Use `stream1` in single-messages tests The previous stream object was in an awkward in-between position: its ID happened to match the `stream1` and `stream1`'s subscription in the state (`baseState`) that the `check` function used as a default. But the stream's name differed in an arbitrary and unimportant way. (Both stream objects are "nonrandom" enough for current purposes.) So, just use `stream1`. --- ...oundEventEditSequence-test.js.snap.android | 38 +++++++++---------- ...eInboundEventEditSequence-test.js.snap.ios | 38 +++++++++---------- .../generateInboundEventEditSequence-test.js | 2 +- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android index 40241d2c2a7..c208d4af22c 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android @@ -1534,7 +1534,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1576,7 +1576,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1608,7 +1608,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1640,7 +1640,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1672,7 +1672,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1704,7 +1704,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1736,7 +1736,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1768,7 +1768,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1800,7 +1800,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1832,7 +1832,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1864,7 +1864,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1896,7 +1896,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1928,7 +1928,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1960,7 +1960,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1992,7 +1992,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2026,7 +2026,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2058,7 +2058,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2090,7 +2090,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2122,7 +2122,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios index 40241d2c2a7..c208d4af22c 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios @@ -1534,7 +1534,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1576,7 +1576,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1608,7 +1608,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1640,7 +1640,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1672,7 +1672,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1704,7 +1704,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1736,7 +1736,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1768,7 +1768,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1800,7 +1800,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1832,7 +1832,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1864,7 +1864,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1896,7 +1896,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1928,7 +1928,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1960,7 +1960,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -1992,7 +1992,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2026,7 +2026,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2058,7 +2058,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2090,7 +2090,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
@@ -2122,7 +2122,7 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible other
- # nonrandom stream + # stream 1
example topic
Dec 31, 1969
diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index 716b47cce95..d395fe80f79 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -422,7 +422,7 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () const baseSingleMessage = eg.streamMessage({ id: -1, timestamp: -1, - stream: eg.makeStream({ stream_id: 1, name: 'nonrandom stream' }), + stream: stream1, sender: singleMessageSender, }); From 51b582f15c1566eaa7fb871f9ccd246033bcd539 Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Fri, 11 Mar 2022 12:29:01 -0800 Subject: [PATCH 5/5] msglist tests: Add snapshot with unsubscribed-stream header --- ...oundEventEditSequence-test.js.snap.android | 32 +++++++++++++++++++ ...eInboundEventEditSequence-test.js.snap.ios | 32 +++++++++++++++++++ .../generateInboundEventEditSequence-test.js | 15 +++++++++ 3 files changed, 79 insertions(+) diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android index c208d4af22c..a118313e597 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.android @@ -1526,6 +1526,38 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible all-pm
" `; +exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in unsubscribed stream 1`] = ` +"
+
+ Dec 31, 1969 +
+
+
+ # stream 1 +
+
example topic
+
Dec 31, 1969
+
+
+ \\"Nonrandom +
+
+
+
+ Nonrandom name sender User +
+
11:59 PM
+
+

This is an example stream message.

+ + + +
+ +
" +`; + exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with a poll 1`] = ` "
diff --git a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios index c208d4af22c..a118313e597 100644 --- a/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios +++ b/src/webview/__tests__/__snapshots__/generateInboundEventEditSequence-test.js.snap.ios @@ -1526,6 +1526,38 @@ exports[`messages -> piece descriptors -> content HTML is stable/sensible all-pm
" `; +exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message in unsubscribed stream 1`] = ` +"
+
+ Dec 31, 1969 +
+
+
+ # stream 1 +
+
example topic
+
Dec 31, 1969
+
+
+ \\"Nonrandom +
+
+
+
+ Nonrandom name sender User +
+
11:59 PM
+
+

This is an example stream message.

+ + + +
+ +
" +`; + exports[`messages -> piece descriptors -> content HTML is stable/sensible other interesting cases (single messages) message with a poll 1`] = ` "
diff --git a/src/webview/__tests__/generateInboundEventEditSequence-test.js b/src/webview/__tests__/generateInboundEventEditSequence-test.js index d395fe80f79..fa9a32fc73a 100644 --- a/src/webview/__tests__/generateInboundEventEditSequence-test.js +++ b/src/webview/__tests__/generateInboundEventEditSequence-test.js @@ -426,6 +426,21 @@ describe('messages -> piece descriptors -> content HTML is stable/sensible', () sender: singleMessageSender, }); + test('message in unsubscribed stream', () => { + check({ + narrow: HOME_NARROW, + messages: [baseSingleMessage], + state: eg.reduxStatePlus({ + streams: [...eg.plusReduxState.streams, stream1, stream2], + subscriptions: [ + ...eg.plusReduxState.subscriptions, + // no subscription for stream1 + eg.makeSubscription({ stream: stream2 }), + ], + }), + }); + }); + test('message with reactions', () => { check({ narrow: HOME_NARROW,