Skip to content
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
5 changes: 3 additions & 2 deletions resources/js/pages/user/connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,9 @@ export default function Connections({
>
@{person.handle}
</p>
{type === 'followers' &&
knowsFollowers &&
{(type === 'following' ||
(type === 'followers' &&
knowsFollowers)) &&
person.follows_you && (
<span className="shrink-0 rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground">
Follows you
Expand Down
31 changes: 28 additions & 3 deletions tests/Unit/FollowState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ for (const type of [
'mutuals',
] as const) {
for (const followsYou of [true, false]) {
test(`${type} shows the follows-you badge only for a viewer's follower on the Followers tab (${followsYou})`, () => {
test(`${type} shows the follows-you badge only for a viewer's follower on the Followers or Following tab (${followsYou})`, () => {
const page = Connections({
user: suggestion('someone-else'),
type,
Expand All @@ -358,9 +358,9 @@ for (const type of [
assert.equal(
find(page, (props) => props.children === 'Follows you') !==
null,
type === 'followers' && followsYou,
(type === 'followers' || type === 'following') && followsYou,
);
if (type === 'followers' && followsYou) {
if ((type === 'followers' || type === 'following') && followsYou) {
const handleRow = find(
page,
(props) =>
Expand All @@ -383,6 +383,31 @@ for (const type of [
}
}

for (const followsYou of [true, false]) {
test(`your own Following list shows the follows-you badge only for a viewer's follower (${followsYou})`, () => {
const page = Connections({
user: suggestion('viewer'),
type: 'following',
users: {
data: [
{
...suggestion('own-following'),
is_followed: true,
follows_you: followsYou,
},
],
next_cursor: null,
prev_cursor: null,
},
});

assert.equal(
find(page, (props) => props.children === 'Follows you') !== null,
followsYou,
);
});
}

for (const isFollowing of [true, false]) {
test(`your own Followers list hides the redundant follows-you badge (following=${isFollowing})`, () => {
const page = Connections({
Expand Down