Skip to content

Commit f03c406

Browse files
authored
chore: remove legacy asset handling (#19631)
* feat: remove legacy asset handling * feat: implement breaking changes * fix: sonarqube error * chore: clean up and organise jest mocks, add missing api-client mock (#19747) * fix: images not loading because of undefined id
1 parent e8d1ae1 commit f03c406

File tree

105 files changed

+1785
-1076
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1785
-1076
lines changed

src/script/util/test/mock/animationMock.ts renamed to __mocks__/@formkit/auto-animate/react.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Wire
3-
* Copyright (C) 2020 Wire Swiss GmbH
3+
* Copyright (C) 2025 Wire Swiss GmbH
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -17,8 +17,6 @@
1717
*
1818
*/
1919

20-
// Prevent animations delaying ui changes
21-
jest.mock('@wireapp/react-ui-kit', () => {
22-
const uiKit = jest.requireActual('@wireapp/react-ui-kit');
23-
return {...uiKit, Transition: ({children}: any) => children, TransitionContainer: ({children}: any) => children};
24-
});
20+
module.exports = {
21+
useAutoAnimate: () => [null, () => {}],
22+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*
18+
*/
19+
20+
class FeatureAPI {
21+
async getAllFeatures() {
22+
return {};
23+
}
24+
25+
async getLegalholdFeature() {
26+
return {};
27+
}
28+
29+
async getConversationGuestLinkFeature() {
30+
return {};
31+
}
32+
33+
async putConversationGuestLinkFeature() {
34+
return {};
35+
}
36+
37+
async getConferenceCallingFeature() {
38+
return {};
39+
}
40+
41+
async putConferenceCallingFeature() {
42+
return {};
43+
}
44+
45+
async getVideoCallingFeature() {
46+
return {};
47+
}
48+
49+
async putVideoCallingFeature() {
50+
return {};
51+
}
52+
53+
async getSelfDeletingMessagesFeature() {
54+
return {};
55+
}
56+
57+
async putSelfDeletingMessagesFeature() {
58+
return {};
59+
}
60+
}
61+
62+
const isBackendError = () => false;
63+
64+
module.exports = {
65+
FeatureAPI,
66+
isBackendError,
67+
};

src/__mocks__/@wireapp/core-crypto.ts renamed to __mocks__/@wireapp/core-crypto.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Wire
3-
* Copyright (C) 2022 Wire Swiss GmbH
3+
* Copyright (C) 2025 Wire Swiss GmbH
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
File renamed without changes.

__mocks__/@wireapp/react-ui-kit.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*
18+
*/
19+
20+
const actualUIKit = jest.requireActual('@wireapp/react-ui-kit');
21+
22+
module.exports = {
23+
...actualUIKit,
24+
Transition: ({children}) => children,
25+
TransitionContainer: ({children}) => children,
26+
};

__mocks__/axios.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*
18+
*/
19+
20+
const create = () => {
21+
return {
22+
interceptors: {
23+
request: {eject: jest.fn(), use: jest.fn()},
24+
response: {eject: jest.fn(), use: jest.fn()},
25+
},
26+
request: jest.fn(),
27+
};
28+
};
29+
30+
const axiosMock = {
31+
create,
32+
request: jest.fn(),
33+
interceptors: {
34+
request: {eject: jest.fn(), use: jest.fn()},
35+
response: {eject: jest.fn(), use: jest.fn()},
36+
},
37+
};
38+
39+
module.exports = axiosMock;
40+
module.exports.default = axiosMock;

__mocks__/react-pdf.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2025 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*
18+
*/
19+
20+
module.exports = {
21+
pdfjs: {
22+
GlobalWorkerOptions: {
23+
workerSrc: 'pdf.worker.js',
24+
},
25+
},
26+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@wireapp/avs": "10.2.7",
1717
"@wireapp/avs-debugger": "0.0.7",
1818
"@wireapp/commons": "5.4.5",
19-
"@wireapp/core": "46.40.1",
19+
"@wireapp/core": "46.45.1",
2020
"@wireapp/kalium-backup": "0.0.4",
2121
"@wireapp/promise-queue": "2.4.5",
2222
"@wireapp/react-ui-kit": "9.69.0",

setupTests.js

Lines changed: 32 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@
1919

2020
/* eslint-disable import/order */
2121

22-
// Polyfill for "tsyringe" dependency injection
22+
/**
23+
* ---------------------------------------------------------------------------
24+
* Global polyfills required by the application runtime inside the Jest env
25+
* ---------------------------------------------------------------------------
26+
*/
2327
import 'core-js/full/reflect';
2428
import 'intersection-observer';
2529
import 'core-js/stable/structured-clone';
2630
import 'fake-indexeddb/auto';
2731
import '@testing-library/jest-dom';
2832

33+
/**
34+
* ---------------------------------------------------------------------------
35+
* Wire specific side-effect mocks (mutate global objects when imported)
36+
* ---------------------------------------------------------------------------
37+
*/
2938
import 'src/script/util/test/mock/createObjectURLMock';
3039
import 'src/script/util/test/mock/cryptoMock';
3140
import 'src/script/util/test/mock/matchMediaMock';
@@ -35,49 +44,30 @@ import 'src/script/util/test/mock/ResponseMock';
3544
import 'src/script/util/test/mock/WebRTCMock';
3645
import 'src/script/util/test/mock/resizeObserver.mock';
3746
import 'src/script/util/test/mock/wireEnvMock';
47+
import 'src/script/util/test/mock/browserApiMock';
3848

39-
import encoding from 'text-encoding';
40-
41-
jest.mock('axios', () => {
42-
return {
43-
create: () => {
44-
return {
45-
interceptors: {
46-
request: {eject: jest.fn(), use: jest.fn()},
47-
response: {eject: jest.fn(), use: jest.fn()},
48-
},
49-
request: jest.fn(),
50-
};
51-
},
52-
};
53-
});
54-
55-
window.TextEncoder = encoding.TextEncoder;
56-
window.TextDecoder = encoding.TextDecoder;
57-
58-
window.z = {userPermission: {}};
59-
60-
window.URL.createObjectURL = jest.fn();
61-
window.URL.revokeObjectURL = jest.fn();
62-
63-
Object.defineProperty(document, 'elementFromPoint', {
64-
writable: true,
65-
value: jest.fn().mockImplementation((x, y) => {
66-
return null;
67-
}),
68-
});
69-
49+
/**
50+
* ---------------------------------------------------------------------------
51+
* Testing library configuration
52+
* ---------------------------------------------------------------------------
53+
*/
7054
const testLib = require('@testing-library/react');
7155
testLib.configure({testIdAttribute: 'data-uie-name'});
7256

73-
jest.mock('@formkit/auto-animate/react', () => ({
74-
useAutoAnimate: () => [null, () => {}],
75-
}));
57+
/**
58+
* ---------------------------------------------------------------------------
59+
* Third-party module mocks (implementations live in __mocks__)
60+
* ---------------------------------------------------------------------------
61+
*/
62+
jest.mock('axios');
63+
jest.mock('@formkit/auto-animate/react');
64+
jest.mock('react-pdf');
65+
jest.mock('@wireapp/react-ui-kit');
66+
jest.mock('@wireapp/api-client/lib/team/feature/FeatureAPI');
67+
jest.mock('@wireapp/core');
68+
jest.mock('@wireapp/core-crypto');
7669

77-
jest.mock('react-pdf', () => ({
78-
pdfjs: {
79-
GlobalWorkerOptions: {
80-
workerSrc: 'pdf.worker.js',
81-
},
82-
},
83-
}));
70+
// Important: the team module re-exports FeatureAPI. Requiring both modules here
71+
// ensures Node's module cache captures the mocked constructors instead of the real ones.
72+
require('@wireapp/api-client/lib/team/feature/FeatureAPI');
73+
require('@wireapp/api-client/lib/team');

src/script/E2EIdentity/EnrollmentTimer/EnrollmentTimer.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
import {TimeInMillis} from '@wireapp/commons/lib/util/TimeUtil';
21+
import {CredentialType} from '@wireapp/core/lib/messagingProtocols/mls';
2122

2223
import {getEnrollmentTimer, messageRetentionTime} from './EnrollmentTimer';
2324

@@ -46,6 +47,7 @@ describe('e2ei delays', () => {
4647
])('should return a snoozable timer if device is still valid', (validityPeriod, grace, expectedTimer) => {
4748
const {firingDate, isSnoozable} = getEnrollmentTimer(
4849
{
50+
credentialType: CredentialType.X509,
4951
x509Identity: {
5052
certificate: ' ',
5153
notAfter: (Date.now() + validityPeriod) / 1000,
@@ -65,6 +67,7 @@ describe('e2ei delays', () => {
6567

6668
const {firingDate, isSnoozable} = getEnrollmentTimer(
6769
{
70+
credentialType: CredentialType.X509,
6871
x509Identity: {
6972
certificate: ' ',
7073
notAfter: deadline / 1000,
@@ -83,6 +86,7 @@ describe('e2ei delays', () => {
8386
const gracePeriodStartingPoint = deadline - gracePeriod;
8487
const {firingDate, isSnoozable} = getEnrollmentTimer(
8588
{
89+
credentialType: CredentialType.X509,
8690
x509Identity: {
8791
certificate: ' ',
8892
notAfter: deadline / 1000,

0 commit comments

Comments
 (0)