server icon indicating copy to clipboard operation
server copied to clipboard

Fix User profile picture when performing the search

Open AndyXheli opened this issue 3 years ago • 2 comments

Signed-off-by: Andy Xheli [email protected]

Before image

After 2022-05-27 14_47_23-Dashboard - AXTSolutions Cloud

Fix for #31065

AndyXheli avatar May 27 '22 19:05 AndyXheli

Hey guys! Anyway we can look into this also. I think it would be nice to have this in NC 25.

Currently in NC 25

image

AndyXheli avatar Sep 02 '22 18:09 AndyXheli

Everything seems to work now since i added the line $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]); that @nickvergessen suggested

AndyXheli avatar Sep 20 '22 14:09 AndyXheli

Hi all, any updates on this on being in NC 25 ?

AndyXheli avatar Sep 26 '22 14:09 AndyXheli

@andyxheli CI is unhappy:

There was 1 failure:

  1. Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage Failed asserting that '' is null.

/drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166

that test needs adjustements apparently

blizzz avatar Sep 29 '22 12:09 blizzz

Thank you! @blizzz

@Pytal Do you have any suggestions on what needs to be done on ?

There was 1 failure:

Tests\Contacts\ContactsMenu\ContactsStoreTest::testGetContactsWithoutBinaryImage Failed asserting that '' is null. /drone/src/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php:166

AndyXheli avatar Sep 29 '22 13:09 AndyXheli

This looks to be from the return value of linkToRouteAbsolute() so would say that urlGenerator needs to be mocked, @blizzz might know more here though?

Pytal avatar Sep 29 '22 18:09 Pytal

Actually the test was ensuring(!) that avatar is null. Now it is not anymore as every time an avatar url is being created. The mock would at least return an empty string, and not null. testGetContactsWithoutAvatarURI does not fail however? A bit confusing when your not totally in the logic, it feels a bit that the tests were out of touch with the changes of the ContactsStore.

blizzz avatar Oct 01 '22 18:10 blizzz

Best probably to do as @Pytal suggested: mock url generator to return a dummy url and expect this.

Something like this

diff --git a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
index aa609aedbb9..dfdd67fbb23 100644
--- a/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
+++ b/tests/lib/Contacts/ContactsMenu/ContactsStoreTest.php
@@ -140,6 +140,10 @@ class ContactsStoreTest extends TestCase {
    public function testGetContactsWithoutBinaryImage() {
        /** @var IUser|MockObject $user */
        $user = $this->createMock(IUser::class);
+       $this->urlGenerator->expects($this->any())
+           ->method('linkToRouteAbsolute')
+           ->with('core.avatar.getAvatar', $this->anything())
+           ->willReturn('https://urlToNcAvatar.test');
        $this->contactsManager->expects($this->once())
            ->method('search')
            ->with($this->equalTo(''), $this->equalTo(['FN', 'EMAIL']))
@@ -163,7 +167,7 @@ class ContactsStoreTest extends TestCase {
        $entries = $this->contactsStore->getContacts($user, '');
 
        $this->assertCount(2, $entries);
-       $this->assertNull($entries[1]->getAvatar());
+       $this->assertSame('https://urlToNcAvatar.test', $entries[1]->getAvatar());
    }
 
    public function testGetContactsWithoutAvatarURI() {

(didn't run tests against it)

blizzz avatar Oct 01 '22 19:10 blizzz

Thanks @blizzz I created a pull request for the changes that you suggested for the test

https://github.com/nextcloud/server/pull/34386

AndyXheli avatar Oct 01 '22 23:10 AndyXheli

@andyxheli could you add them as commit to this PR?

blizzz avatar Oct 03 '22 13:10 blizzz

@blizzz All done :)

AndyXheli avatar Oct 03 '22 14:10 AndyXheli

/backport to stable25

blizzz avatar Oct 05 '22 08:10 blizzz

@blizzz thank you! Can we also backpo this to NC 24 ?

AndyXheli avatar Oct 05 '22 12:10 AndyXheli

/backport to stable24

blizzz avatar Oct 05 '22 14:10 blizzz

This seemingly broke avatars of vcf-contacts.

See https://github.com/nextcloud/server/pull/36735

szaimen avatar Feb 15 '23 21:02 szaimen

@szaimen would this also fix https://github.com/nextcloud/server/issues/34503 ? under See https://github.com/nextcloud/server/pull/36735

AndyXheli avatar Feb 15 '23 21:02 AndyXheli

@szaimen would this also fix #34503 ?

No.

szaimen avatar Feb 15 '23 21:02 szaimen

Okay, thanks. Just checking so we did have duplicate issues.

AndyXheli avatar Feb 15 '23 21:02 AndyXheli