@dxos/shell 0.3.11-main.c8e9429 → 0.3.11-main.c95bc86

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 (56) hide show
  1. package/dist/bundle/shell.mjs +5759 -5648
  2. package/dist/bundle/shell.mjs.map +1 -1
  3. package/dist/bundle/shell.umd.js +58 -58
  4. package/dist/bundle/shell.umd.js.map +1 -1
  5. package/dist/bundle/style.css +1 -1
  6. package/dist/lib/browser/meta.json +1 -1
  7. package/dist/lib/browser/react.mjs +55 -43
  8. package/dist/lib/browser/react.mjs.map +3 -3
  9. package/dist/lib/browser/testing/index.mjs +35 -14
  10. package/dist/lib/browser/testing/index.mjs.map +3 -3
  11. package/dist/types/src/components/IdentityList/SpaceMemberList.js +1 -1
  12. package/dist/types/src/components/IdentityList/SpaceMemberList.js.map +1 -1
  13. package/dist/types/src/components/Panel/Action.d.ts.map +1 -1
  14. package/dist/types/src/components/Panel/Action.js +3 -18
  15. package/dist/types/src/components/Panel/Action.js.map +1 -1
  16. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js +1 -1
  17. package/dist/types/src/panels/IdentityPanel/IdentityPanel.js.map +1 -1
  18. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.d.ts.map +1 -1
  19. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +1 -1
  20. package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
  21. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js +2 -2
  22. package/dist/types/src/panels/IdentityPanel/steps/SignOutChooser.js.map +1 -1
  23. package/dist/types/src/panels/JoinPanel/joinMachine.d.ts +1 -1
  24. package/dist/types/src/panels/JoinPanel/joinMachine.d.ts.map +1 -1
  25. package/dist/types/src/panels/JoinPanel/joinMachine.js +14 -17
  26. package/dist/types/src/panels/JoinPanel/joinMachine.js.map +1 -1
  27. package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.js +3 -3
  28. package/dist/types/src/panels/JoinPanel/steps/AdditionMethodChooser.js.map +1 -1
  29. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.d.ts.map +1 -1
  30. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js +13 -6
  31. package/dist/types/src/panels/JoinPanel/steps/InvitationInput.js.map +1 -1
  32. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js +1 -1
  33. package/dist/types/src/panels/JoinPanel/steps/ResetIdentity.js.map +1 -1
  34. package/dist/types/src/playwright/invitations-manager.d.ts +1 -0
  35. package/dist/types/src/playwright/invitations-manager.d.ts.map +1 -1
  36. package/dist/types/src/playwright/invitations-manager.js +4 -1
  37. package/dist/types/src/playwright/invitations-manager.js.map +1 -1
  38. package/dist/types/src/playwright/invitations.spec.js +15 -0
  39. package/dist/types/src/playwright/invitations.spec.js.map +1 -1
  40. package/dist/types/src/testing/shell-manager.d.ts +5 -4
  41. package/dist/types/src/testing/shell-manager.d.ts.map +1 -1
  42. package/dist/types/src/testing/shell-manager.js +36 -12
  43. package/dist/types/src/testing/shell-manager.js.map +1 -1
  44. package/package.json +19 -19
  45. package/src/components/IdentityList/SpaceMemberList.tsx +1 -1
  46. package/src/components/Panel/Action.tsx +4 -19
  47. package/src/panels/IdentityPanel/IdentityPanel.tsx +1 -1
  48. package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +5 -1
  49. package/src/panels/IdentityPanel/steps/SignOutChooser.tsx +2 -0
  50. package/src/panels/JoinPanel/joinMachine.ts +15 -18
  51. package/src/panels/JoinPanel/steps/AdditionMethodChooser.tsx +3 -3
  52. package/src/panels/JoinPanel/steps/InvitationInput.tsx +7 -1
  53. package/src/panels/JoinPanel/steps/ResetIdentity.tsx +1 -1
  54. package/src/playwright/invitations-manager.ts +5 -1
  55. package/src/playwright/invitations.spec.ts +19 -0
  56. package/src/testing/shell-manager.ts +40 -13
@@ -39,12 +39,17 @@ export const InvitationInput = (props: InvitationInputProps) => {
39
39
  unredeemedCode && setInputValue(unredeemedCode ?? '');
40
40
  }, [unredeemedCode]);
41
41
 
42
- const handleNext = () =>
42
+ const handleNext = () => {
43
+ if (inputValue.trim().length === 0) {
44
+ return;
45
+ }
46
+
43
47
  send({
44
48
  type: `set${Kind}InvitationCode`,
45
49
  code: invitationCodeFromUrl(inputValue),
46
50
  ...(Kind === 'Space' && { succeededKeys }),
47
51
  });
52
+ };
48
53
 
49
54
  const exitAction = (
50
55
  <Action
@@ -62,6 +67,7 @@ export const InvitationInput = (props: InvitationInputProps) => {
62
67
  <div role='none' className='grow flex flex-col justify-center'>
63
68
  <Input
64
69
  label={<StepHeading>{t('invitation input label')}</StepHeading>}
70
+ // TODO(burdon): Translation.
65
71
  placeholder='Type an invitation code'
66
72
  disabled={disabled}
67
73
  value={inputValue}
@@ -50,7 +50,7 @@ export const ResetIdentityImpl = ({ disabled, validationMessage, onConfirm }: Re
50
50
  {...{ validationMessage }}
51
51
  label={<StepHeading>{t('reset identity input label', { confirmationValue })}</StepHeading>}
52
52
  disabled={disabled}
53
- data-testid='identity-input'
53
+ data-testid='reset-identity-input'
54
54
  placeholder={confirmationValue}
55
55
  onChange={({ target: { value } }) => setInputValue(value)}
56
56
  />
@@ -70,6 +70,10 @@ export class InvitationsManager extends ScopedShellManager {
70
70
  return this.peer(id).getByTestId('space-list-item').nth(nth).textContent();
71
71
  }
72
72
 
73
+ async getSpaceMembersCount(id: number) {
74
+ return this.peer(id).getByTestId('space-members-list').locator('li').count();
75
+ }
76
+
73
77
  async getAuthCode(): Promise<string> {
74
78
  return await this._authCode.wait();
75
79
  }
@@ -147,7 +151,7 @@ export class InvitationsManager extends ScopedShellManager {
147
151
  const peer = this.peer(id);
148
152
  // TODO(wittjosiah): Update ids.
149
153
  if (type === 'device') {
150
- await peer.getByTestId('join-identity').click();
154
+ await peer.getByTestId('identity-chooser.join-identity').click();
151
155
  }
152
156
  await peer.getByTestId(`${type === 'device' ? 'halo' : 'space'}-invitation-input`).waitFor({ timeout: 500 });
153
157
  await peer.getByTestId(`${type === 'device' ? 'halo' : 'space'}-invitation-input`).fill(invitation);
@@ -185,6 +185,25 @@ test.describe('Invitations', () => {
185
185
  expect(await manager.getSpaceName(0, 1)).to.equal(await manager.getSpaceName(1, 1));
186
186
  });
187
187
 
188
+ test('already joined', async () => {
189
+ await manager.createIdentity(0);
190
+ await manager.createSpace(0);
191
+ await manager.openPanel(0, 1);
192
+ const invitation1 = await manager.createInvitation(0, 'space', { authMethod: Invitation.AuthMethod.NONE });
193
+ const invitation2 = await manager.createInvitation(0, 'space');
194
+
195
+ await manager.createIdentity(1);
196
+ await manager.openPanel(1, 'join');
197
+ await manager.acceptInvitation(1, 'space', invitation1);
198
+ await manager.doneInvitation('space', manager.peer(1));
199
+
200
+ await manager.openPanel(1, 'join');
201
+ await manager.acceptInvitation(1, 'space', invitation2);
202
+ await manager.doneInvitation('space', manager.peer(1));
203
+
204
+ expect(await manager.getSpaceMembersCount(0)).to.equal(2);
205
+ });
206
+
188
207
  test('no auth method', async () => {
189
208
  await manager.createIdentity(0);
190
209
  await manager.createSpace(0);
@@ -2,12 +2,14 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import type { ConsoleMessage, Page } from '@playwright/test';
5
+ import type { ConsoleMessage, Dialog, Page } from '@playwright/test';
6
6
 
7
7
  import { sleep, Trigger } from '@dxos/async';
8
8
 
9
9
  import { ScopedShellManager } from './scoped-shell-manager';
10
10
 
11
+ // TODO(wittjosiah): Normalize data-testids between snake and camel case.
12
+
11
13
  export class ShellManager extends ScopedShellManager {
12
14
  private _invitationCode = new Trigger<string>();
13
15
  private _authCode = new Trigger<string>();
@@ -27,6 +29,10 @@ export class ShellManager extends ScopedShellManager {
27
29
 
28
30
  // Getters
29
31
 
32
+ async getDisplayName(): Promise<string | null> {
33
+ return this.shell.getByTestId('identityHeading.displayName').textContent();
34
+ }
35
+
30
36
  async isCurrentSpaceViewVisible(): Promise<boolean> {
31
37
  return await this.shell.getByTestId('current-space-view').isVisible();
32
38
  }
@@ -44,29 +50,50 @@ export class ShellManager extends ScopedShellManager {
44
50
  await this.shell.getByTestId('halo-invitation-accepted-done').click();
45
51
  }
46
52
 
47
- async closeShell() {
48
- await this.page.keyboard.press('Escape');
53
+ async createDeviceInvitation(): Promise<string> {
54
+ this._invitationCode = new Trigger<string>();
55
+ this._authCode = new Trigger<string>();
56
+ await this.shell.getByTestId('devices-panel.create-invitation').click();
57
+ return await this._invitationCode.wait();
49
58
  }
50
59
 
51
- // TODO(wittjosiah): These shortcuts are no longer within the SDK so these commands should live elsewhere.
52
- async openCurrentSpace() {
53
- await this.page.keyboard.press('Meta+.');
60
+ async resetDevice() {
61
+ const handleDialog = async (dialog: Dialog) => {
62
+ if (dialog.type() === 'confirm') {
63
+ await dialog.accept();
64
+ }
65
+ };
66
+
67
+ this.page.on('dialog', handleDialog);
68
+ await this.shell.getByTestId('devices-panel.sign-out').click();
69
+ await this.shell.getByTestId('sign-out.reset-device').click();
70
+ this.page.off('dialog', handleDialog);
54
71
  }
55
72
 
56
- async openSpaceList() {
57
- await this.page.keyboard.press('Meta+Shift+>');
73
+ async joinNewIdentity(invitationCode: string) {
74
+ await this.shell.getByTestId('devices-panel.sign-out').click();
75
+ await this.shell.getByTestId('sign-out.join-new-identity').click();
76
+ await this.shell.getByTestId('reset-identity-input').fill('CONFIRM');
77
+ await this.shell.getByTestId('reset-identity-input-confirm').click();
78
+ await this.shell.getByTestId('identity-chooser.join-identity').click();
79
+ await this.inputInvitation('device', invitationCode, this.shell);
58
80
  }
59
81
 
60
- async showAllSpaces() {
61
- await this.shell.getByTestId('show-all-spaces').click();
82
+ async authenticateDevice(authCode: string, skipDone = true) {
83
+ // Wait for focus to shift before typing.
84
+ await sleep(1500);
85
+ await this.authenticateInvitation('device', authCode, this.shell);
86
+ // TODO(wittjosiah): When "signing out" and joinging a new identity, the done step seems to be skipped.
87
+ if (!skipDone) {
88
+ await this.doneInvitation('device', this.shell);
89
+ }
62
90
  }
63
91
 
64
- async showCurrentSpace() {
65
- await this.shell.getByTestId('show-current-space').click();
92
+ async closeShell() {
93
+ await this.page.keyboard.press('Escape');
66
94
  }
67
95
 
68
96
  async createSpaceInvitation(): Promise<string> {
69
- await this.openCurrentSpace();
70
97
  this._invitationCode = new Trigger<string>();
71
98
  this._authCode = new Trigger<string>();
72
99
  await this.shell.getByTestId('spaces-panel.create-invitation').click();