Step 8.1: Remove skinning setup from all tests

This commit is contained in:
Travis Ralston 2022-03-22 23:22:53 -06:00
parent 9350c50f87
commit a987ead7d2
57 changed files with 3 additions and 129 deletions

View file

@ -34,7 +34,6 @@ export default %%ComponentName%%;
import React from 'react';
import { mount } from 'enzyme';
import '%%SkinnedSdkPath%%';
import %%ComponentName%% from '%%RelativeComponentPath%%';
describe('<%%ComponentName%% />', () => {
@ -85,10 +84,8 @@ const makeFile = async ({
const relativePathToComponent = path.parse(path.relative(path.dirname(newFilePath), componentFilePath || ''));
const importComponentPath = path.join(relativePathToComponent.dir, relativePathToComponent.name);
const skinnedSdkPath = path.relative(path.dirname(newFilePath), 'test/skinned-sdk')
try {
await fs.writeFile(newFilePath, fillTemplate(template, componentName, importComponentPath, skinnedSdkPath), { flag: 'wx' });
await fs.writeFile(newFilePath, fillTemplate(template, componentName, importComponentPath), { flag: 'wx' });
console.log(`Created ${path.relative(process.cwd(), newFilePath)}`);
return newFilePath;
} catch (error) {
@ -104,7 +101,6 @@ const makeFile = async ({
const fillTemplate = (template, componentName, relativeComponentFilePath, skinnedSdkPath) =>
template.replace(/%%ComponentName%%/g, componentName)
.replace(/%%RelativeComponentPath%%/g, relativeComponentFilePath)
.replace(/%%SkinnedSdkPath%%/g, skinnedSdkPath)
const makeReactComponent = async () => {

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import './skinned-sdk';
import { IProtocol } from 'matrix-js-sdk/src/matrix';
import { CallEvent, CallState, CallType } from 'matrix-js-sdk/src/webrtc/call';
import EventEmitter from 'events';

View file

@ -16,7 +16,6 @@ limitations under the License.
import { MatrixEvent } from 'matrix-js-sdk/src/matrix';
import './skinned-sdk'; // Must be first for skinning to work
import { DecryptionFailureTracker } from '../src/DecryptionFailureTracker';
class MockDecryptionError extends Error {

View file

@ -19,7 +19,6 @@ import { EventEmitter } from "events";
import { mocked } from "jest-mock";
import { Room } from "matrix-js-sdk/src/matrix";
import './skinned-sdk';
import DeviceListener from "../src/DeviceListener";
import { MatrixClientPeg } from "../src/MatrixClientPeg";
import * as SetupEncryptionToast from "../src/toasts/SetupEncryptionToast";

View file

@ -17,7 +17,6 @@ limitations under the License.
import fs from "fs";
import path from "path";
import './skinned-sdk';
import { blobIsAnimated, mayBeAnimated } from "../src/utils/Image";
describe("Image", () => {

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import './skinned-sdk';
import {
getNestedReplyText,
getParentEventId,

View file

@ -1,5 +1,3 @@
import './skinned-sdk';
import { EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
import TestRenderer from 'react-test-renderer';

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import '../skinned-sdk'; // Must be first for skinning to work
import * as React from "react";
import { mount, ReactWrapper } from "enzyme";

View file

@ -17,8 +17,6 @@ limitations under the License.
import { mocked } from 'jest-mock';
import { logger } from 'matrix-js-sdk/src/logger';
import '../skinned-sdk'; // Must be first for skinning to work
import { createAudioContext, decodeOgg } from '../../src/audio/compat';
import { Playback, PlaybackState } from "../../src/audio/Playback";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../../skinned-sdk";
import { MatrixClient, MatrixEvent } from 'matrix-js-sdk/src/matrix';
import { EventType } from "matrix-js-sdk/src/@types/event";
import { CallState } from "matrix-js-sdk/src/webrtc/call";

View file

@ -19,8 +19,6 @@ import TestRenderer from "react-test-renderer";
import { jest } from "@jest/globals";
import { Room } from "matrix-js-sdk/src/models/room";
// We can't use the usual `skinned-sdk`, as it stubs out the RightPanel
import "../../minimal-sdk";
import RightPanel from "../../../src/components/structures/RightPanel";
import { MatrixClientPeg } from "../../../src/MatrixClientPeg";
import ResizeNotifier from "../../../src/utils/ResizeNotifier";

View file

@ -16,7 +16,6 @@ limitations under the License.
import React from 'react';
import { shallow, mount } from "enzyme";
import '../../skinned-sdk';
import {
ThreadFilterType,

View file

@ -20,7 +20,6 @@ import { mocked } from 'jest-mock';
import { logger } from 'matrix-js-sdk/src/logger';
import { act } from 'react-dom/test-utils';
import '../../../skinned-sdk';
import RecordingPlayback from '../../../../src/components/views/audio_messages/RecordingPlayback';
import { Playback } from '../../../../src/audio/Playback';
import RoomContext, { TimelineRenderingType } from '../../../../src/contexts/RoomContext';

View file

@ -17,7 +17,6 @@ limitations under the License.
import React from "react";
import { mount } from "enzyme";
import "../../../skinned-sdk";
import ContextMenu, { ChevronFace } from "../../../../src/components/structures/ContextMenu";
import UIStore from "../../../../src/stores/UIStore";

View file

@ -21,7 +21,6 @@ import { Room } from 'matrix-js-sdk/src/models/room';
import { PendingEventOrdering } from 'matrix-js-sdk/src/matrix';
import { ExtensibleEvent, MessageEvent, M_POLL_KIND_DISCLOSED, PollStartEvent } from 'matrix-events-sdk';
import '../../../skinned-sdk';
import * as TestUtils from '../../../test-utils';
import MessageContextMenu from '../../../../src/components/views/context_menus/MessageContextMenu';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';

View file

@ -20,7 +20,6 @@ import { Room } from 'matrix-js-sdk/src/matrix';
import { mocked } from 'jest-mock';
import { act } from 'react-dom/test-utils';
import '../../../skinned-sdk';
import SpaceContextMenu from '../../../../src/components/views/context_menus/SpaceContextMenu';
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';
import { findByTestId } from '../../../test-utils';

View file

@ -20,7 +20,6 @@ import { mocked } from 'jest-mock';
import { act } from "react-dom/test-utils";
import { Room } from 'matrix-js-sdk/src/matrix';
import '../../../skinned-sdk';
import ExportDialog from '../../../../src/components/views/dialogs/ExportDialog';
import { ExportType, ExportFormat } from '../../../../src/utils/exportUtils/exportUtils';
import { createTestClient, mkStubRoom } from '../../../test-utils';

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../../../skinned-sdk";
import React from "react";
import { mount } from "enzyme";
import { act } from "react-dom/test-utils";

View file

@ -20,8 +20,6 @@ import { jest } from "@jest/globals";
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixWidgetType } from "matrix-widget-api";
// We can't use the usual `skinned-sdk`, as it stubs out the RightPanel
import "../../../minimal-sdk";
import RightPanel from "../../../../src/components/structures/RightPanel";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import ResizeNotifier from "../../../../src/utils/ResizeNotifier";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import '../../../skinned-sdk';
import { Direction, mouseWithinRegion } from "../../../../src/components/views/elements/InteractiveTooltip";
describe("InteractiveTooltip", () => {

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// skinned-sdk should be the first import in most tests
import '../../../skinned-sdk';
import React from "react";
import { mount, ReactWrapper } from "enzyme";
import { Room } from "matrix-js-sdk/src/models/room";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../../../skinned-sdk";
import * as testUtils from '../../../test-utils';
import { getParentEventId } from "../../../../src/utils/Reply";

View file

@ -13,7 +13,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import "../../../skinned-sdk";
import React from 'react';
import { mount } from 'enzyme';

View file

@ -1,5 +1,3 @@
// skinned-sdk should be the first import in most tests
import '../../../skinned-sdk';
import React from "react";
import {
renderIntoDocument,

View file

@ -23,7 +23,6 @@ import { MatrixClient } from 'matrix-js-sdk/src/client';
import { mocked } from 'jest-mock';
import { logger } from 'matrix-js-sdk/src/logger';
import "../../../skinned-sdk"; // Must be first for skinning to work
import LocationPicker from "../../../../src/components/views/location/LocationPicker";
import { LocationShareType } from "../../../../src/components/views/location/shareLocation";
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';

View file

@ -24,7 +24,6 @@ import { M_BEACON_INFO } from 'matrix-js-sdk/src/@types/beacon';
import { M_ASSET, LocationAssetType } from 'matrix-js-sdk/src/@types/location';
import { logger } from 'matrix-js-sdk/src/logger';
import '../../../skinned-sdk';
import LocationShareMenu from '../../../../src/components/views/location/LocationShareMenu';
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';
import { ChevronFace } from '../../../../src/components/structures/ContextMenu';

View file

@ -1,4 +1,3 @@
import '../../../skinned-sdk'; // Must be first for skinning to work
import React from 'react';
import TestRenderer from 'react-test-renderer';
import { EventEmitter } from 'events';

View file

@ -21,7 +21,6 @@ import { act } from "react-dom/test-utils";
import { Room, User, MatrixClient } from 'matrix-js-sdk/src/matrix';
import { Phase, VerificationRequest } from 'matrix-js-sdk/src/crypto/verification/request/VerificationRequest';
import "../../../skinned-sdk";
import UserInfo from '../../../../src/components/views/right_panel/UserInfo';
import { RightPanelPhases } from '../../../../src/stores/right-panel/RightPanelStorePhases';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';

View file

@ -14,8 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../../../skinned-sdk";
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import ReactDOM from 'react-dom';

View file

@ -2,7 +2,6 @@ import React from 'react';
import { mount, ReactWrapper } from 'enzyme';
import { Room, PendingEventOrdering, MatrixEvent, MatrixClient } from 'matrix-js-sdk/src/matrix';
import "../../../skinned-sdk";
import * as TestUtils from '../../../test-utils';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import DMRoomMap from '../../../../src/utils/DMRoomMap';

View file

@ -23,7 +23,6 @@ import {
} from 'react-dom/test-utils';
import { Room, RoomMember, MatrixError, IContent } from 'matrix-js-sdk/src/matrix';
import "../../../skinned-sdk";
import { stubClient } from '../../../test-utils';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import DMRoomMap from '../../../../src/utils/DMRoomMap';

View file

@ -20,7 +20,6 @@ import { sleep } from "matrix-js-sdk/src/utils";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { mount } from 'enzyme';
import '../../../skinned-sdk'; // Must be first for skinning to work
import SendMessageComposer, {
createMessageContent,
isQuickReaction,

View file

@ -1,5 +1,3 @@
import '../../../skinned-sdk';
import React, { ReactElement } from 'react';
import ReactDOM from 'react-dom';
import { MatrixClient } from 'matrix-js-sdk/src/matrix';

View file

@ -17,7 +17,6 @@ limitations under the License.
import React from 'react';
import { mount } from "enzyme";
import '../../../skinned-sdk';
import * as TestUtils from "../../../test-utils";
import FontScalingPanel from '../../../../src/components/views/settings/FontScalingPanel';

View file

@ -14,7 +14,6 @@ limitations under the License.
import React from 'react';
import { mount } from 'enzyme';
import '../../../skinned-sdk';
import { IPushRule, IPushRules, RuleId, IPusher } from 'matrix-js-sdk/src/matrix';
import { IThreepid, ThreepidMedium } from 'matrix-js-sdk/src/@types/threepids';
import { act } from 'react-dom/test-utils';

View file

@ -17,7 +17,6 @@ limitations under the License.
import React from 'react';
import { mount } from "enzyme";
import '../../../skinned-sdk';
import * as TestUtils from "../../../test-utils";
import ThemeChoicePanel from '../../../../src/components/views/settings/ThemeChoicePanel';

View file

@ -19,7 +19,6 @@ import { mount } from 'enzyme';
import { mocked } from 'jest-mock';
import { act } from 'react-dom/test-utils';
import '../../../skinned-sdk';
import QuickThemeSwitcher from '../../../../src/components/views/spaces/QuickThemeSwitcher';
import { getOrderedThemes } from '../../../../src/theme';
import ThemeChoicePanel from '../../../../src/components/views/settings/ThemeChoicePanel';

View file

@ -20,7 +20,6 @@ import { mocked } from 'jest-mock';
import { MatrixClient } from 'matrix-js-sdk/src/matrix';
import { act } from "react-dom/test-utils";
import '../../../skinned-sdk';
import SpacePanel from '../../../../src/components/views/spaces/SpacePanel';
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
import { SpaceKey } from '../../../../src/stores/spaces';

View file

@ -1,5 +1,3 @@
// skinned-sdk should be the first import in most tests
import '../../../skinned-sdk';
import React from "react";
import { mocked } from 'jest-mock';
import {

View file

@ -1,4 +1,3 @@
import './skinned-sdk'; // Must be first for skinning to work
import { EventEmitter } from 'events';
import { waitForMember, canEncryptToAllUsers } from '../src/createRoom';

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import { getLineAndNodePosition } from "../../src/editor/caret";
import EditorModel from "../../src/editor/model";
import { createPartCreator } from "./mock";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import '../skinned-sdk'; // Must be first for skinning to work
import { parseEvent } from "../../src/editor/deserialize";
import { createPartCreator } from "./mock";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import EditorModel from "../../src/editor/model";
import { createPartCreator, createRenderer } from "./mock";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import EditorModel from "../../src/editor/model";
import { createPartCreator, createRenderer } from "./mock";
import {

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import EditorModel from "../../src/editor/model";
import { createPartCreator } from "./mock";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import EditorModel from "../../src/editor/model";
import { createPartCreator, createRenderer } from "./mock";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import EditorModel from "../../src/editor/model";
import { htmlSerializeIfNeeded } from "../../src/editor/serialize";
import { createPartCreator } from "./mock";

View file

@ -1,29 +0,0 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
* minimal-sdk.js
*
* Starts up the skin system with even less than `skinned-sdk`.
*/
import * as sdk from "../src/index";
const components = {};
// sdk.loadSkin({ components });
export default sdk;

View file

@ -1,28 +0,0 @@
/*
* skinned-sdk.js
*
* Skins the react-sdk with a few stub components which we expect the
* application to provide
*/
/* this is a convenient place to ensure we load the compatibility libraries we expect our
* app to provide
*/
import * as sdk from "../src/index";
import stubComponent from "./components/stub-component";
const components = {};
components['structures.LeftPanel'] = stubComponent();
components['structures.RightPanel'] = stubComponent();
components['structures.RoomDirectory'] = stubComponent();
components['views.globals.GuestWarningBar'] = stubComponent();
components['views.globals.NewVersionBar'] = stubComponent();
components['views.elements.Spinner'] = stubComponent({ displayName: 'Spinner' });
components['views.messages.MessageTimestamp'] = stubComponent({ displayName: 'MessageTimestamp' });
components['views.messages.SenderProfile'] = stubComponent({ displayName: 'SenderProfile' });
components['views.rooms.SearchBar'] = stubComponent();
// sdk.loadSkin({ components });
export default sdk;

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import '../skinned-sdk'; // Must be first for skinning to work
import RoomViewStore from '../../src/stores/RoomViewStore';
import { Action } from '../../src/dispatcher/actions';
import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg';

View file

@ -21,7 +21,6 @@ import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
import { defer } from "matrix-js-sdk/src/utils";
import { ClientEvent, RoomEvent, MatrixEvent } from 'matrix-js-sdk/src/matrix';
import "../skinned-sdk"; // Must be first for skinning to work
import SpaceStore from "../../src/stores/spaces/SpaceStore";
import {
MetaSpace,

View file

@ -16,7 +16,6 @@ limitations under the License.
import { ClientWidgetApi, MatrixWidgetType } from "matrix-widget-api";
import "../skinned-sdk";
import { stubClient } from "../test-utils";
import WidgetStore from "../../src/stores/WidgetStore";
import { WidgetMessagingStore } from "../../src/stores/widgets/WidgetMessagingStore";

View file

@ -17,7 +17,6 @@ limitations under the License.
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import "../skinned-sdk"; // Must be first for skinning to work
import { VoiceRecording } from '../../src/audio/VoiceRecording';
import { VoiceRecordingStore } from '../../src/stores/VoiceRecordingStore';
import { MatrixClientPeg } from "../../src/MatrixClientPeg";

View file

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import "../skinned-sdk"; // Must be first for skinning to work
import { Room } from "matrix-js-sdk/src/matrix";
import WidgetStore, { IApp } from "../../src/stores/WidgetStore";

View file

@ -17,7 +17,6 @@ limitations under the License.
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixEventEvent, MatrixEvent } from "matrix-js-sdk/src/matrix";
import "../../skinned-sdk";
import { stubClient } from "../../test-utils";
import { MatrixClientPeg } from "../../../src/MatrixClientPeg";
import { RoomNotificationState } from "../../../src/stores/notifications/RoomNotificationState";

View file

@ -15,7 +15,6 @@ limitations under the License.
*/
import { mocked } from 'jest-mock';
import "../../skinned-sdk"; // Must be first for skinning to work
import { SpaceWatcher } from "../../../src/stores/room-list/SpaceWatcher";
import type { RoomListStoreClass } from "../../../src/stores/room-list/RoomListStore";
import SettingsStore from "../../../src/settings/SettingsStore";

View file

@ -27,7 +27,6 @@ import {
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
import { IExportOptions, ExportType, ExportFormat } from "../../src/utils/exportUtils/exportUtils";
import '../skinned-sdk';
import PlainTextExporter from "../../src/utils/exportUtils/PlainTextExport";
import HTMLExporter from "../../src/utils/exportUtils/HtmlExport";
import * as TestUtilsMatrix from '../test-utils';