@dxos/react-ui 0.1.36-next.ef27157 → 0.1.37-next.801214f

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.
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { test } from '@playwright/test';
6
6
  import { expect } from 'chai';
7
+ import waitForExpect from 'wait-for-expect';
7
8
 
8
9
  import { sleep } from '@dxos/async';
9
10
  import { ConnectionState, Invitation } from '@dxos/protocols/proto/dxos/client/services';
@@ -32,8 +33,7 @@ test.describe('Invitations', () => {
32
33
  expect(await manager.getDisplayName(0)).to.equal(await manager.getDisplayName(1));
33
34
  });
34
35
 
35
- // TODO(wittjosiah): Auth method not hooked up?
36
- test.skip('no auth method', async () => {
36
+ test('no auth method', async () => {
37
37
  await manager.createIdentity(0);
38
38
  await manager.openPanel(0, 'devices');
39
39
  const invitation = await manager.createInvitation(0, 'device', { authMethod: Invitation.AuthMethod.NONE });
@@ -45,8 +45,7 @@ test.describe('Invitations', () => {
45
45
  expect(await manager.getDisplayName(0)).to.equal(await manager.getDisplayName(1));
46
46
  });
47
47
 
48
- // TODO(wittjosiah): Invalid auth code cannot retry.
49
- test.skip('invalid & retry auth code', async () => {
48
+ test('invalid & retry auth code', async () => {
50
49
  await manager.createIdentity(0);
51
50
  await manager.openPanel(0, 'devices');
52
51
  const invitation = await manager.createInvitation(0, 'device');
@@ -61,29 +60,63 @@ test.describe('Invitations', () => {
61
60
  expect(await manager.getDisplayName(0)).to.equal(await manager.getDisplayName(1));
62
61
  });
63
62
 
64
- // TODO(wittjosiah): Invalid auth code cannot retry.
65
- test.skip('invalid & max auth code retries reached, retry invitation', async () => {});
66
-
67
- // TODO(wittjosiah): Trigger timeout.
68
- test.skip('invitation timeout & retry', async () => {
63
+ test('invalid & max auth code retries reached, retry invitation', async () => {
69
64
  await manager.createIdentity(0);
70
65
  await manager.openPanel(0, 'devices');
71
- const invitation = await manager.createInvitation(0, 'device', { timeout: 100 });
66
+ const invitation = await manager.createInvitation(0, 'device');
72
67
 
73
68
  await manager.openPanel(1, 'identity');
74
- await sleep(100);
69
+ await manager.acceptInvitation(1, 'device', invitation);
75
70
 
76
- // TODO(wittjosiah): Retry here.
71
+ await manager.authenticateInvitation('device', '000001', manager.peer(1));
72
+ await manager.clearAuthCode('device', manager.peer(1));
73
+ await manager.authenticateInvitation('device', '000002', manager.peer(1));
74
+ await manager.clearAuthCode('device', manager.peer(1));
75
+ await manager.authenticateInvitation('device', '000003', manager.peer(1));
76
+
77
+ expect(await manager.invitationFailed(manager.peer(1))).to.be.true;
78
+
79
+ await manager.resetInvitation(manager.peer(1));
80
+ await manager.invitationInputContinue('device', manager.peer(1));
81
+
82
+ const [authCode] = await Promise.all([manager.getAuthCode(), manager.clearAuthCode('device', manager.peer(1))]);
77
83
 
78
- const [authCode] = await Promise.all([manager.getAuthCode(), manager.acceptInvitation(1, 'device', invitation)]);
79
84
  await manager.authenticateInvitation('device', authCode, manager.peer(1));
80
85
  await manager.doneInvitation('device', manager.peer(1));
81
86
 
82
87
  expect(await manager.getDisplayName(0)).to.equal(await manager.getDisplayName(1));
83
88
  });
84
89
 
85
- // TODO(wittjosiah): Propagate cancel to guest.
86
- test.skip('invitation cancelled by host', async () => {});
90
+ test('invitation timeout', async () => {
91
+ await manager.createIdentity(0);
92
+ await manager.openPanel(0, 'devices');
93
+ const invitation = await manager.createInvitation(0, 'device', { timeout: 10 });
94
+
95
+ await manager.openPanel(1, 'identity');
96
+ await manager.acceptInvitation(1, 'device', invitation);
97
+
98
+ // Wait for timeout to fire.
99
+ await waitForExpect(async () => {
100
+ expect(await manager.invitationFailed(manager.peer(1))).to.be.true;
101
+ }, 100);
102
+ });
103
+
104
+ test('invitation cancelled by host', async () => {
105
+ await manager.createIdentity(0);
106
+ await manager.openPanel(0, 'devices');
107
+ const invitation = await manager.createInvitation(0, 'device');
108
+
109
+ await manager.openPanel(1, 'identity');
110
+ await manager.acceptInvitation(1, 'device', invitation);
111
+ // Wait for invitation to connect before cancelling it.
112
+ await sleep(100);
113
+ await manager.cancelInvitation('device', 'host', manager.peer(0));
114
+
115
+ // Wait for cancellation to propagate.
116
+ await waitForExpect(async () => {
117
+ expect(await manager.invitationFailed(manager.peer(1))).to.be.true;
118
+ }, 100);
119
+ });
87
120
 
88
121
  test('invitation cancelled by guest & retry', async () => {
89
122
  await manager.createIdentity(0);
@@ -102,8 +135,7 @@ test.describe('Invitations', () => {
102
135
  expect(await manager.getDisplayName(0)).to.equal(await manager.getDisplayName(1));
103
136
  });
104
137
 
105
- // TODO(wittjosiah): Propagating network failure is flaky.
106
- test.skip('recover from network failure during invitation', async () => {
138
+ test('recover from network failure during invitation', async () => {
107
139
  await manager.createIdentity(0);
108
140
  await manager.openPanel(0, 'devices');
109
141
  const invitation = await manager.createInvitation(0, 'device');
@@ -114,6 +146,8 @@ test.describe('Invitations', () => {
114
146
  await manager.setConnectionState(0, ConnectionState.OFFLINE);
115
147
  await sleep(100);
116
148
  await manager.setConnectionState(0, ConnectionState.ONLINE);
149
+ // TODO(wittjosiah): Requires attempting an action to discover the network failure.
150
+ await manager.authenticateInvitation('device', '00000', manager.peer(1));
117
151
  await manager.resetInvitation(manager.peer(1));
118
152
  await manager.invitationInputContinue('device', manager.peer(1));
119
153
  const [authCode] = await Promise.all([manager.getAuthCode(), manager.clearAuthCode('device', manager.peer(1))]);
@@ -235,29 +269,40 @@ test.describe('Invitations', () => {
235
269
  expect(await manager.getSpaceName(0, 0)).to.equal(await manager.getSpaceName(1, 0));
236
270
  });
237
271
 
238
- // TODO(wittjosiah): Trigger timeout.
239
- test.skip('invitation timeout & retry', async () => {
272
+ test('invitation timeout', async () => {
240
273
  await manager.createIdentity(0);
241
274
  await manager.createSpace(0);
242
275
  await manager.openPanel(0, 0);
243
- const invitation = await manager.createInvitation(0, 'space', { timeout: 100 });
276
+ const invitation = await manager.createInvitation(0, 'space', { timeout: 10 });
244
277
 
245
278
  await manager.createIdentity(1);
246
279
  await manager.openPanel(1, 'join');
247
- await sleep(100);
280
+ await manager.acceptInvitation(1, 'space', invitation);
248
281
 
249
- // TODO(wittjosiah): Retry here.
282
+ // Wait for timeout to fire.
283
+ await waitForExpect(async () => {
284
+ expect(await manager.invitationFailed(manager.peer(1))).to.be.true;
285
+ }, 100);
286
+ });
250
287
 
251
- const [authCode] = await Promise.all([manager.getAuthCode(), manager.acceptInvitation(1, 'space', invitation)]);
252
- await manager.authenticateInvitation('space', authCode, manager.peer(1));
253
- await manager.doneInvitation('space', manager.peer(1));
288
+ test('invitation cancelled by host', async () => {
289
+ await manager.createIdentity(0);
290
+ await manager.createSpace(0);
291
+ await manager.openPanel(0, 0);
292
+ const invitation = await manager.createInvitation(0, 'space');
254
293
 
255
- await manager.openPanel(0, 'spaces');
256
- expect(await manager.getSpaceName(0, 0)).to.equal(await manager.getSpaceName(1, 0));
257
- });
294
+ await manager.createIdentity(1);
295
+ await manager.openPanel(1, 'join');
296
+ await manager.acceptInvitation(1, 'space', invitation);
297
+ // Wait for invitation to connect before cancelling it.
298
+ await sleep(100);
299
+ await manager.cancelInvitation('space', 'host', manager.peer(0));
258
300
 
259
- // TODO(wittjosiah): Propagate cancel to guest.
260
- test.skip('invitation cancelled by host', async () => {});
301
+ // Wait for cancellation to propagate.
302
+ await waitForExpect(async () => {
303
+ expect(await manager.invitationFailed(manager.peer(1))).to.be.true;
304
+ }, 100);
305
+ });
261
306
 
262
307
  test('invitation cancelled by guest & retry', async () => {
263
308
  await manager.createIdentity(0);
@@ -281,8 +326,7 @@ test.describe('Invitations', () => {
281
326
  expect(await manager.getSpaceName(0, 0)).to.equal(await manager.getSpaceName(1, 0));
282
327
  });
283
328
 
284
- // TODO(wittjosiah): Propagating network failure is flaky.
285
- test.skip('recover from network failure during invitation', async () => {
329
+ test('recover from network failure during invitation', async () => {
286
330
  await manager.createIdentity(0);
287
331
  await manager.createSpace(0);
288
332
  await manager.openPanel(0, 0);
@@ -295,6 +339,8 @@ test.describe('Invitations', () => {
295
339
  await manager.setConnectionState(0, ConnectionState.OFFLINE);
296
340
  await sleep(100);
297
341
  await manager.setConnectionState(0, ConnectionState.ONLINE);
342
+ // TODO(wittjosiah): Requires attempting an action to discover the network failure.
343
+ await manager.authenticateInvitation('space', '00000', manager.peer(1));
298
344
  await manager.resetInvitation(manager.peer(1));
299
345
  await manager.invitationInputContinue('space', manager.peer(1));
300
346
  const [authCode] = await Promise.all([manager.getAuthCode(), manager.clearAuthCode('space', manager.peer(1))]);
@@ -31,6 +31,8 @@ export class ShellManager {
31
31
  await (scope || this.page)
32
32
  .getByTestId(`${type === 'device' ? 'halo' : 'space'}-invitation-authenticator-cancel`)
33
33
  .click();
34
+ } else {
35
+ await (scope || this.page).getByTestId('cancel-invitation').nth(0).click();
34
36
  }
35
37
  }
36
38