org-shortcuts.test.ts 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // @ts-nocheck
  2. import { describe, expect, it } from 'vitest'
  3. import { SHORTCUT_REFERENCE_GROUP_ORDER, SHORTCUT_REFERENCE_GROUPS } from '../referenceGroups'
  4. import { SHORTCUT_DEFINITIONS, SHORTCUT_IDS } from '../registry'
  5. describe('Org settings nav shortcuts', () => {
  6. const navIds = [
  7. SHORTCUT_IDS.NAV_ORG_SETTINGS_GENERAL,
  8. SHORTCUT_IDS.NAV_ORG_SETTINGS_SECURITY,
  9. SHORTCUT_IDS.NAV_ORG_SETTINGS_SSO,
  10. SHORTCUT_IDS.NAV_ORG_SETTINGS_APPS,
  11. SHORTCUT_IDS.NAV_ORG_SETTINGS_PRIVATE_APPS,
  12. SHORTCUT_IDS.NAV_ORG_SETTINGS_WEBHOOKS,
  13. SHORTCUT_IDS.NAV_ORG_SETTINGS_AUDIT,
  14. SHORTCUT_IDS.NAV_ORG_SETTINGS_AUDIT_LOG_DRAINS,
  15. SHORTCUT_IDS.NAV_ORG_SETTINGS_DOCUMENTS,
  16. ]
  17. it.each(navIds)('%s is registered with NAVIGATION_ORG_SETTINGS group', (id) => {
  18. expect(SHORTCUT_DEFINITIONS[id].referenceGroup).toBe(
  19. SHORTCUT_REFERENCE_GROUPS.NAVIGATION_ORG_SETTINGS
  20. )
  21. })
  22. it.each(navIds)('%s sequence starts with S', (id) => {
  23. const sequence = SHORTCUT_DEFINITIONS[id].sequence
  24. expect(Array.isArray(sequence) ? sequence[0] : sequence).toBe('S')
  25. })
  26. })
  27. describe('NAV_ORG_SETTINGS remap', () => {
  28. it('uses G , (matching project settings chord)', () => {
  29. const def = SHORTCUT_DEFINITIONS[SHORTCUT_IDS.NAV_ORG_SETTINGS]
  30. expect(def.sequence).toEqual(['G', ','])
  31. })
  32. })
  33. describe('Org action shortcuts', () => {
  34. it('ORG_OAUTH_APPS_PUBLISH is registered', () => {
  35. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_OAUTH_APPS_PUBLISH]).toBeDefined()
  36. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_OAUTH_APPS_PUBLISH].sequence).toEqual(['Shift+N'])
  37. })
  38. it('ORG_OAUTH_APPS_SUBMIT uses Mod+Enter and is hidden from settings', () => {
  39. const def = SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_OAUTH_APPS_SUBMIT]
  40. expect(def.sequence).toEqual(['Mod+Enter'])
  41. expect(def.showInSettings).toBe(false)
  42. })
  43. it('ORG_TEAM_INVITE is registered', () => {
  44. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_TEAM_INVITE].sequence).toEqual(['Shift+N'])
  45. })
  46. it('ORG_TEAM_INVITE_SUBMIT uses Mod+Enter and is hidden from settings', () => {
  47. const def = SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_TEAM_INVITE_SUBMIT]
  48. expect(def.sequence).toEqual(['Mod+Enter'])
  49. expect(def.showInSettings).toBe(false)
  50. })
  51. it('ORG_INTEGRATIONS_ADD_CONNECTION is registered', () => {
  52. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_INTEGRATIONS_ADD_CONNECTION].sequence).toEqual([
  53. 'Shift+N',
  54. ])
  55. })
  56. it('ORG_PROJECTS_NEW is registered', () => {
  57. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_PROJECTS_NEW].sequence).toEqual(['Shift+N'])
  58. })
  59. it('ORG_PROJECTS_SEARCH is registered', () => {
  60. expect(SHORTCUT_DEFINITIONS[SHORTCUT_IDS.ORG_PROJECTS_SEARCH].sequence).toEqual(['Shift+F'])
  61. })
  62. })
  63. describe('Reference group ordering', () => {
  64. it('NAVIGATION_ORG_SETTINGS appears after NAVIGATION_GLOBAL', () => {
  65. const globalIdx = SHORTCUT_REFERENCE_GROUP_ORDER.indexOf(
  66. SHORTCUT_REFERENCE_GROUPS.NAVIGATION_GLOBAL
  67. )
  68. const orgSettingsIdx = SHORTCUT_REFERENCE_GROUP_ORDER.indexOf(
  69. SHORTCUT_REFERENCE_GROUPS.NAVIGATION_ORG_SETTINGS
  70. )
  71. expect(orgSettingsIdx).toBeGreaterThan(globalIdx)
  72. })
  73. })