@automattic/launchpad 1.2.3 → 1.3.0

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 (90) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/action-components/share-site-modal/index.js +5 -7
  4. package/dist/cjs/action-components/share-site-modal/index.js.map +1 -1
  5. package/dist/cjs/action-components/share-site-modal/style.scss +0 -19
  6. package/dist/cjs/checklist-item/index.js +4 -4
  7. package/dist/cjs/checklist-item/index.js.map +1 -1
  8. package/dist/cjs/checklist-item/style.scss +3 -1
  9. package/dist/cjs/index.js +4 -1
  10. package/dist/cjs/index.js.map +1 -1
  11. package/dist/cjs/launchpad-internal.js +2 -2
  12. package/dist/cjs/launchpad-internal.js.map +1 -1
  13. package/dist/cjs/launchpad.js +5 -9
  14. package/dist/cjs/launchpad.js.map +1 -1
  15. package/dist/cjs/setup-actions.js +11 -6
  16. package/dist/cjs/setup-actions.js.map +1 -1
  17. package/dist/cjs/site-type.js +3 -0
  18. package/dist/cjs/site-type.js.map +1 -0
  19. package/dist/cjs/use-launchpad.js +151 -0
  20. package/dist/cjs/use-launchpad.js.map +1 -0
  21. package/dist/cjs/use-site.js +38 -0
  22. package/dist/cjs/use-site.js.map +1 -0
  23. package/dist/cjs/wpcom-request.js +24 -0
  24. package/dist/cjs/wpcom-request.js.map +1 -0
  25. package/dist/esm/action-components/share-site-modal/index.js +4 -6
  26. package/dist/esm/action-components/share-site-modal/index.js.map +1 -1
  27. package/dist/esm/action-components/share-site-modal/style.scss +0 -19
  28. package/dist/esm/checklist-item/index.js +2 -2
  29. package/dist/esm/checklist-item/index.js.map +1 -1
  30. package/dist/esm/checklist-item/style.scss +3 -1
  31. package/dist/esm/index.js +2 -0
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/esm/launchpad-internal.js +1 -1
  34. package/dist/esm/launchpad-internal.js.map +1 -1
  35. package/dist/esm/launchpad.js +3 -6
  36. package/dist/esm/launchpad.js.map +1 -1
  37. package/dist/esm/setup-actions.js +9 -4
  38. package/dist/esm/setup-actions.js.map +1 -1
  39. package/dist/esm/site-type.js +2 -0
  40. package/dist/esm/site-type.js.map +1 -0
  41. package/dist/esm/use-launchpad.js +140 -0
  42. package/dist/esm/use-launchpad.js.map +1 -0
  43. package/dist/esm/use-site.js +33 -0
  44. package/dist/esm/use-site.js.map +1 -0
  45. package/dist/esm/wpcom-request.js +18 -0
  46. package/dist/esm/wpcom-request.js.map +1 -0
  47. package/dist/tsconfig-cjs.tsbuildinfo +1 -1
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/action-components/share-site-modal/index.d.ts +3 -3
  50. package/dist/types/action-components/share-site-modal/index.d.ts.map +1 -1
  51. package/dist/types/checklist/index.d.ts +1 -1
  52. package/dist/types/checklist/index.d.ts.map +1 -1
  53. package/dist/types/checklist-item/index.d.ts.map +1 -1
  54. package/dist/types/index.d.ts +2 -0
  55. package/dist/types/index.d.ts.map +1 -1
  56. package/dist/types/launchpad-internal.d.ts +3 -2
  57. package/dist/types/launchpad-internal.d.ts.map +1 -1
  58. package/dist/types/launchpad.d.ts +1 -2
  59. package/dist/types/launchpad.d.ts.map +1 -1
  60. package/dist/types/setup-actions.d.ts.map +1 -1
  61. package/dist/types/site-type.d.ts +10 -0
  62. package/dist/types/site-type.d.ts.map +1 -0
  63. package/dist/types/use-launchpad.d.ts +65 -0
  64. package/dist/types/use-launchpad.d.ts.map +1 -0
  65. package/dist/types/use-site.d.ts +8 -0
  66. package/dist/types/use-site.d.ts.map +1 -0
  67. package/dist/types/use-tracking/index.d.ts +2 -2
  68. package/dist/types/use-tracking/index.d.ts.map +1 -1
  69. package/dist/types/wpcom-request.d.ts +7 -0
  70. package/dist/types/wpcom-request.d.ts.map +1 -0
  71. package/package.json +12 -13
  72. package/src/action-components/share-site-modal/index.tsx +7 -18
  73. package/src/action-components/share-site-modal/style.scss +0 -19
  74. package/src/checklist-item/index.tsx +6 -2
  75. package/src/checklist-item/style.scss +3 -1
  76. package/src/index.ts +2 -0
  77. package/src/launchpad-internal.tsx +3 -3
  78. package/src/launchpad.tsx +3 -15
  79. package/src/setup-actions.ts +9 -4
  80. package/src/site-type.ts +9 -0
  81. package/src/test/launchpad.tsx +3 -1
  82. package/src/test/lib/fixtures.ts +1 -2
  83. package/src/test/setup-actions.ts +44 -0
  84. package/src/test/use-site.ts +60 -0
  85. package/src/use-launchpad.ts +249 -0
  86. package/src/use-site.ts +36 -0
  87. package/src/use-tracking/index.tsx +2 -2
  88. package/src/use-tracking/test/index.tsx +3 -3
  89. package/src/wpcom-request.ts +26 -0
  90. package/tsconfig.json +1 -5
@@ -1,11 +1,11 @@
1
+ import type { LaunchpadSiteDetails } from '../../site-type';
1
2
  import type { Task } from '../../types';
2
- import type { SiteDetails } from '@automattic/data-stores';
3
3
  import './style.scss';
4
4
  interface ShareSiteModalProps {
5
5
  setModalIsOpen: (isOpen: boolean) => void;
6
- site: SiteDetails | null;
6
+ site: LaunchpadSiteDetails | null;
7
7
  task: Task | null;
8
8
  }
9
- declare const ShareSiteModal: ({ setModalIsOpen, site, task }: ShareSiteModalProps) => import("react/jsx-runtime").JSX.Element;
9
+ declare const ShareSiteModal: ({ setModalIsOpen, site, task }: ShareSiteModalProps) => import("react").JSX.Element;
10
10
  export default ShareSiteModal;
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/action-components/share-site-modal/index.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,cAAc,CAAC;AAEtB,UAAU,mBAAmB;IAC5B,cAAc,EAAE,CAAE,MAAM,EAAE,OAAO,KAAM,IAAI,CAAC;IAC5C,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAClB;AAkHD,QAAA,MAAM,cAAc,GAAK,gCAAgC,mBAAmB,4CA8H3E,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/action-components/share-site-modal/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,cAAc,CAAC;AAEtB,UAAU,mBAAmB;IAC5B,cAAc,EAAE,CAAE,MAAM,EAAE,OAAO,KAAM,IAAI,CAAC;IAC5C,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAClB;AAkHD,QAAA,MAAM,cAAc,GAAK,gCAAgC,mBAAmB,gCAoH3E,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -7,6 +7,6 @@ interface Props {
7
7
  children?: ReactElement<ComponentProps<typeof ChecklistItem>> | ReactElement<ComponentProps<typeof ChecklistItem>>[];
8
8
  }
9
9
  declare const Checklist: FC<Props>;
10
- export declare const Placeholder: () => import("react/jsx-runtime").JSX.Element;
10
+ export declare const Placeholder: () => import("react").JSX.Element;
11
11
  export default Checklist;
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checklist/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,EAAE,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,aAA0D,MAAM,mBAAmB,CAAC;AAC3F,OAAO,cAAc,CAAC;AAEtB,UAAU,KAAK;IACd,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EACN,YAAY,CAAE,cAAc,CAAE,OAAO,aAAa,CAAE,CAAE,GACtD,YAAY,CAAE,cAAc,CAAE,OAAO,aAAa,CAAE,CAAE,EAAE,CAAC;CAC5D;AAED,QAAA,MAAM,SAAS,EAAE,EAAE,CAAE,KAAK,CA6BzB,CAAC;AAEF,eAAO,MAAM,WAAW,+CASvB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checklist/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,EAAE,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,OAAO,CAAC;AAChG,OAAO,aAA0D,MAAM,mBAAmB,CAAC;AAC3F,OAAO,cAAc,CAAC;AAEtB,UAAU,KAAK;IACd,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,EACN,YAAY,CAAE,cAAc,CAAE,OAAO,aAAa,CAAE,CAAE,GACtD,YAAY,CAAE,cAAc,CAAE,OAAO,aAAa,CAAE,CAAE,EAAE,CAAC;CAC5D;AAED,QAAA,MAAM,SAAS,EAAE,EAAE,CAAE,KAAK,CA6BzB,CAAC;AAEF,eAAO,MAAM,WAAW,mCASvB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checklist-item/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,cAAc,CAAC;AAEtB,UAAU,KAAK;IACd,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAE,KAAK,CA8I7B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAQzB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/checklist-item/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,cAAc,CAAC;AAEtB,UAAU,KAAK;IACd,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,IAAI,EAAE,IAAI,CAAC;IACX,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,QAAA,MAAM,aAAa,EAAE,EAAE,CAAE,KAAK,CAkJ7B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAQzB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -6,4 +6,6 @@ export { default as Launchpad } from './launchpad';
6
6
  export { setUpActionsForTasks } from './setup-actions';
7
7
  export * from './action-components';
8
8
  export * from './types';
9
+ export * from './use-launchpad';
10
+ export { setRequester } from './wpcom-request';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { type FC } from 'react';
2
+ import { type UseLaunchpadOptions } from './use-launchpad';
3
+ import type { LaunchpadSiteDetails } from './site-type';
2
4
  import type { Task } from './types';
3
- import type { SiteDetails, UseLaunchpadOptions } from '@automattic/data-stores';
4
5
  interface Props {
5
- site?: SiteDetails | null;
6
+ site?: LaunchpadSiteDetails | null;
6
7
  siteSlug: string | null;
7
8
  checklistSlug: string | null;
8
9
  makeLastTaskPrimaryAction?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"launchpad-internal.d.ts","sourceRoot":"","sources":["../../src/launchpad-internal.t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IACpC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IACzC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,QAAA,MAAM,iBAAiB,EAAE,EAAE,CAAE,KAAK,CA+DjC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import type { EventHandlers, Task } from './types';
2
- export declare const SITE_STORE: "automattic/site";
3
2
  type LaunchpadProps = {
4
3
  siteSlug: string | null;
5
4
  checklistSlug: string;
@@ -9,6 +8,6 @@ type LaunchpadProps = {
9
8
  onPostFilterTasks?: (tasks: Task[]) => Task[];
10
9
  highlightNextAction?: boolean;
11
10
  };
12
- declare const Launchpad: ({ siteSlug, checklistSlug, launchpadContext, onSiteLaunched, onTaskClick, onPostFilterTasks, highlightNextAction, }: LaunchpadProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ declare const Launchpad: ({ siteSlug, checklistSlug, launchpadContext, onSiteLaunched, onTaskClick, onPostFilterTasks, highlightNextAction, }: LaunchpadProps) => import("react").JSX.Element | null;
13
12
  export default Launchpad;
14
13
  //# sourceMappingURL=launchpad.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launchpad.d.ts","sourceRoot":"","sources":["../../src/launchpad.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEnD,eAAO,MAAM,UAAU,mBAAwD,CAAC;AAEhF,KAAK,cAAc,GAAG;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,aAAa,CAAE,aAAa,CAAE,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,SAAS,GAAK,qHAQjB,cAAc,mDAkEhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"launchpad.d.ts","sourceRoot":"","sources":["../../src/launchpad.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEnD,KAAK,cAAc,GAAG;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,aAAa,CAAE,aAAa,CAAE,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAE,KAAK,EAAE,IAAI,EAAE,KAAM,IAAI,EAAE,CAAC;IAChD,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,SAAS,GAAK,qHAQjB,cAAc,uCA6DhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup-actions.d.ts","sourceRoot":"","sources":["../../src/setup-actions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAe/D,eAAO,MAAM,oBAAoB,GAAK,0EAOnC,yBAAyB,KAAI,IAAI,EAoJnC,CAAC"}
1
+ {"version":3,"file":"setup-actions.d.ts","sourceRoot":"","sources":["../../src/setup-actions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,yBAAyB,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAe/D,eAAO,MAAM,oBAAoB,GAAK,0EAOnC,yBAAyB,KAAI,IAAI,EA0JnC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /** A full `SiteDetails` satisfies this. */
2
+ export interface LaunchpadSiteDetails {
3
+ slug?: string;
4
+ URL?: string;
5
+ options?: {
6
+ site_intent?: string;
7
+ site_goals?: string[];
8
+ };
9
+ }
10
+ //# sourceMappingURL=site-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-type.d.ts","sourceRoot":"","sources":["../../src/site-type.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACtB,CAAC;CACF"}
@@ -0,0 +1,65 @@
1
+ interface Task {
2
+ id: string;
3
+ completed: boolean;
4
+ disabled: boolean;
5
+ title: string;
6
+ subtitle?: string;
7
+ badgeText?: string;
8
+ actionDispatch?: () => void;
9
+ isLaunchTask?: boolean;
10
+ warning?: boolean;
11
+ order?: number;
12
+ }
13
+ export interface ChecklistStatuses {
14
+ links_edited?: boolean;
15
+ site_edited?: boolean;
16
+ site_launched?: boolean;
17
+ first_post_published?: boolean;
18
+ video_uploaded?: boolean;
19
+ publish_first_course?: boolean;
20
+ plan_selected?: boolean;
21
+ plan_completed?: boolean;
22
+ domain_upsell_deferred?: boolean;
23
+ }
24
+ type LaunchpadScreen = 'full' | 'off' | 'skipped' | 'minimized';
25
+ export interface LaunchpadResponse {
26
+ site_intent?: string | null;
27
+ launchpad_screen?: LaunchpadScreen | boolean | null | undefined;
28
+ checklist?: Task[] | null;
29
+ checklist_statuses?: ChecklistStatuses;
30
+ is_enabled: boolean;
31
+ is_dismissed: boolean;
32
+ is_dismissible: boolean;
33
+ title?: string | null;
34
+ }
35
+ type LaunchpadUpdateSettings = {
36
+ checklist_statuses?: Record<string, boolean>;
37
+ is_checklist_dismissed?: {
38
+ slug: string;
39
+ is_dismissed?: boolean;
40
+ dismissed_until?: number | null;
41
+ };
42
+ launchpad_screen?: 'off' | 'minimized' | 'full' | 'skipped';
43
+ };
44
+ export type UseLaunchpadOptions = {
45
+ onSuccess?: (data: LaunchpadResponse) => LaunchpadResponse;
46
+ };
47
+ export declare const fetchLaunchpad: (siteSlug: SiteSlug, checklistSlug?: string | null, launchpadContext?: string) => Promise<LaunchpadResponse>;
48
+ export declare function sortLaunchpadTasksByCompletionStatus(response: LaunchpadResponse): LaunchpadResponse;
49
+ export declare function defaultSuccessCallback(response: LaunchpadResponse): LaunchpadResponse;
50
+ type SiteSlug = string | number | null;
51
+ export declare const useLaunchpad: (siteSlug: SiteSlug, checklistSlug?: string | null, options?: UseLaunchpadOptions, launchpad_context?: string | undefined) => import("@tanstack/react-query").DefinedUseQueryResult<LaunchpadResponse, Error>;
52
+ export declare const useSortedLaunchpadTasks: (siteSlug: SiteSlug, checklistSlug?: string | null, launchpadContext?: string) => import("@tanstack/react-query").DefinedUseQueryResult<LaunchpadResponse, Error>;
53
+ export declare const updateLaunchpadSettings: (siteSlug: SiteSlug, settings?: LaunchpadUpdateSettings) => Promise<unknown>;
54
+ export interface PermanentDismiss {
55
+ isDismissed: boolean;
56
+ }
57
+ export interface TemporaryDismiss {
58
+ dismissBy: '+ 1 day' | '+ 1 week';
59
+ }
60
+ type DismissSettings = PermanentDismiss | TemporaryDismiss;
61
+ export declare const useLaunchpadDismisser: (siteSlug: SiteSlug, checklistSlug: string, launchpadContext: string) => import("@tanstack/react-query").UseMutationResult<unknown, Error, DismissSettings, {
62
+ previous: LaunchpadResponse | undefined;
63
+ }>;
64
+ export {};
65
+ //# sourceMappingURL=use-launchpad.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-launchpad.d.ts","sourceRoot":"","sources":["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AC;CAClC;AAED,KAAK,eAAe,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAsB3D,eAAO,MAAM,qBAAqB,GACjC,UAAU,QAAQ,EAClB,eAAe,MAAM,EACrB,kBAAkB,MAAM;;EAqCxB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { LaunchpadSiteDetails } from './site-type';
2
+ /**
3
+ * Fetches the site fields Launchpad reads. The response is the full site; only these
4
+ * fields are cached. Skipped where the proxy is unavailable, since there is no REST
5
+ * fallback, and kept for the session — both matching the site store this replaces.
6
+ */
7
+ export declare const useSite: (siteSlug: string | null) => LaunchpadSiteDetails | null;
8
+ //# sourceMappingURL=use-site.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-site.d.ts","sourceRoot":"","sources":["../../src/use-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAK,UAAU,MAAM,GAAG,IAAI,gCA0B/C,CAAC"}
@@ -1,10 +1,10 @@
1
+ import type { LaunchpadSiteDetails } from '../site-type';
1
2
  import type { Task } from '../types';
2
- import type { SiteDetails } from '@automattic/data-stores';
3
3
  interface Params {
4
4
  tasks: Task[];
5
5
  checklistSlug: string | null;
6
6
  context: string;
7
- site: SiteDetails | null | undefined;
7
+ site: LaunchpadSiteDetails | null | undefined;
8
8
  flow?: string;
9
9
  }
10
10
  export declare const useTracking: (params: Params) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/use-tracking/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,UAAU,MAAM;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAWD,eAAO,MAAM,WAAW,GAAK,QAAQ,MAAM;2BAoDX,IAAI;CAgBnC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/use-tracking/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,UAAU,MAAM;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,oBAAoB,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;CACd;AAWD,eAAO,MAAM,WAAW,GAAK,QAAQ,MAAM;2BAoDX,IAAI;CAgBnC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type WpcomRequestParams } from 'wpcom-proxy-request';
2
+ type WpcomRequester = <T>(params: WpcomRequestParams) => Promise<T>;
3
+ export declare function setRequester(requester: WpcomRequester): void;
4
+ export default function wpcomRequest<T>(params: WpcomRequestParams): Promise<T>;
5
+ export declare function canAccessWpcomApis(): boolean;
6
+ export {};
7
+ //# sourceMappingURL=wpcom-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wpcom-request.d.ts","sourceRoot":"","sources":["../../src/wpcom-request.ts"],"names":[],"mappings":"AAAA,OAA0B,EACzB,KAAK,kBAAkB,EAEvB,MAAM,qBAAqB,CAAC;AAE7B,KAAK,cAAc,GAAG,CAAE,CAAC,EAAI,MAAM,EAAE,kBAAkB,KAAM,OAAO,CAAE,CAAC,CAAE,CAAC;AAI1E,wBAAgB,YAAY,CAAE,SAAS,EAAE,cAAc,GAAI,IAAI,CAE9D;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,CAAC,EAAI,MAAM,EAAE,kBAAkB,GAAI,OAAO,CAAE,CAAC,CAAE,CAKpF;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAK5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/launchpad",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "Launchpad components.",
5
5
  "homepage": "https://github.com/Automattic/wp-calypso",
6
6
  "license": "GPL-2.0-or-later",
@@ -14,6 +14,9 @@
14
14
  "types": "./dist/types/index.d.ts",
15
15
  "import": "./dist/esm/index.js",
16
16
  "require": "./dist/cjs/index.js"
17
+ },
18
+ "./src/*": {
19
+ "calypso:src": "./src/*"
17
20
  }
18
21
  },
19
22
  "sideEffects": [
@@ -35,26 +38,25 @@
35
38
  "build": "tsc --build ./tsconfig.json ./tsconfig-cjs.json && copy-assets",
36
39
  "prepack": "yarn run clean && yarn run build",
37
40
  "watch": "tsc --build ./tsconfig.json --watch",
38
- "storybook:start": "storybook dev"
41
+ "storybook:start": "storybook dev -p 26837"
39
42
  },
40
43
  "dependencies": {
41
44
  "@automattic/calypso-analytics": "^1.1.5",
42
- "@automattic/calypso-config": "^1.0.0-alpha.0",
43
- "@automattic/components": "^3.0.4",
44
- "@automattic/data-stores": "^3.2.1",
45
- "@automattic/i18n-utils": "^1.2.4",
45
+ "@automattic/i18n-utils": "^1.3.0",
46
+ "@automattic/oauth-token": "^1.0.1",
46
47
  "@automattic/typography": "^1.0.0",
47
48
  "@automattic/viewport": "^1.1.1",
48
49
  "@tanstack/react-query": "^5.83.0",
50
+ "@wordpress/api-fetch": "^7.48.0",
49
51
  "@wordpress/base-styles": "^9.1.0",
50
- "@wordpress/components": "^35.0.0",
52
+ "@wordpress/components": "^37.0.0",
51
53
  "@wordpress/icons": "^13.3.0",
54
+ "@wordpress/ui": "^0.18.0",
52
55
  "@wordpress/url": "^4.48.0",
53
56
  "clsx": "^2.1.1",
54
57
  "social-logos": "^3.1.18",
55
58
  "tslib": "^2.8.1",
56
- "utility-types": "^3.10.0",
57
- "wpcom-proxy-request": "^7.0.7"
59
+ "wpcom-proxy-request": "^7.1.0"
58
60
  },
59
61
  "devDependencies": {
60
62
  "@automattic/calypso-build": "^11.0.0",
@@ -63,7 +65,7 @@
63
65
  "@storybook/addon-a11y": "^9.1.20",
64
66
  "msw": "^2.1.7",
65
67
  "msw-storybook-addon": "2.0.7",
66
- "postcss": "^8.5.3",
68
+ "postcss": "^8.5.15",
67
69
  "react": "^18.3.1",
68
70
  "react-dom": "^18.3.1",
69
71
  "storybook": "^9.1.20",
@@ -71,10 +73,7 @@
71
73
  "webpack": "^5.99.8"
72
74
  },
73
75
  "peerDependencies": {
74
- "@wordpress/data": "^10.48.0",
75
- "@wordpress/element": "^8.0.0",
76
76
  "@wordpress/i18n": "^6.21.0",
77
- "debug": "^4.4.1",
78
77
  "react": "^18.3.1 || ^19.0.0",
79
78
  "react-dom": "^18.3.1 || ^19.0.0"
80
79
  }
@@ -1,6 +1,4 @@
1
1
  import { recordTracksEvent } from '@automattic/calypso-analytics';
2
- import { Popover } from '@automattic/components';
3
- import { updateLaunchpadSettings } from '@automattic/data-stores';
4
2
  import { useQueryClient } from '@tanstack/react-query';
5
3
  import {
6
4
  Button,
@@ -12,15 +10,16 @@ import {
12
10
  } from '@wordpress/components';
13
11
  import { __, sprintf } from '@wordpress/i18n';
14
12
  import { copy, share, check } from '@wordpress/icons';
15
- import { useState, useRef, useMemo, useCallback } from 'react';
13
+ import { useState, useMemo, useCallback } from 'react';
16
14
  import { SocialLogo } from 'social-logos';
15
+ import { updateLaunchpadSettings } from '../../use-launchpad';
16
+ import type { LaunchpadSiteDetails } from '../../site-type';
17
17
  import type { Task } from '../../types';
18
- import type { SiteDetails } from '@automattic/data-stores';
19
18
  import './style.scss';
20
19
 
21
20
  interface ShareSiteModalProps {
22
21
  setModalIsOpen: ( isOpen: boolean ) => void;
23
- site: SiteDetails | null;
22
+ site: LaunchpadSiteDetails | null;
24
23
  task: Task | null;
25
24
  }
26
25
 
@@ -107,7 +106,7 @@ const getShareLinks = ( siteUrl: string, text: string ): ShareLink[] => {
107
106
  ];
108
107
  };
109
108
 
110
- const getSiteSlug = ( site: SiteDetails | null ) => {
109
+ const getSiteSlug = ( site: LaunchpadSiteDetails | null ) => {
111
110
  if ( ! site ) {
112
111
  return '';
113
112
  }
@@ -122,12 +121,12 @@ const getSiteSlug = ( site: SiteDetails | null ) => {
122
121
  return '';
123
122
  };
124
123
 
125
- const getShareData = ( site: SiteDetails | null ) => {
124
+ const getShareData = ( site: LaunchpadSiteDetails | null ) => {
126
125
  const siteSlug = getSiteSlug( site );
127
126
  return {
128
127
  title: siteSlug,
129
128
  text: sprintf(
130
- /* translators: siteSlug is the short form of the site URL with the https:// */
129
+ /* translators: %(siteSlug)s is the short form of the site URL with the https:// */
131
130
  __( 'Please visit my site: %(siteSlug)s', 'launchpad' ),
132
131
  {
133
132
  siteSlug,
@@ -158,7 +157,6 @@ const ShareSiteModal = ( { setModalIsOpen, site, task }: ShareSiteModalProps ) =
158
157
  );
159
158
 
160
159
  const [ clipboardCopied, setClipboardCopied ] = useState( false );
161
- const clipboardTextEl = useRef( null );
162
160
  const copyHandler = () => {
163
161
  navigator.clipboard.writeText( shareData.url );
164
162
  setClipboardCopied( true );
@@ -204,20 +202,11 @@ const ShareSiteModal = ( { setModalIsOpen, site, task }: ShareSiteModalProps ) =
204
202
  >
205
203
  <VStack className="share-site-modal__modal-content" spacing={ 4 }>
206
204
  <VStack className="share-site-modal__modal-actions" spacing={ 4 }>
207
- <Popover
208
- className="share-site-modal__popover"
209
- isVisible={ clipboardCopied }
210
- context={ clipboardTextEl.current }
211
- position="top"
212
- >
213
- { __( 'Copied to clipboard!', 'launchpad' ) }
214
- </Popover>
215
205
  <InputControl
216
206
  className="share-site-modal__modal-input-container"
217
207
  __next40pxDefaultSize
218
208
  value={ shareData.title }
219
209
  label={ __( 'Site URL', 'launchpad' ) }
220
- ref={ clipboardTextEl }
221
210
  readOnly
222
211
  hideLabelFromVision
223
212
  suffix={
@@ -45,22 +45,3 @@
45
45
  text-decoration: underline;
46
46
  }
47
47
  }
48
-
49
- .share-site-modal__popover {
50
- outline: none;
51
- z-index: 100000;
52
- .popover__inner {
53
- border: 0;
54
- box-shadow: none;
55
- border-radius: 2px;
56
- color: var(--color-text-inverted);
57
- background: var(--color-neutral-60);
58
- font-size: $font-body-extra-small;
59
- padding: 6px 10px;
60
- text-align: left;
61
- }
62
-
63
- .popover__arrow {
64
- display: none;
65
- }
66
- }
@@ -1,7 +1,7 @@
1
- import { Badge } from '@automattic/components';
2
1
  import { Button, Icon } from '@wordpress/components';
3
2
  import { __, isRTL, sprintf } from '@wordpress/i18n';
4
3
  import { check, chevronLeft, chevronRight } from '@wordpress/icons';
4
+ import { Badge } from '@wordpress/ui';
5
5
  import clsx from 'clsx';
6
6
  import type { Task, Expandable } from '../types';
7
7
  import type { FC, Key } from 'react';
@@ -137,7 +137,11 @@ const ChecklistItem: FC< Props > = ( {
137
137
  <span className="screen-reader-text">{ getStatusText() }</span>
138
138
  <span aria-hidden="true">{ title }</span>
139
139
  </span>
140
- { task.badge_text ? <Badge type="info-blue">{ task.badge_text }</Badge> : null }
140
+ { task.badge_text ? (
141
+ <Badge className="badge" intent="informational">
142
+ { String( task.badge_text ) }
143
+ </Badge>
144
+ ) : null }
141
145
  { shouldDisplayTaskCounter && (
142
146
  <span className="checklist-item__counter">
143
147
  { task.repetition_count }/{ task.target_repetitions }
@@ -123,7 +123,8 @@
123
123
  // general styles
124
124
  .checklist-item__text {
125
125
  font-weight: 600;
126
- flex-grow: 1;
126
+ flex: 1 1 0%;
127
+ min-width: 0;
127
128
  text-align: left;
128
129
  }
129
130
 
@@ -236,6 +237,7 @@
236
237
  display: flex;
237
238
  line-height: 20px;
238
239
  width: 30px;
240
+ flex-shrink: 0;
239
241
  }
240
242
 
241
243
  .gridicon.checklist-item__chevron {
package/src/index.ts CHANGED
@@ -6,3 +6,5 @@ export { default as Launchpad } from './launchpad';
6
6
  export { setUpActionsForTasks } from './setup-actions';
7
7
  export * from './action-components';
8
8
  export * from './types';
9
+ export * from './use-launchpad';
10
+ export { setRequester } from './wpcom-request';
@@ -1,13 +1,13 @@
1
- import { useLaunchpad } from '@automattic/data-stores';
2
1
  import { type FC, useMemo } from 'react';
3
2
  import Checklist, { Placeholder as ChecklistPlaceHolder } from './checklist';
4
3
  import ChecklistItem from './checklist-item';
4
+ import { useLaunchpad, type UseLaunchpadOptions } from './use-launchpad';
5
5
  import { useTracking } from './use-tracking';
6
+ import type { LaunchpadSiteDetails } from './site-type';
6
7
  import type { Task } from './types';
7
- import type { SiteDetails, UseLaunchpadOptions } from '@automattic/data-stores';
8
8
 
9
9
  interface Props {
10
- site?: SiteDetails | null;
10
+ site?: LaunchpadSiteDetails | null;
11
11
  siteSlug: string | null;
12
12
  checklistSlug: string | null;
13
13
  makeLastTaskPrimaryAction?: boolean;
package/src/launchpad.tsx CHANGED
@@ -1,19 +1,12 @@
1
1
  import { recordTracksEvent } from '@automattic/calypso-analytics';
2
- import {
3
- Site,
4
- type SiteSelect,
5
- defaultSuccessCallback,
6
- useSortedLaunchpadTasks,
7
- } from '@automattic/data-stores';
8
- import { useSelect } from '@wordpress/data';
9
2
  import { useState } from 'react';
10
3
  import { ShareSiteModal } from './action-components';
11
4
  import LaunchpadInternal from './launchpad-internal';
12
5
  import { setUpActionsForTasks } from './setup-actions';
6
+ import { defaultSuccessCallback, useSortedLaunchpadTasks } from './use-launchpad';
7
+ import { useSite } from './use-site';
13
8
  import type { EventHandlers, Task } from './types';
14
9
 
15
- export const SITE_STORE = Site.register( { client_id: '', client_secret: '' } );
16
-
17
10
  type LaunchpadProps = {
18
11
  siteSlug: string | null;
19
12
  checklistSlug: string;
@@ -41,12 +34,7 @@ const Launchpad = ( {
41
34
 
42
35
  const tracksData = { recordTracksEvent, checklistSlug, tasklistCompleted, launchpadContext };
43
36
 
44
- const site = useSelect(
45
- ( select ) => {
46
- return siteSlug ? ( select( SITE_STORE ) as SiteSelect ).getSite( siteSlug ) : null;
47
- },
48
- [ siteSlug ]
49
- );
37
+ const site = useSite( siteSlug );
50
38
  const [ shareSiteModalIsOpen, setShareSiteModalIsOpen ] = useState( false );
51
39
 
52
40
  const taskFilter = ( tasks: Task[] ) => {
@@ -1,8 +1,7 @@
1
- import { updateLaunchpadSettings } from '@automattic/data-stores';
2
1
  import { localizeUrl } from '@automattic/i18n-utils';
3
2
  import { isMobile } from '@automattic/viewport';
4
- import { addQueryArgs } from '@wordpress/url';
5
3
  import wpcomRequest from 'wpcom-proxy-request';
4
+ import { updateLaunchpadSettings } from './use-launchpad';
6
5
  import type { LaunchpadTaskActionsProps, Task } from './types';
7
6
 
8
7
  const TASKS_TO_COMPLETE_ON_CLICK = [
@@ -38,8 +37,14 @@ export const setUpActionsForTasks = ( {
38
37
  const hasCalypsoPath = task.calypso_path !== undefined;
39
38
 
40
39
  if ( uiContext === 'calypso' && hasCalypsoPath ) {
41
- if ( task.id === 'drive_traffic' && ! isMobile() && hasCalypsoPath ) {
42
- task.calypso_path = addQueryArgs( task.calypso_path, { tour: 'marketingConnectionsTour' } );
40
+ const { calypso_path } = task;
41
+ if ( task.id === 'drive_traffic' && ! isMobile() && calypso_path !== undefined ) {
42
+ // Merge the query via a throwaway base, but keep the original string as the base so
43
+ // absolute origins survive, then re-append any fragment.
44
+ const params = new URL( calypso_path, 'http://example.com' ).searchParams;
45
+ params.set( 'tour', 'marketingConnectionsTour' );
46
+ const [ baseAndQuery, fragment = '' ] = calypso_path.split( /(#.*)/s );
47
+ task.calypso_path = `${ baseAndQuery.split( '?' )[ 0 ] }?${ params }${ fragment }`;
43
48
  }
44
49
 
45
50
  // Enable task in 'calypso' context
@@ -0,0 +1,9 @@
1
+ /** A full `SiteDetails` satisfies this. */
2
+ export interface LaunchpadSiteDetails {
3
+ slug?: string;
4
+ URL?: string;
5
+ options?: {
6
+ site_intent?: string;
7
+ site_goals?: string[];
8
+ };
9
+ }
@@ -8,7 +8,9 @@ import type { Task } from '../types';
8
8
 
9
9
  jest.mock( '@automattic/calypso-analytics' );
10
10
 
11
- jest.mock( '@automattic/data-stores', () => {
11
+ jest.mock( '../use-launchpad', () => {
12
+ // jest.mock factories are hoisted above imports, so the fixture has to be required here.
13
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
14
  const { buildTask } = require( './lib/fixtures' );
13
15
  return {
14
16
  useLaunchpad: jest.fn( () => {
@@ -1,7 +1,6 @@
1
- import { SiteDetails } from '@automattic/data-stores/src/site';
2
1
  import { Task } from '../../types';
3
2
 
4
- export const defaultSiteDetails: SiteDetails = {
3
+ export const defaultSiteDetails = {
5
4
  ID: 211078228,
6
5
  title: 'Test Newsletter',
7
6
  name: 'testNewsletter',
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ import { setUpActionsForTasks } from '../setup-actions';
5
+ import type { LaunchpadTaskActionsProps } from '../types';
6
+
7
+ jest.mock( '@automattic/viewport', () => ( { isMobile: jest.fn( () => false ) } ) );
8
+ jest.mock( '../use-launchpad', () => ( { updateLaunchpadSettings: jest.fn() } ) );
9
+
10
+ const runDriveTraffic = ( calypso_path: string ) => {
11
+ const props: LaunchpadTaskActionsProps = {
12
+ siteSlug: 'example.wordpress.com',
13
+ tasks: [ { id: 'drive_traffic', completed: false, disabled: false, calypso_path } ],
14
+ tracksData: {
15
+ checklistSlug: 'test',
16
+ launchpadContext: 'test',
17
+ recordTracksEvent: jest.fn(),
18
+ tasklistCompleted: false,
19
+ },
20
+ extraActions: {},
21
+ uiContext: 'calypso',
22
+ };
23
+ return setUpActionsForTasks( props )[ 0 ].calypso_path;
24
+ };
25
+
26
+ describe( 'setUpActionsForTasks: drive_traffic tour query arg', () => {
27
+ it( 'appends the tour arg to a relative path', () => {
28
+ expect( runDriveTraffic( '/marketing/connections/example.wordpress.com' ) ).toBe(
29
+ '/marketing/connections/example.wordpress.com?tour=marketingConnectionsTour'
30
+ );
31
+ } );
32
+
33
+ it( 'preserves the origin and existing query of an absolute URL', () => {
34
+ expect( runDriveTraffic( 'https://example.com/wp-admin/admin.php?page=jetpack-social' ) ).toBe(
35
+ 'https://example.com/wp-admin/admin.php?page=jetpack-social&tour=marketingConnectionsTour'
36
+ );
37
+ } );
38
+
39
+ it( 'keeps the fragment after the query', () => {
40
+ expect( runDriveTraffic( '/marketing/connections/example.wordpress.com#section' ) ).toBe(
41
+ '/marketing/connections/example.wordpress.com?tour=marketingConnectionsTour#section'
42
+ );
43
+ } );
44
+ } );