mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 14:05:04 +08:00
Merge pull request #3823 from matrix-org/travis/sm-fix-tests
Fix tests for sourcemaps branch
This commit is contained in:
commit
4c3703a5ea
10
__mocks__/languages.json
Normal file
10
__mocks__/languages.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"en": {
|
||||||
|
"fileName": "en_EN.json",
|
||||||
|
"label": "English"
|
||||||
|
},
|
||||||
|
"en-us": {
|
||||||
|
"fileName": "en_US.json",
|
||||||
|
"label": "English (US)"
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{
|
module.exports = {
|
||||||
"sourceMaps": "inline",
|
"sourceMaps": "inline",
|
||||||
"presets": [
|
"presets": [
|
||||||
["@babel/preset-env", {
|
["@babel/preset-env", {
|
||||||
@ -23,4 +23,4 @@
|
|||||||
"@babel/plugin-syntax-dynamic-import",
|
"@babel/plugin-syntax-dynamic-import",
|
||||||
"@babel/plugin-transform-runtime"
|
"@babel/plugin-transform-runtime"
|
||||||
]
|
]
|
||||||
}
|
};
|
18
package.json
18
package.json
@ -121,8 +121,9 @@
|
|||||||
"@babel/preset-typescript": "^7.7.4",
|
"@babel/preset-typescript": "^7.7.4",
|
||||||
"@babel/register": "^7.7.4",
|
"@babel/register": "^7.7.4",
|
||||||
"@babel/runtime": "^7.7.6",
|
"@babel/runtime": "^7.7.6",
|
||||||
|
"@peculiar/webcrypto": "^1.0.22",
|
||||||
"babel-eslint": "^10.0.3",
|
"babel-eslint": "^10.0.3",
|
||||||
"babel-jest": "^23.6.0",
|
"babel-jest": "^24.9.0",
|
||||||
"chokidar": "^2.1.2",
|
"chokidar": "^2.1.2",
|
||||||
"concurrently": "^4.0.1",
|
"concurrently": "^4.0.1",
|
||||||
"enzyme": "^3.10.0",
|
"enzyme": "^3.10.0",
|
||||||
@ -137,7 +138,7 @@
|
|||||||
"estree-walker": "^0.5.0",
|
"estree-walker": "^0.5.0",
|
||||||
"file-loader": "^3.0.1",
|
"file-loader": "^3.0.1",
|
||||||
"flow-parser": "^0.57.3",
|
"flow-parser": "^0.57.3",
|
||||||
"jest": "^23.2.0",
|
"jest": "^24.9.0",
|
||||||
"matrix-mock-request": "^1.2.3",
|
"matrix-mock-request": "^1.2.3",
|
||||||
"matrix-react-test-utils": "^0.2.2",
|
"matrix-react-test-utils": "^0.2.2",
|
||||||
"react-test-renderer": "^16.9.0",
|
"react-test-renderer": "^16.9.0",
|
||||||
@ -147,7 +148,6 @@
|
|||||||
"stylelint": "^9.10.1",
|
"stylelint": "^9.10.1",
|
||||||
"stylelint-config-standard": "^18.2.0",
|
"stylelint-config-standard": "^18.2.0",
|
||||||
"stylelint-scss": "^3.9.0",
|
"stylelint-scss": "^3.9.0",
|
||||||
"subtle": "^0.1.8",
|
|
||||||
"tslint": "^5.20.1",
|
"tslint": "^5.20.1",
|
||||||
"typescript": "^3.7.3",
|
"typescript": "^3.7.3",
|
||||||
"walk": "^2.3.9",
|
"walk": "^2.3.9",
|
||||||
@ -155,10 +155,16 @@
|
|||||||
"webpack-cli": "^3.1.1"
|
"webpack-cli": "^3.1.1"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"testMatch": ["<rootDir>/test/**/*-test.js"],
|
"testMatch": [
|
||||||
|
"<rootDir>/test/**/*-test.js"
|
||||||
|
],
|
||||||
"setupTestFrameworkScriptFile": "<rootDir>/test/setupTests.js",
|
"setupTestFrameworkScriptFile": "<rootDir>/test/setupTests.js",
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"\\.(gif|png|svg|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js"
|
"\\.(gif|png|svg|ttf|woff2)$": "<rootDir>/__mocks__/imageMock.js",
|
||||||
}
|
"\\$webapp/i18n/languages.json": "<rootDir>/__mocks__/languages.json"
|
||||||
|
},
|
||||||
|
"transformIgnorePatterns": [
|
||||||
|
"/node_modules/(?!matrix-js-sdk).+$"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -419,9 +419,9 @@ export function pickBestLanguage(langs) {
|
|||||||
function getLangsJson() {
|
function getLangsJson() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
let url;
|
let url;
|
||||||
try {
|
if (typeof(webpackLangJsonUrl) === 'string') { // in Jest this 'url' isn't a URL, so just fall through
|
||||||
url = webpackLangJsonUrl;
|
url = webpackLangJsonUrl;
|
||||||
} catch (e) {
|
} else {
|
||||||
url = i18nFolder + 'languages.json';
|
url = i18nFolder + 'languages.json';
|
||||||
}
|
}
|
||||||
request(
|
request(
|
||||||
|
@ -21,7 +21,7 @@ import { configure, mount } from "enzyme";
|
|||||||
|
|
||||||
import sdk from "../../../skinned-sdk";
|
import sdk from "../../../skinned-sdk";
|
||||||
import {mkEvent, mkStubRoom} from "../../../test-utils";
|
import {mkEvent, mkStubRoom} from "../../../test-utils";
|
||||||
import MatrixClientPeg from "../../../../src/MatrixClientPeg";
|
import {MatrixClientPeg} from "../../../../src/MatrixClientPeg";
|
||||||
import * as languageHandler from "../../../../src/languageHandler";
|
import * as languageHandler from "../../../../src/languageHandler";
|
||||||
|
|
||||||
const TextualBody = sdk.getComponent("views.messages.TextualBody");
|
const TextualBody = sdk.getComponent("views.messages.TextualBody");
|
||||||
@ -33,7 +33,7 @@ describe("<TextualBody />", () => {
|
|||||||
MatrixClientPeg.matrixClient = null;
|
MatrixClientPeg.matrixClient = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("renders m.emote correctly", () => {
|
it("renders m.emote correctly", () => {
|
||||||
MatrixClientPeg.matrixClient = {
|
MatrixClientPeg.matrixClient = {
|
||||||
getRoom: () => mkStubRoom("room_id"),
|
getRoom: () => mkStubRoom("room_id"),
|
||||||
getAccountData: () => undefined,
|
getAccountData: () => undefined,
|
||||||
@ -56,7 +56,7 @@ describe("<TextualBody />", () => {
|
|||||||
expect(content.html()).toBe('<span class="mx_EventTile_body" dir="auto">winks</span>');
|
expect(content.html()).toBe('<span class="mx_EventTile_body" dir="auto">winks</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("renders m.notice correctly", () => {
|
it("renders m.notice correctly", () => {
|
||||||
MatrixClientPeg.matrixClient = {
|
MatrixClientPeg.matrixClient = {
|
||||||
getRoom: () => mkStubRoom("room_id"),
|
getRoom: () => mkStubRoom("room_id"),
|
||||||
getAccountData: () => undefined,
|
getAccountData: () => undefined,
|
||||||
@ -80,12 +80,14 @@ describe("<TextualBody />", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("renders plain-text m.text correctly", () => {
|
describe("renders plain-text m.text correctly", () => {
|
||||||
MatrixClientPeg.matrixClient = {
|
beforeEach(() => {
|
||||||
getRoom: () => mkStubRoom("room_id"),
|
MatrixClientPeg.matrixClient = {
|
||||||
getAccountData: () => undefined,
|
getRoom: () => mkStubRoom("room_id"),
|
||||||
};
|
getAccountData: () => undefined,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
describe("simple message renders as expected", () => {
|
it("simple message renders as expected", () => {
|
||||||
const ev = mkEvent({
|
const ev = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
room: "room_id",
|
room: "room_id",
|
||||||
@ -104,7 +106,7 @@ describe("<TextualBody />", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If pills were rendered within a Portal/same shadow DOM then it'd be easier to test
|
// If pills were rendered within a Portal/same shadow DOM then it'd be easier to test
|
||||||
describe("linkification get applied correctly into the DOM", () => {
|
it("linkification get applied correctly into the DOM", () => {
|
||||||
const ev = mkEvent({
|
const ev = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
room: "room_id",
|
room: "room_id",
|
||||||
@ -126,16 +128,18 @@ describe("<TextualBody />", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("renders formatted m.text correctly", () => {
|
describe("renders formatted m.text correctly", () => {
|
||||||
MatrixClientPeg.matrixClient = {
|
beforeEach(() => {
|
||||||
getRoom: () => mkStubRoom("room_id"),
|
MatrixClientPeg.matrixClient = {
|
||||||
getAccountData: () => undefined,
|
getRoom: () => mkStubRoom("room_id"),
|
||||||
getUserId: () => "@me:my_server",
|
getAccountData: () => undefined,
|
||||||
getHomeserverUrl: () => "https://my_server/",
|
getUserId: () => "@me:my_server",
|
||||||
on: () => undefined,
|
getHomeserverUrl: () => "https://my_server/",
|
||||||
removeListener: () => undefined,
|
on: () => undefined,
|
||||||
};
|
removeListener: () => undefined,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
describe("italics, bold, underline and strikethrough render as expected", () => {
|
it("italics, bold, underline and strikethrough render as expected", () => {
|
||||||
const ev = mkEvent({
|
const ev = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
room: "room_id",
|
room: "room_id",
|
||||||
@ -156,7 +160,7 @@ describe("<TextualBody />", () => {
|
|||||||
ev.getContent().formatted_body + '</span>');
|
ev.getContent().formatted_body + '</span>');
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("spoilers get injected properly into the DOM", () => {
|
it("spoilers get injected properly into the DOM", () => {
|
||||||
const ev = mkEvent({
|
const ev = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
room: "room_id",
|
room: "room_id",
|
||||||
@ -182,7 +186,7 @@ describe("<TextualBody />", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// If pills were rendered within a Portal/same shadow DOM then it'd be easier to test
|
// If pills were rendered within a Portal/same shadow DOM then it'd be easier to test
|
||||||
describe("pills get injected correctly into the DOM", () => {
|
it("pills get injected correctly into the DOM", () => {
|
||||||
const ev = mkEvent({
|
const ev = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
room: "room_id",
|
room: "room_id",
|
||||||
@ -208,7 +212,7 @@ describe("<TextualBody />", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("renders url previews correctly", () => {
|
it("renders url previews correctly", () => {
|
||||||
languageHandler.setMissingEntryGenerator(key => key.split('|', 2)[1]);
|
languageHandler.setMissingEntryGenerator(key => key.split('|', 2)[1]);
|
||||||
|
|
||||||
MatrixClientPeg.matrixClient = {
|
MatrixClientPeg.matrixClient = {
|
||||||
|
@ -4,7 +4,7 @@ import ReactDOM from 'react-dom';
|
|||||||
import jest from 'jest-mock';
|
import jest from 'jest-mock';
|
||||||
import * as testUtils from '../../../test-utils';
|
import * as testUtils from '../../../test-utils';
|
||||||
import sdk from '../../../skinned-sdk';
|
import sdk from '../../../skinned-sdk';
|
||||||
import MatrixClientPeg from '../../../../src/MatrixClientPeg';
|
import {MatrixClientPeg} from '../../../../src/MatrixClientPeg';
|
||||||
import SettingsStore from '../../../../src/settings/SettingsStore';
|
import SettingsStore from '../../../../src/settings/SettingsStore';
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,16 +9,10 @@
|
|||||||
* app to provide
|
* app to provide
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// for ES6 stuff like startsWith() and Object.values() that babel doesn't do by
|
import * as sdk from "../src/index";
|
||||||
// default
|
import stubComponent from "./components/stub-component";
|
||||||
require('babel-polyfill');
|
|
||||||
|
|
||||||
const sdk = require("../src/index");
|
const components = {};
|
||||||
|
|
||||||
const skin = require('../src/component-index.js');
|
|
||||||
const stubComponent = require('./components/stub-component.js');
|
|
||||||
|
|
||||||
const components = skin.components;
|
|
||||||
components['structures.LeftPanel'] = stubComponent();
|
components['structures.LeftPanel'] = stubComponent();
|
||||||
components['structures.RightPanel'] = stubComponent();
|
components['structures.RightPanel'] = stubComponent();
|
||||||
components['structures.RoomDirectory'] = stubComponent();
|
components['structures.RoomDirectory'] = stubComponent();
|
||||||
@ -31,6 +25,6 @@ components['views.messages.MessageTimestamp'] = stubComponent({displayName: 'Mes
|
|||||||
components['views.messages.SenderProfile'] = stubComponent({displayName: 'SenderProfile'});
|
components['views.messages.SenderProfile'] = stubComponent({displayName: 'SenderProfile'});
|
||||||
components['views.rooms.SearchBar'] = stubComponent();
|
components['views.rooms.SearchBar'] = stubComponent();
|
||||||
|
|
||||||
sdk.loadSkin(skin);
|
sdk.loadSkin({components});
|
||||||
|
|
||||||
module.exports = sdk;
|
export default sdk;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import RoomViewStore from '../../src/stores/RoomViewStore';
|
import RoomViewStore from '../../src/stores/RoomViewStore';
|
||||||
|
|
||||||
import peg from '../../src/MatrixClientPeg';
|
import {MatrixClientPeg as peg} from '../../src/MatrixClientPeg';
|
||||||
|
|
||||||
import * as testUtils from '../test-utils';
|
import * as testUtils from '../test-utils';
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import peg from '../src/MatrixClientPeg';
|
import {MatrixClientPeg as peg} from '../src/MatrixClientPeg';
|
||||||
import dis from '../src/dispatcher';
|
import dis from '../src/dispatcher';
|
||||||
import jssdk from 'matrix-js-sdk';
|
|
||||||
import {makeType} from "../src/utils/TypeUtils";
|
import {makeType} from "../src/utils/TypeUtils";
|
||||||
import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils";
|
import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils";
|
||||||
import ShallowRenderer from 'react-test-renderer/shallow';
|
import ShallowRenderer from 'react-test-renderer/shallow';
|
||||||
import MatrixClientContext from "../src/contexts/MatrixClientContext";
|
import MatrixClientContext from "../src/contexts/MatrixClientContext";
|
||||||
const MatrixEvent = jssdk.MatrixEvent;
|
import {MatrixEvent} from "matrix-js-sdk/src/models/event";
|
||||||
|
|
||||||
export function getRenderer() {
|
export function getRenderer() {
|
||||||
// Old: ReactTestUtils.createRenderer();
|
// Old: ReactTestUtils.createRenderer();
|
||||||
|
@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import peg from '../../../src/MatrixClientPeg';
|
import {MatrixClientPeg as peg} from '../../../src/MatrixClientPeg';
|
||||||
import {
|
import {
|
||||||
makeGroupPermalink,
|
makeGroupPermalink,
|
||||||
makeRoomPermalink,
|
makeRoomPermalink,
|
||||||
|
Loading…
Reference in New Issue
Block a user