add integration tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen committed 2021-01-25 19:18:28 +02:00
1 parent add376510a
commit 02568443fd
12 files changed
+629 -551

No files matched your search

+13 -12
View File
@@ -17,33 +17,34 @@ export async function requestMain(channel: string, ...args: any[]) {
return ipcRenderer.invoke(channel, ...args);
}
async function getSubFrames(): Promise<ClusterFrameInfo[]> {
async function getSubFrames(processId: number): Promise<ClusterFrameInfo[]> {
const subFrames: ClusterFrameInfo[] = [];
clusterFrameMap.forEach(frameInfo => {
subFrames.push(frameInfo);
});
return subFrames;
return subFrames.filter(frame => frame.processId === processId);
}
export async function broadcastMessage(channel: string, ...args: any[]) {
let subFrames: ClusterFrameInfo[];
if (ipcRenderer) {
subFrames = await requestMain(subFramesChannel);
} else {
subFrames = await getSubFrames();
}
const views = (webContents || remote?.webContents)?.getAllWebContents();
if (!views) return;
views.forEach(webContent => {
views.forEach(async webContent => {
const type = webContent.getType();
logger.silly(`[IPC]: broadcasting "${channel}" to ${type}=${webContent.id}`, { args });
webContent.send(channel, ...args);
let subFrames: ClusterFrameInfo[];
if (ipcRenderer) {
subFrames = await requestMain(subFramesChannel, webContent.getProcessId());
} else {
subFrames = await getSubFrames(webContent.getProcessId());
}
subFrames.map((frameInfo) => {
webContent.sendToFrame([frameInfo.processId, frameInfo.frameId], channel, ...args);
});
@@ -83,7 +84,7 @@ export function unsubscribeAllFromBroadcast(channel: string) {
}
export function bindBroadcastHandlers() {
handleRequest(subFramesChannel, async () => {
return toJS(await getSubFrames(), { recurseEverything: true });
handleRequest(subFramesChannel, async (processId: number) => {
return toJS(await getSubFrames(processId), { recurseEverything: true });
});
}
+1
View File
@@ -243,6 +243,7 @@ export class WorkspaceStore extends BaseStore<WorkspaceStoreModel> {
throw new Error(`workspace ${id} doesn't exist`);
}
this.currentWorkspaceId = id;
clusterStore.setActive(null);
}
@action
@@ -36,6 +36,7 @@ export class AddWorkspace extends React.Component {
placeholder="Workspace name"
autoFocus={true}
theme="round-black"
data-test-id="command-palette-workspace-add-name"
validators={[uniqueWorkspaceName]}
onSubmit={(v) => this.onSubmit(v)}
dirty={true}
@@ -58,6 +58,7 @@ export class RemoveWorkspace extends React.Component {
options={this.options}
autoFocus={true}
escapeClearsValue={false}
data-test-id="command-palette-workspace-remove-select"
placeholder="Remove workspace" />
);
}
@@ -17,9 +17,9 @@ export class BottomBar extends React.Component {
return (
<div className="BottomBar flex gaps">
<div id="current-workspace" className="flex gaps align-center" onClick={() => CommandOverlay.open(<ChooseWorkspace />)}>
<div id="current-workspace" data-test-id="current-workspace" className="flex gaps align-center" onClick={() => CommandOverlay.open(<ChooseWorkspace />)}>
<Icon smallest material="layers"/>
<span className="workspace-name">{currentWorkspace.name}</span>
<span className="workspace-name" data-test-id="current-workspace-name">{currentWorkspace.name}</span>
</div>
<div className="extensions box grow flex gaps justify-flex-end">
{Array.isArray(items) && items.map(({ item }, index) => {
@@ -74,6 +74,7 @@ export class CommandDialog extends React.Component {
options={this.options}
autoFocus={true}
escapeClearsValue={false}
data-test-id="command-palette-search"
placeholder="" />
);
}