@netless/window-manager 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/AppListener.d.ts +0 -1
  2. package/dist/AppManager.d.ts +8 -8
  3. package/dist/Base/Context.d.ts +0 -2
  4. package/dist/BoxManager.d.ts +0 -1
  5. package/dist/Cursor/Cursor.d.ts +1 -0
  6. package/dist/Cursor/index.d.ts +2 -1
  7. package/dist/index.es.js +1 -1
  8. package/dist/index.es.js.map +1 -1
  9. package/dist/index.umd.js +1 -1
  10. package/dist/index.umd.js.map +1 -1
  11. package/dist/typings.d.ts +1 -0
  12. package/package.json +2 -2
  13. package/src/AppContext.ts +1 -1
  14. package/src/AppListener.ts +0 -8
  15. package/src/AppManager.ts +42 -93
  16. package/src/AppProxy.ts +1 -0
  17. package/src/Base/Context.ts +1 -6
  18. package/src/BoxManager.ts +0 -8
  19. package/src/Cursor/Cursor.ts +8 -4
  20. package/src/Cursor/index.ts +15 -14
  21. package/src/index.ts +3 -2
  22. package/src/typings.ts +1 -0
  23. package/src/viewManager.ts +1 -1
  24. package/e2e/cypress/integration/index.spec.ts +0 -105
  25. package/e2e/cypress/integration/readonly.spec.ts +0 -26
  26. package/e2e/cypress/plugins/index.js +0 -22
  27. package/e2e/cypress/support/commands.js +0 -25
  28. package/e2e/cypress/support/index.js +0 -20
  29. package/e2e/cypress.json +0 -6
  30. package/e2e/package.json +0 -15
  31. package/example/.env +0 -4
  32. package/example/babel.config.js +0 -15
  33. package/example/dist/assets/css/chunk-vendors.d2fb6693.chunk.css +0 -1
  34. package/example/dist/assets/css/index.12f29b9a.chunk.css +0 -1
  35. package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js +0 -2
  36. package/example/dist/assets/js/chunk-vendors.d2fb6693.chunk.js.LICENSE.txt +0 -136
  37. package/example/dist/assets/js/index.12f29b9a.chunk.js +0 -1
  38. package/example/dist/assets/js/runtime~index.d502de40.js +0 -1
  39. package/example/dist/index.html +0 -1
  40. package/example/index.html +0 -13
  41. package/example/index.tsx +0 -368
  42. package/example/package.json +0 -23
  43. package/example/poi.config.js +0 -12
  44. package/example/test.js +0 -114
package/dist/typings.d.ts CHANGED
@@ -56,6 +56,7 @@ export declare type RegisterEvents<SetupResult = any> = {
56
56
  result: SetupResult;
57
57
  };
58
58
  destroy: RegisterEventData;
59
+ focus: RegisterEventData;
59
60
  };
60
61
  export declare type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
61
62
  kind: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/window-manager",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "",
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",
@@ -56,6 +56,6 @@
56
56
  "typescript": "^4.3.5",
57
57
  "video.js": "^7.14.3",
58
58
  "vite": "^2.5.3",
59
- "white-web-sdk": "^2.15.1"
59
+ "white-web-sdk": "2.15.6"
60
60
  }
61
61
  }
package/src/AppContext.ts CHANGED
@@ -102,7 +102,7 @@ export class AppContext<TAttrs extends Record<string, any>, AppOptions = any> {
102
102
  public async setScenePath(scenePath: string): Promise<void> {
103
103
  if (!this.appProxy.box) return;
104
104
  this.appProxy.setFullPath(scenePath);
105
- this.manager.viewManager.switchAppToWriter(this.appId);
105
+ this.appProxy.context.switchAppToWriter(this.appId);
106
106
  }
107
107
 
108
108
  public mountView(dom: HTMLDivElement): void {
@@ -28,10 +28,6 @@ export class AppListeners {
28
28
  this.appResizeHandler(data.payload);
29
29
  break;
30
30
  }
31
- case Events.AppBoxStateChange: {
32
- this.appBoxStateHandler(data.payload);
33
- break;
34
- }
35
31
  case Events.SwitchViewsToFreedom: {
36
32
  this.switchViewsToFreedomHandler();
37
33
  break;
@@ -51,10 +47,6 @@ export class AppListeners {
51
47
  this.manager.room?.refreshViewSize();
52
48
  };
53
49
 
54
- private appBoxStateHandler = (payload: any) => {
55
- this.boxManager.setBoxState(payload.state);
56
- };
57
-
58
50
  private switchViewsToFreedomHandler = () => {
59
51
  this.manager.viewManager.freedomAllViews();
60
52
  };
package/src/AppManager.ts CHANGED
@@ -1,31 +1,20 @@
1
- import {
2
- AppAttributes,
3
- AppStatus,
4
- Events,
5
- MagixEventName
6
- } from './constants';
7
- import { AppListeners } from './AppListener';
8
- import { AppProxy } from './AppProxy';
9
- import { AttributesDelegate } from './AttributesDelegate';
10
- import { BoxManager, TELE_BOX_STATE } from './BoxManager';
11
- import { callbacks, emitter } from './index';
12
- import { CameraStore } from './Utils/CameraStore';
13
- import { genAppId, makeValidScenePath, setScenePath } from './Utils/Common';
14
- import {
15
- autorun,
16
- isPlayer,
17
- isRoom,
18
- ScenePathType,
19
- ViewVisionMode
20
- } from 'white-web-sdk';
21
- import { log } from './Utils/log';
22
- import { MainViewProxy } from './MainView';
23
- import { onObjectInserted, onObjectRemoved } from './Utils/Reactive';
24
- import { ReconnectRefresher } from './ReconnectRefresher';
25
- import { ViewManager } from './ViewManager';
1
+ import { AppAttributes, AppStatus, Events, MagixEventName } from "./constants";
2
+ import { AppListeners } from "./AppListener";
3
+ import { AppProxy } from "./AppProxy";
4
+ import { AttributesDelegate } from "./AttributesDelegate";
5
+ import { BoxManager, TELE_BOX_STATE } from "./BoxManager";
6
+ import { callbacks, emitter } from "./index";
7
+ import { CameraStore } from "./Utils/CameraStore";
8
+ import { genAppId, makeValidScenePath, setScenePath } from "./Utils/Common";
9
+ import { autorun, isPlayer, isRoom, ScenePathType, ViewVisionMode } from "white-web-sdk";
10
+ import { log } from "./Utils/log";
11
+ import { MainViewProxy } from "./MainView";
12
+ import { onObjectInserted, onObjectRemoved } from "./Utils/Reactive";
13
+ import { ReconnectRefresher } from "./ReconnectRefresher";
14
+ import { ViewManager } from "./ViewManager";
26
15
  import type { Displayer, DisplayerState, Room } from "white-web-sdk";
27
16
  import type { CreateCollectorConfig } from "./BoxManager";
28
- import type { AddAppParams, BaseInsertParams, WindowManager , TeleBoxRect } from "./index";
17
+ import type { AddAppParams, BaseInsertParams, WindowManager, TeleBoxRect } from "./index";
29
18
  export class AppManager {
30
19
  public displayer: Displayer;
31
20
  public boxManager: BoxManager;
@@ -39,7 +28,6 @@ export class AppManager {
39
28
 
40
29
  private appListeners: AppListeners;
41
30
 
42
-
43
31
  constructor(public windowManger: WindowManager, options: CreateCollectorConfig) {
44
32
  this.displayer = windowManger.displayer;
45
33
  this.cameraStore = new CameraStore();
@@ -78,24 +66,30 @@ export class AppManager {
78
66
  });
79
67
  });
80
68
  this.refresher?.add("maximized", () => {
81
- return autorun(
82
- () => {
83
- const maximized = this.attributes.maximized;
84
- if (this.boxManager.maximized !== maximized) {
85
- this.boxManager.setMaximized(Boolean(maximized));
69
+ return autorun(() => {
70
+ const maximized = this.attributes.maximized;
71
+ if (this.boxManager.maximized !== maximized) {
72
+ if (maximized === true && this.boxManager.minimized === false) {
73
+ const topBox = this.boxManager.getTopBox();
74
+ if (topBox) {
75
+ emitter.emit("focus", { appId: topBox.id });
76
+ }
86
77
  }
78
+ this.boxManager.setMaximized(Boolean(maximized));
87
79
  }
88
- )
80
+ });
89
81
  });
90
82
  this.refresher?.add("minimized", () => {
91
- return autorun(
92
- () => {
93
- const minimized = this.attributes.minimized;
94
- if (this.boxManager.minimized !== minimized) {
95
- this.boxManager.setMinimized(Boolean(minimized));
83
+ return autorun(() => {
84
+ const minimized = this.attributes.minimized;
85
+ if (this.boxManager.minimized !== minimized) {
86
+ if (minimized === true && this.store.focus !== undefined) {
87
+ this.store.cleanFocus();
88
+ this.boxManager.blurFocusBox();
96
89
  }
90
+ this.boxManager.setMinimized(Boolean(minimized));
97
91
  }
98
- )
92
+ });
99
93
  });
100
94
  if (!this.attributes.apps || Object.keys(this.attributes.apps).length === 0) {
101
95
  const mainScenePath = this.store.getMainViewScenePath();
@@ -142,7 +136,7 @@ export class AppManager {
142
136
  appProxy.destroy(true, false);
143
137
  }
144
138
  });
145
- }
139
+ };
146
140
 
147
141
  public bindMainView(divElement: HTMLDivElement, disableCameraTransform: boolean) {
148
142
  const mainView = this.mainViewProxy.view;
@@ -151,10 +145,7 @@ export class AppManager {
151
145
  if (!mainView.focusScenePath) {
152
146
  this.store.setMainViewFocusPath();
153
147
  }
154
- if (
155
- this.store.focus === undefined &&
156
- mainView.mode !== ViewVisionMode.Writable
157
- ) {
148
+ if (this.store.focus === undefined && mainView.mode !== ViewVisionMode.Writable) {
158
149
  this.viewManager.switchMainViewToWriter();
159
150
  }
160
151
  this.mainViewProxy.addMainViewListener();
@@ -172,16 +163,16 @@ export class AppManager {
172
163
  private async beforeAddApp(params: AddAppParams, isDynamicPPT: boolean) {
173
164
  const appId = await genAppId(params.kind);
174
165
  this.appStatus.set(appId, AppStatus.StartCreate);
166
+ const attrs = params.attributes ?? {};
167
+ this.safeUpdateAttributes([appId], attrs);
175
168
  this.store.setupAppAttributes(params, appId, isDynamicPPT);
176
- if (this.boxManager.boxState === TELE_BOX_STATE.Minimized) {
177
- this.boxManager.setBoxState(TELE_BOX_STATE.Normal);
169
+ if (this.boxManager.minimized) {
170
+ this.boxManager.setMinimized(false);
178
171
  }
179
- const needFocus = this.boxManager.boxState !== TELE_BOX_STATE.Minimized;
172
+ const needFocus = !this.boxManager.minimized;
180
173
  if (needFocus) {
181
174
  this.store.setAppFocus(appId, true);
182
175
  }
183
- const attrs = params.attributes ?? {};
184
- this.safeUpdateAttributes([appId], attrs);
185
176
  return { appId, needFocus };
186
177
  }
187
178
 
@@ -243,7 +234,7 @@ export class AppManager {
243
234
  appProxy.appEmitter.emit("roomStateChange", state);
244
235
  });
245
236
  emitter.emit("observerIdChange", this.displayer.observerId);
246
- }
237
+ };
247
238
 
248
239
  private displayerWritableListener = (isReadonly: boolean) => {
249
240
  const isWritable = !isReadonly;
@@ -265,7 +256,7 @@ export class AppManager {
265
256
  } else {
266
257
  this.mainView.disableCameraTransform = true;
267
258
  }
268
- }
259
+ };
269
260
 
270
261
  private get eventName() {
271
262
  return isRoom(this.displayer) ? "onRoomStateChanged" : "onPlayerStateChanged";
@@ -359,10 +350,6 @@ export class AppManager {
359
350
  this.windowManger.safeSetAttributes({ focus: payload.appId });
360
351
  break;
361
352
  }
362
- case "blur": {
363
- this.dispatchInternalEvent(Events.AppBlur, payload);
364
- break;
365
- }
366
353
  case "resize": {
367
354
  if (payload.width && payload.height) {
368
355
  this.dispatchInternalEvent(Events.AppResize, payload);
@@ -373,44 +360,6 @@ export class AppManager {
373
360
  }
374
361
  break;
375
362
  }
376
- case TELE_BOX_STATE.Minimized: {
377
- this.safeDispatchMagixEvent(MagixEventName, {
378
- eventName: Events.AppBoxStateChange,
379
- payload: {
380
- ...payload,
381
- state: eventName,
382
- },
383
- });
384
-
385
- this.store.cleanFocus();
386
- this.boxManager.blurFocusBox();
387
- break;
388
- }
389
- case TELE_BOX_STATE.Maximized: {
390
- this.safeDispatchMagixEvent(MagixEventName, {
391
- eventName: Events.AppBoxStateChange,
392
- payload: {
393
- ...payload,
394
- state: eventName,
395
- },
396
- });
397
- const topBox = this.boxManager.getTopBox();
398
- if (topBox) {
399
- emitter.emit("focus", { appId: topBox.id });
400
- }
401
- break;
402
- }
403
- case TELE_BOX_STATE.Normal: {
404
- this.safeDispatchMagixEvent(MagixEventName, {
405
- eventName: Events.AppBoxStateChange,
406
- payload: {
407
- ...payload,
408
- state: eventName,
409
- },
410
- });
411
- this.safeSetAttributes({ boxState: eventName });
412
- break;
413
- }
414
363
  case "close": {
415
364
  const appProxy = this.appProxies.get(payload.appId);
416
365
  if (appProxy) {
package/src/AppProxy.ts CHANGED
@@ -211,6 +211,7 @@ export class AppProxy extends Base {
211
211
  }
212
212
 
213
213
  public switchToWritable() {
214
+ appRegister.notifyApp(this.kind, "focus", { appId: this.id });
214
215
  this.cameraStore.switchView(this.id, this.view, () => {
215
216
  if (this.view) {
216
217
  if (this.view.mode === ViewVisionMode.Writable) return;
@@ -1,4 +1,3 @@
1
- import { memoize } from "lodash";
2
1
  import { emitter } from "../index";
3
2
  import type { AppManager } from "../AppManager";
4
3
 
@@ -14,7 +13,7 @@ export class Context {
14
13
  };
15
14
 
16
15
  public get uid() {
17
- return this.findMember(this.observerId)?.payload?.uid || "";
16
+ return this.manager.room?.uid || "";
18
17
  }
19
18
 
20
19
  public findMember = (memberId: number) => {
@@ -27,10 +26,6 @@ export class Context {
27
26
  return roomMembers?.find(member => member.payload?.uid === uid);
28
27
  }
29
28
 
30
- public memoizeFindMember = memoize(this.findMember);
31
-
32
- public memoizeFindMemberByUid = memoize(this.findMemberByUid);
33
-
34
29
  public updateManagerRect() {
35
30
  this.manager.boxManager.updateManagerRect();
36
31
  }
package/src/BoxManager.ts CHANGED
@@ -225,9 +225,6 @@ export class BoxManager {
225
225
  this.teleBoxManager.setMaximized(Boolean(state.maximized), true);
226
226
  this.teleBoxManager.setMinimized(Boolean(state.minimized), true);
227
227
  }
228
- if (state.boxState) {
229
- this.teleBoxManager.setState(state.boxState, true);
230
- }
231
228
  setTimeout(() => {
232
229
  if (state.focus) {
233
230
  this.teleBoxManager.update(box.id, { focus: true }, true);
@@ -289,11 +286,6 @@ export class BoxManager {
289
286
  this.teleBoxManager.updateAll(config);
290
287
  }
291
288
 
292
- public setBoxState(state: TELE_BOX_STATE): void {
293
- this.teleBoxManager.setState(state, true);
294
- callbacks.emit("boxStateChange", state);
295
- }
296
-
297
289
  public setMaximized(maximized: boolean) {
298
290
  this.teleBoxManager.setMaximized(maximized, true);
299
291
  }
@@ -36,7 +36,7 @@ export class Cursor extends Base {
36
36
  pRetry(() => {
37
37
  this.disposer && this.disposer();
38
38
  if (!this.cursorPosition) {
39
- throw new Error();
39
+ console.warn(`${memberId} not exist`);
40
40
  }
41
41
  this.startReaction();
42
42
  }, { retries: 3 });
@@ -142,7 +142,7 @@ export class Cursor extends Base {
142
142
  }
143
143
  this.timer = window.setTimeout(() => {
144
144
  this.hide();
145
- this.store.updateCursorState(this.context.uid, CursorState.Leave);
145
+ this.store.updateCursorState(this.memberId, CursorState.Leave);
146
146
  }, 1000 * 10); // 10 秒钟自动隐藏
147
147
  }
148
148
 
@@ -180,8 +180,12 @@ export class Cursor extends Base {
180
180
  }
181
181
 
182
182
  public setMember() {
183
- this.member = this.context.memoizeFindMemberByUid(this.memberId);
184
- this.component?.$set(omit(this.initProps(), ["x", "y", "visible"]));
183
+ this.member = this.context.findMemberByUid(this.memberId);
184
+ this.updateComponent();
185
+ }
186
+
187
+ private updateComponent() {
188
+ this.component?.$set(omit(this.initProps(), ["x", "y"]));
185
189
  }
186
190
 
187
191
  public destroy() {
@@ -1,7 +1,7 @@
1
1
  import { Base } from '../Base';
2
2
  import { Cursor } from './Cursor';
3
3
  import { CursorState } from '../constants';
4
- import { debounce } from 'lodash';
4
+ import { compact, debounce, uniq } from 'lodash';
5
5
  import { Fields } from '../AttributesDelegate';
6
6
  import { onObjectInserted } from '../Utils/Reactive';
7
7
  import { WindowManager } from '../index';
@@ -54,8 +54,12 @@ export class CursorManager extends Base {
54
54
  })
55
55
  }
56
56
 
57
+ private getUids = (members: readonly RoomMember[] | undefined) => {
58
+ return compact(uniq(members?.map(member => member.payload?.uid)));
59
+ }
60
+
57
61
  private handleRoomMembersChange = debounce((wrapper: HTMLElement) => {
58
- const uids = this.roomMembers?.map(member => member.payload?.uid);
62
+ const uids = this.getUids(this.roomMembers);
59
63
  const cursors = Object.keys(this.cursors);
60
64
  if (uids?.length) {
61
65
  cursors.map(uid => {
@@ -183,7 +187,7 @@ export class CursorManager extends Base {
183
187
  }
184
188
  }
185
189
 
186
- public cleanMemberCursor(uid: string) {
190
+ public deleteCursor(uid: string) {
187
191
  this.store.cleanCursor(uid);
188
192
  const cursor = this.cursorInstances.get(uid);
189
193
  if (cursor) {
@@ -199,20 +203,17 @@ export class CursorManager extends Base {
199
203
  }
200
204
 
201
205
  public cleanMemberAttributes(members: readonly RoomMember[]) {
202
- const uids = members.map(member => member.payload?.uid);
203
- const needDeleteIds = [];
204
- for (const uid in this.cursors) {
205
- const index = uids.findIndex(id => id === uid);
206
+ const uids = this.getUids(members);
207
+ const needDeleteIds: string[] = [];
208
+ const cursors = Object.keys(this.cursors);
209
+ cursors.map(cursorId => {
210
+ const index = uids.findIndex(id => id === cursorId);
206
211
  if (index === -1) {
207
- needDeleteIds.push(uid);
212
+ needDeleteIds.push(cursorId);
208
213
  }
209
- }
214
+ });
210
215
  needDeleteIds.forEach(uid => {
211
- const instance = this.cursorInstances.get(uid);
212
- if (instance) {
213
- instance.destroy();
214
- }
215
- this.store.cleanCursor(uid);
216
+ this.deleteCursor(uid);
216
217
  });
217
218
  }
218
219
 
package/src/index.ts CHANGED
@@ -170,7 +170,7 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
170
170
  public static containerSizeRatio = DEFAULT_CONTAINER_RATIO;
171
171
  private static isCreated = false;
172
172
 
173
- public version = "0.3.3";
173
+ public version = "0.3.5";
174
174
 
175
175
  public appListeners?: AppListeners;
176
176
 
@@ -384,7 +384,8 @@ export class WindowManager extends InvisiblePlugin<WindowMangerAttributes> {
384
384
  if (!isValidScenePath(scenePath)) {
385
385
  throw new InvalidScenePath();
386
386
  }
387
- for (const appId in this.apps) {
387
+ const apps = Object.keys(this.apps || {});
388
+ for (const appId of apps) {
388
389
  const appScenePath = appManager.store.getAppScenePath(appId);
389
390
  if (appScenePath && appScenePath === scenePath) {
390
391
  console.warn(`[WindowManager]: ScenePath ${scenePath} Already opened`);
package/src/typings.ts CHANGED
@@ -59,6 +59,7 @@ export type RegisterEventData = {
59
59
  export type RegisterEvents<SetupResult = any> = {
60
60
  created: RegisterEventData & { result: SetupResult; };
61
61
  destroy: RegisterEventData;
62
+ focus: RegisterEventData;
62
63
  };
63
64
 
64
65
  export type RegisterParams<AppOptions = any, SetupResult = any, Attributes = any> = {
@@ -104,7 +104,7 @@ export class ViewManager extends Base {
104
104
  });
105
105
  if (this.mainView.mode === ViewVisionMode.Writable) {
106
106
  notifyMainViewModeChange(callbacks, ViewVisionMode.Freedom);
107
- this.mainView.mode = ViewVisionMode.Freedom;
107
+ setViewMode(this.mainView, ViewVisionMode.Freedom);
108
108
  }
109
109
  if (!this.mainView.focusScenePath) {
110
110
  this.store.setMainViewFocusPath();
@@ -1,105 +0,0 @@
1
- import { TELE_BOX_STATE } from "@netless/telebox-insider";
2
- import { RoomPhase, ViewVisionMode } from "white-web-sdk";
3
-
4
- describe("正常流程", () => {
5
- before(() => {
6
- cy.visit("/");
7
- cy.wait(8000);
8
- })
9
-
10
- afterEach(() => {
11
- cy.wait(1000)
12
- })
13
-
14
- it("挂载成功", () => {
15
- cy.window().then((window: any) => {
16
- const manager = window.manager;
17
- const room = window.room;
18
- expect(room).to.be.a("object");
19
- expect(room.phase).to.be.equal(RoomPhase.Connected);
20
- expect(manager).to.be.a("object");
21
- })
22
- })
23
-
24
- it("插入一个 APP", () => {
25
- cy.window().then(async (window: any) => {
26
- const manager = window.manager;
27
- const appId = await manager.addApp({
28
- kind: "HelloWorld",
29
- options: {
30
- scenePath: "/helloworld1"
31
- }
32
- });
33
- cy.wait(1000).then(() => {
34
- expect(appId).to.be.string;
35
- cy.get(".telebox-box").should("have.length", 1);
36
- expect(manager.queryAll().length).to.be.equal(1);
37
- })
38
- });
39
- })
40
-
41
- it("切换可写白板", () => {
42
- cy.window().then(async (window: any) => {
43
- const manager = window.manager;
44
- const apps = manager.queryAll();
45
- const app = apps[0];
46
- cy.get(".netless-window-manager-main-view").click({ force: true })
47
- cy.wait(1000).then(() => {
48
- expect(manager.mainView.mode).to.be.equal(ViewVisionMode.Writable);
49
- })
50
- cy.get(`[data-tele-box-i-d=${app.id}] .telebox-content-wrap`).click({ force: true });
51
- cy.wait(1000).then(() => {
52
- expect(app.view.mode).to.be.equal(ViewVisionMode.Writable);
53
- })
54
- });
55
- })
56
-
57
- it("最大化", () => {
58
- cy.window().then(async (window: any) => {
59
- const manager = window.manager;
60
- const apps = manager.queryAll();
61
- const app = apps[0];
62
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Normal);
63
- cy.get(`[data-tele-box-i-d=${app.id}] .telebox-titlebar-icon-maximize`).click({ force: true });
64
- cy.wait(500).then(() => {
65
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Maximized);
66
- });
67
- cy.get(`[data-tele-box-i-d=${app.id}] .telebox-titlebar-icon-maximize`).click({ force: true });
68
- cy.wait(500).then(() => {
69
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Normal);
70
- });
71
- })
72
- })
73
-
74
- it("最小化", () => {
75
- cy.window().then(async (window: any) => {
76
- const manager = window.manager;
77
- const apps = manager.queryAll();
78
- const app = apps[0];
79
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Normal);
80
- cy.get(`[data-tele-box-i-d=${app.id}] .telebox-titlebar-icon-minimize`).click({ force: true });
81
- cy.wait(500).then(() => {
82
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Minimized);
83
- cy.get(".telebox-collector.telebox-collector-visible").should("have.length", 1);
84
- });
85
- cy.get(`.telebox-collector.telebox-collector-visible`).click({ force: true });
86
- cy.wait(500).then(() => {
87
- expect(manager.boxState).to.be.equal(TELE_BOX_STATE.Normal);
88
- });
89
- })
90
- })
91
-
92
- it("删除所有 APP", () => {
93
- cy.window().then(async (window: any) => {
94
- const manager = window.manager;
95
- const apps = manager.queryAll();
96
- for (const app of apps) {
97
- await app.close();
98
- }
99
- expect(manager.queryAll().length).to.be.equal(0);
100
- cy.get(".telebox-box").should("have.length", 0);
101
- })
102
- })
103
- })
104
-
105
- export {};
@@ -1,26 +0,0 @@
1
- import { RoomPhase } from 'white-web-sdk';
2
- import type { Room} from "white-web-sdk";
3
-
4
- describe("只读模式加入房间", () => {
5
- before(() => {
6
- cy.visit("/?isWritable=false");
7
- cy.wait(8000);
8
- })
9
-
10
- afterEach(() => {
11
- cy.wait(1000)
12
- })
13
-
14
- it("挂载成功", () => {
15
- cy.window().then((window: any) => {
16
- const manager = window.manager;
17
- const room = window.room as Room;
18
- expect(room.phase).to.be.equal(RoomPhase.Connected);
19
- expect(manager).to.be.a("object");
20
- expect(room.isWritable).to.be.false;
21
- cy.get(".netless-whiteboard").should("have.length", 1);
22
- })
23
- })
24
- })
25
-
26
- export {};
@@ -1,22 +0,0 @@
1
- /// <reference types="cypress" />
2
- // ***********************************************************
3
- // This example plugins/index.js can be used to load plugins
4
- //
5
- // You can change the location of this file or turn off loading
6
- // the plugins file with the 'pluginsFile' configuration option.
7
- //
8
- // You can read more here:
9
- // https://on.cypress.io/plugins-guide
10
- // ***********************************************************
11
-
12
- // This function is called when a project is opened or re-opened (e.g. due to
13
- // the project's config changing)
14
-
15
- /**
16
- * @type {Cypress.PluginConfig}
17
- */
18
- // eslint-disable-next-line no-unused-vars
19
- module.exports = (on, config) => {
20
- // `on` is used to hook into various events Cypress emits
21
- // `config` is the resolved Cypress config
22
- }
@@ -1,25 +0,0 @@
1
- // ***********************************************
2
- // This example commands.js shows you how to
3
- // create various custom commands and overwrite
4
- // existing commands.
5
- //
6
- // For more comprehensive examples of custom
7
- // commands please read more here:
8
- // https://on.cypress.io/custom-commands
9
- // ***********************************************
10
- //
11
- //
12
- // -- This is a parent command --
13
- // Cypress.Commands.add('login', (email, password) => { ... })
14
- //
15
- //
16
- // -- This is a child command --
17
- // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
18
- //
19
- //
20
- // -- This is a dual command --
21
- // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
22
- //
23
- //
24
- // -- This will overwrite an existing command --
25
- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
@@ -1,20 +0,0 @@
1
- // ***********************************************************
2
- // This example support/index.js is processed and
3
- // loaded automatically before your test files.
4
- //
5
- // This is a great place to put global configuration and
6
- // behavior that modifies Cypress.
7
- //
8
- // You can change the location of this file or turn off
9
- // automatically serving support files with the
10
- // 'supportFile' configuration option.
11
- //
12
- // You can read more here:
13
- // https://on.cypress.io/configuration
14
- // ***********************************************************
15
-
16
- // Import commands.js using ES2015 syntax:
17
- import './commands'
18
-
19
- // Alternatively you can use CommonJS syntax:
20
- // require('./commands')