Skip to content

Commit

Permalink
feat: bump core gzipped request (#15694)
Browse files Browse the repository at this point in the history
* chore: bump core

* runfix: update giphy repo test

* test: update conversation repo test

* chore: fix types
  • Loading branch information
PatrykBuniX committed Aug 30, 2023
1 parent 8cf5b2a commit 64d5409
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 250 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"@datadog/browser-rum": "^4.47.0",
"@emotion/react": "11.11.1",
"@wireapp/avs": "9.3.7",
"@wireapp/core": "41.4.2",
"@wireapp/core": "41.5.2",
"@wireapp/lru-cache": "3.8.1",
"@wireapp/react-ui-kit": "9.8.1",
"@wireapp/store-engine-dexie": "2.1.3",
Expand Down
33 changes: 29 additions & 4 deletions src/script/conversation/ConversationRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import {faker} from '@faker-js/faker';
import {ClientClassification} from '@wireapp/api-client/lib/client/';
import {ConnectionStatus} from '@wireapp/api-client/lib/connection/';
import {
Conversation as BackendConversation,
CONVERSATION_ACCESS,
CONVERSATION_LEGACY_ACCESS_ROLE,
CONVERSATION_TYPE,
RemoteConversations,
} from '@wireapp/api-client/lib/conversation/';
} from '@wireapp/api-client/lib/conversation';
import {RECEIPT_MODE} from '@wireapp/api-client/lib/conversation/data';
import {ConversationProtocol} from '@wireapp/api-client/lib/conversation/NewConversation';
import {ConversationCreateEvent, ConversationMemberJoinEvent, CONVERSATION_EVENT} from '@wireapp/api-client/lib/event/';
Expand Down Expand Up @@ -64,8 +65,6 @@ import {generateUser} from '../../../test/helper/UserGenerator';
import {Core} from '../service/CoreSingleton';
import {LegacyEventRecord, StorageService} from '../storage';

jest.deepUnmock('axios');

describe('ConversationRepository', () => {
const testFactory = new TestFactory();

Expand Down Expand Up @@ -569,6 +568,7 @@ describe('ConversationRepository', () => {
it("shows a failed message on the sender's side if the upload fails", () => {
const selfUser = generateUser();
const conversation_id = createUuid();
const conversationQualifiedId = {domain: '', id: conversation_id};
const message_id = createUuid();
const sending_user_id = selfUser.id;
spyOn(testFactory.conversation_repository['userState'], 'self').and.returnValue(selfUser);
Expand Down Expand Up @@ -603,6 +603,31 @@ describe('ConversationRepository', () => {
type: 'conversation.asset-add',
};

const conversation_payload = {
creator: conversation_et.id,
id: conversation_id,
qualified_id: conversationQualifiedId,
members: {
others: [],
self: {
hidden_ref: null,
id: conversation_et.id,
otr_archived_ref: null,
otr_muted_ref: null,
otr_muted_status: 0,
service: null,
status_ref: '0.0',
status_time: '2015-01-28T12:53:41.847Z',
},
},
name: '',
type: 0,
} as unknown as BackendConversation;

jest
.spyOn(testFactory.conversation_repository['conversationService'], 'getConversationById')
.mockResolvedValue(conversation_payload);

return testFactory.conversation_repository['fetchConversationById']({domain: '', id: conversation_id})
.then(fetched_conversation => {
expect(fetched_conversation).toBeDefined();
Expand Down Expand Up @@ -696,7 +721,7 @@ describe('ConversationRepository', () => {
it('should process create event for a new conversation created locally', () => {
jest
.spyOn(testFactory.conversation_repository['conversationService'], 'getConversationById')
.mockResolvedValue(createEvent.data);
.mockResolvedValueOnce(createEvent.data);
return testFactory.conversation_repository['handleConversationEvent'](createEvent).then(() => {
expect(testFactory.conversation_repository['onCreate']).toHaveBeenCalled();
expect(testFactory.conversation_repository.mapConversations).toHaveBeenCalledWith([createEvent.data], 1);
Expand Down
206 changes: 206 additions & 0 deletions test/unit_tests/extension/GiphyRepository.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
/*
* Wire
* Copyright (C) 2018 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

import {GiphyResult} from '@wireapp/api-client/lib/giphy/GiphyResult';
import {container} from 'tsyringe';

import {GiphyRepository} from 'src/script/extension/GiphyRepository';
import {GiphyService} from 'src/script/extension/GiphyService';
import {APIClient} from 'src/script/service/APIClientSingleton';

const randomFooGiphyResponse = {
data: {
fixed_height_downsampled_height: '200',
fixed_height_downsampled_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/200_d.gif',
fixed_height_downsampled_width: '262',
fixed_height_small_height: '100',
fixed_height_small_still_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/100_s.gif',
fixed_height_small_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/100.gif',
fixed_height_small_width: '131',
fixed_width_downsampled_height: '153',
fixed_width_downsampled_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/200w_d.gif',
fixed_width_downsampled_width: '200',
fixed_width_small_height: '76',
fixed_width_small_still_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/100w_s.gif',
fixed_width_small_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/100w.gif',
fixed_width_small_width: '100',
id: 'GKLmFicoabZrW',
image_frames: '10',
image_height: '244',
image_mp4_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/giphy.mp4',
image_original_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/giphy.gif',
image_url: 'http://s3.amazonaws.com/giphygifs/media/GKLmFicoabZrW/giphy.gif',
image_width: '320',
type: 'gif',
url: 'http://giphy.com/gifs/big-thank-indulging-GKLmFicoabZrW',
},
meta: {},
} as unknown as GiphyResult;

const getByIdResponse = {
data: {
bitly_gif_url: 'http://gph.is/1Q95Wje',
bitly_url: 'http://gph.is/1Q95Wje',
caption: '',
content_url: '',
embed_url: 'https://giphy.com/embed/GKLmFicoabZrW',
id: 'GKLmFicoabZrW',
images: {
downsized: {
height: '244',
size: '514699',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy.gif',
width: '320',
},
downsized_large: {
height: '0',
size: '0',
url: '',
width: '0',
},
downsized_still: {
height: '244',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy_s.gif',
width: '320',
},
fixed_height: {
height: '200',
mp4: 'https://media4.giphy.com/media/GKLmFicoabZrW/200.mp4',
mp4_size: '178927',
size: '0',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/200.webp',
webp_size: '88838',
width: '262',
},
fixed_height_downsampled: {
height: '200',
size: '149525',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200_d.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/200_d.webp',
webp_size: '53016',
width: '262',
},
fixed_height_small: {
height: '100',
mp4: 'https://media4.giphy.com/media/GKLmFicoabZrW/100.mp4',
mp4_size: '66464',
size: '0',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/100.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/100.webp',
webp_size: '32982',
width: '131',
},
fixed_height_small_still: {
height: '100',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/100_s.gif',
width: '131',
},
fixed_height_still: {
height: '200',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200_s.gif',
width: '262',
},
fixed_width: {
height: '153',
mp4: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w.mp4',
mp4_size: '120356',
size: '0',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w.webp',
webp_size: '57810',
width: '200',
},
fixed_width_downsampled: {
height: '153',
size: '227351',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w_d.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w_d.webp',
webp_size: '34448',
width: '200',
},
fixed_width_small: {
height: '76',
mp4: 'https://media4.giphy.com/media/GKLmFicoabZrW/100w.mp4',
mp4_size: '46951',
size: '0',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/100w.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/100w.webp',
webp_size: '23174',
width: '100',
},
fixed_width_small_still: {
height: '76',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/100w_s.gif',
width: '100',
},
fixed_width_still: {
height: '153',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/200w_s.gif',
width: '200',
},
original: {
frames: '10',
height: '244',
mp4: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy.mp4',
mp4_size: '710329',
size: '514699',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy.gif',
webp: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy.webp',
webp_size: '116528',
width: '320',
},
original_still: {
height: '244',
url: 'https://media4.giphy.com/media/GKLmFicoabZrW/giphy_s.gif',
width: '320',
},
},
import_datetime: '2015-05-02 00:11:31',
rating: 'pg',
source: 'http://jezebel.com/big-sean-is-indulging-in-some-me-time-thank-you-1701548048',
trending_datetime: '2015-05-04 20:01:25',
type: 'gif',
url: 'https://giphy.com/gifs/big-thank-indulging-GKLmFicoabZrW',
username: '',
},
} as unknown as GiphyResult;

describe('Giphy Repository', () => {
describe('getRandomGif', () => {
it('can receive a random gif', async () => {
const apiClient = container.resolve(APIClient);

const giphyService = new GiphyService(container.resolve(APIClient));
const giphyRepository = new GiphyRepository(giphyService);

jest.spyOn(giphyService, 'getRandom');
jest.spyOn(giphyService, 'getById');

jest.spyOn(apiClient.api.giphy, 'getGiphyRandom').mockResolvedValueOnce(randomFooGiphyResponse);
jest.spyOn(apiClient.api.giphy, 'getGiphyById').mockResolvedValueOnce(getByIdResponse);

const tag = 'foo';
await giphyRepository.getRandomGif({tag});

expect(giphyService.getRandom).toHaveBeenCalledWith(tag);
expect(giphyService.getById).toHaveBeenCalledWith(randomFooGiphyResponse.data.id);
});
});
});
Loading

0 comments on commit 64d5409

Please sign in to comment.