Skip to content

Commit cd22511

Browse files
wesbillmanCarl
andcommitted
Test channel tail realignment
Cover composer growth and keyboard metric changes while following the latest message, plus preservation of a deliberately detached timeline. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <[email protected]>
1 parent f8771b6 commit cd22511

1 file changed

Lines changed: 137 additions & 0 deletions

File tree

‎mobile/test/features/channels/channel_detail_page_test.dart‎

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,143 @@ void main() {
17681768
);
17691769
});
17701770

1771+
testWidgets(
1772+
'keeps the followed tail anchored through composer and keyboard resize',
1773+
(tester) async {
1774+
tester.view.physicalSize = const Size(400, 800);
1775+
tester.view.devicePixelRatio = 1;
1776+
addTearDown(tester.view.resetPhysicalSize);
1777+
addTearDown(tester.view.resetDevicePixelRatio);
1778+
addTearDown(tester.view.reset);
1779+
1780+
final messages = [
1781+
for (var i = 0; i < 20; i++)
1782+
_textMsg(
1783+
id: 'msg$i',
1784+
pubkey: i.isEven ? 'alice' : 'bob',
1785+
content: 'Message $i',
1786+
createdAt: 1000 + i * 1000,
1787+
),
1788+
];
1789+
1790+
await tester.pumpWidget(
1791+
_buildTestable(
1792+
messages: messages,
1793+
users: const {
1794+
'alice': UserProfile(pubkey: 'alice', displayName: 'Alice'),
1795+
'bob': UserProfile(pubkey: 'bob', displayName: 'Bob'),
1796+
},
1797+
),
1798+
);
1799+
await tester.pumpAndSettle();
1800+
1801+
final latestMessage = find.byKey(
1802+
const ValueKey('channel-message-group-msg19'),
1803+
);
1804+
final composerDock = find.byKey(
1805+
const ValueKey('channel-composer-dock'),
1806+
);
1807+
final compactDockHeight = tester.getSize(composerDock).height;
1808+
1809+
expect(latestMessage, findsOneWidget);
1810+
expect(
1811+
tester.getBottomLeft(latestMessage).dy,
1812+
lessThanOrEqualTo(tester.getTopLeft(composerDock).dy + 1),
1813+
);
1814+
1815+
await tester.tap(find.text('Message #general'));
1816+
await tester.pumpAndSettle();
1817+
1818+
expect(
1819+
tester.getSize(composerDock).height,
1820+
greaterThan(compactDockHeight),
1821+
);
1822+
expect(
1823+
tester.getBottomLeft(latestMessage).dy,
1824+
lessThanOrEqualTo(tester.getTopLeft(composerDock).dy + 1),
1825+
);
1826+
expect(
1827+
find.byKey(const ValueKey('channel-jump-to-latest')),
1828+
findsNothing,
1829+
);
1830+
1831+
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
1832+
await tester.pumpAndSettle();
1833+
1834+
expect(latestMessage, findsOneWidget);
1835+
expect(
1836+
tester.getBottomLeft(latestMessage).dy,
1837+
lessThanOrEqualTo(tester.getTopLeft(composerDock).dy + 1),
1838+
);
1839+
expect(
1840+
find.byKey(const ValueKey('channel-jump-to-latest')),
1841+
findsNothing,
1842+
);
1843+
},
1844+
);
1845+
1846+
testWidgets(
1847+
'does not realign a user-detached timeline on keyboard resize',
1848+
(tester) async {
1849+
tester.view.physicalSize = const Size(400, 600);
1850+
tester.view.devicePixelRatio = 1;
1851+
addTearDown(tester.view.resetPhysicalSize);
1852+
addTearDown(tester.view.resetDevicePixelRatio);
1853+
addTearDown(tester.view.reset);
1854+
1855+
final messages = [
1856+
for (var i = 0; i < 40; i++)
1857+
_textMsg(
1858+
id: 'msg$i',
1859+
pubkey: 'alice',
1860+
content: 'Message $i',
1861+
createdAt: 1000 + i,
1862+
),
1863+
];
1864+
1865+
await tester.pumpWidget(
1866+
_buildTestable(
1867+
messages: messages,
1868+
users: const {
1869+
'alice': UserProfile(pubkey: 'alice', displayName: 'Alice'),
1870+
},
1871+
),
1872+
);
1873+
await tester.pumpAndSettle();
1874+
1875+
final messageList = find.byKey(const ValueKey('channel-message-list'));
1876+
await tester.drag(messageList, const Offset(0, 300));
1877+
await tester.pumpAndSettle();
1878+
1879+
expect(findRichText('Message 39'), findsNothing);
1880+
expect(
1881+
find.byKey(const ValueKey('channel-jump-to-latest')),
1882+
findsOneWidget,
1883+
);
1884+
1885+
tester.view.viewInsets = const FakeViewPadding(bottom: 300);
1886+
await tester.pumpAndSettle();
1887+
1888+
expect(findRichText('Message 39'), findsNothing);
1889+
expect(
1890+
find.byKey(const ValueKey('channel-jump-to-latest')),
1891+
findsOneWidget,
1892+
);
1893+
final positions = tester
1894+
.widget<ScrollablePositionedList>(messageList)
1895+
.itemPositionsNotifier!
1896+
.itemPositions
1897+
.value;
1898+
expect(
1899+
positions.any(
1900+
(position) =>
1901+
position.index == 0 && position.itemLeadingEdge.abs() < 0.01,
1902+
),
1903+
isFalse,
1904+
);
1905+
},
1906+
);
1907+
17711908
testWidgets('can jump back to latest after a non-drag user scroll', (
17721909
tester,
17731910
) async {

0 commit comments

Comments
 (0)