@atlaskit/teams-app-internal-analytics 1.0.0 → 1.2.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.
package/CHANGELOG.md CHANGED
@@ -1 +1,19 @@
1
1
  # @atlaskit/teams-app-internal-analytics
2
+
3
+ ## 1.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`a897954343b87`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a897954343b87) -
8
+ Migrated analytics test util
9
+
10
+ ## 1.1.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`d8ea7dc8dc0e1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d8ea7dc8dc0e1) -
15
+ Removed test util export
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
@@ -16,7 +16,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
16
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
17
  var defaultAnalyticsContextData = exports.defaultAnalyticsContextData = {
18
18
  packageName: "@atlaskit/teams-app-internal-analytics",
19
- packageVersion: "0.0.0"
19
+ packageVersion: "1.2.0"
20
20
  };
21
21
  function TeamsAppAnalyticsContext(_ref) {
22
22
  var data = _ref.data,
@@ -2,7 +2,7 @@ import React, { useMemo } from 'react';
2
2
  import { PeopleTeamsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
3
3
  export const defaultAnalyticsContextData = {
4
4
  packageName: "@atlaskit/teams-app-internal-analytics",
5
- packageVersion: "0.0.0"
5
+ packageVersion: "1.2.0"
6
6
  };
7
7
  export function TeamsAppAnalyticsContext({
8
8
  data,
@@ -6,7 +6,7 @@ import React, { useMemo } from 'react';
6
6
  import { PeopleTeamsAnalyticsContext } from '@atlaskit/analytics-namespaced-context';
7
7
  export var defaultAnalyticsContextData = {
8
8
  packageName: "@atlaskit/teams-app-internal-analytics",
9
- packageVersion: "0.0.0"
9
+ packageVersion: "1.2.0"
10
10
  };
11
11
  export function TeamsAppAnalyticsContext(_ref) {
12
12
  var data = _ref.data,
@@ -1,2 +1,3 @@
1
1
  export { TeamsAppAnalyticsContext } from './ui/analytics-context';
2
2
  export { useAnalyticsEvents } from './common/utils/generated/use-analytics-events';
3
+ export type { AnalyticsEventAttributes } from './common/utils/generated/analytics.types';
@@ -1,2 +1,3 @@
1
1
  export { TeamsAppAnalyticsContext } from './ui/analytics-context';
2
2
  export { useAnalyticsEvents } from './common/utils/generated/use-analytics-events';
3
+ export type { AnalyticsEventAttributes } from './common/utils/generated/analytics.types';
package/package.json CHANGED
@@ -43,6 +43,7 @@
43
43
  "@af/integration-testing": "workspace:^",
44
44
  "@af/visual-regression": "workspace:^",
45
45
  "@atlaskit/ssr": "workspace:^",
46
+ "@atlassian/ptc-test-utils": "^0.10.0",
46
47
  "@testing-library/react": "^13.4.0",
47
48
  "@testing-library/react-hooks": "^8.0.1",
48
49
  "@testing-library/user-event": "^14.4.3",
@@ -87,7 +88,7 @@
87
88
  }
88
89
  },
89
90
  "name": "@atlaskit/teams-app-internal-analytics",
90
- "version": "1.0.0",
91
+ "version": "1.2.0",
91
92
  "description": "A package used by the teams app and platform packages to handle people and teams analytics",
92
93
  "author": "Atlassian Pty Ltd",
93
94
  "license": "Apache-2.0",
@@ -1,102 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.renderWithAnalyticsListener = exports.createMockAnalyticsClient = void 0;
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _react = _interopRequireDefault(require("react"));
11
- var _react2 = require("@testing-library/react");
12
- var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
13
- var _analyticsListeners = _interopRequireWildcard(require("@atlaskit/analytics-listeners"));
14
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
15
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
- /**
18
- * Creates a mock analytics client for testing
19
- */
20
- var createMockAnalyticsClient = exports.createMockAnalyticsClient = function createMockAnalyticsClient() {
21
- return {
22
- sendUIEvent: jest.fn(),
23
- sendOperationalEvent: jest.fn(),
24
- sendTrackEvent: jest.fn(),
25
- sendScreenEvent: jest.fn()
26
- };
27
- };
28
-
29
- /**
30
- * Test utility for testing analytics payloads end-to-end.
31
- * Renders children with analytics listener and provides mock client for event verification.
32
- *
33
- * @example
34
- * ```tsx
35
- * const { user, mockClient, expectEventToBeFired } = renderWithAnalyticsListener({
36
- * children: (
37
- * <PeopleTeamsAnalyticsContext data={{ source: 'teamsApp' }}>
38
- * <ButtonWithAnalytics eventType="ui" testId="button-with-analytics"/>
39
- * </PeopleTeamsAnalyticsContext>
40
- * )
41
- * });
42
- *
43
- * // Test triggers event however it needs to
44
- * const button = screen.getByTestId('button-with-analytics');
45
- * await act(() => user.click(button));
46
- *
47
- * // Option 1: Use the helper function
48
- * expectEventToBeFired('ui', {
49
- * action: 'clicked',
50
- * source: 'teamsApp',
51
- * attributes: expect.objectContaining({
52
- * packageName: expect.any(String)
53
- * })
54
- * });
55
- *
56
- * // Option 2: Use mockClient directly for more control
57
- * expect(mockClient.sendUIEvent).toHaveBeenCalledWith(
58
- * expect.objectContaining({ source: 'teamsApp' })
59
- * );
60
- * ```
61
- */
62
- var renderWithAnalyticsListener = exports.renderWithAnalyticsListener = function renderWithAnalyticsListener(ui, options) {
63
- var _ref = options || {},
64
- setup = _ref.setup,
65
- providedMockClient = _ref.mockClient;
66
- if (setup) {
67
- setup();
68
- }
69
- var mockClient = providedMockClient || createMockAnalyticsClient();
70
- var user = _userEvent.default.setup();
71
- var renderResult = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_analyticsListeners.default, {
72
- excludedChannels: Object.values(_analyticsListeners.FabricChannel).filter(function (channel) {
73
- return channel !== _analyticsListeners.FabricChannel.peopleTeams;
74
- }),
75
- client: mockClient
76
- }, ui));
77
- var expectEventToBeFired = function expectEventToBeFired(eventType, expectedPayload) {
78
- var getMockForEventType = function getMockForEventType(type) {
79
- switch (type) {
80
- case 'ui':
81
- return mockClient.sendUIEvent;
82
- case 'operational':
83
- return mockClient.sendOperationalEvent;
84
- case 'track':
85
- return mockClient.sendTrackEvent;
86
- case 'screen':
87
- return mockClient.sendScreenEvent;
88
- default:
89
- throw new Error("Unsupported event type: ".concat(type));
90
- }
91
- };
92
- var targetMock = getMockForEventType(eventType);
93
- expect(targetMock).toHaveBeenCalledWith(expect.objectContaining(_objectSpread(_objectSpread({}, expectedPayload), {}, {
94
- attributes: expect.objectContaining(expectedPayload.attributes || {})
95
- })));
96
- };
97
- return _objectSpread(_objectSpread({}, renderResult), {}, {
98
- user: user,
99
- mockClient: mockClient,
100
- expectEventToBeFired: expectEventToBeFired
101
- });
102
- };
@@ -1,89 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import FabricAnalyticsListeners, { FabricChannel } from '@atlaskit/analytics-listeners';
5
- /**
6
- * Creates a mock analytics client for testing
7
- */
8
- export const createMockAnalyticsClient = () => ({
9
- sendUIEvent: jest.fn(),
10
- sendOperationalEvent: jest.fn(),
11
- sendTrackEvent: jest.fn(),
12
- sendScreenEvent: jest.fn()
13
- });
14
-
15
- /**
16
- * Test utility for testing analytics payloads end-to-end.
17
- * Renders children with analytics listener and provides mock client for event verification.
18
- *
19
- * @example
20
- * ```tsx
21
- * const { user, mockClient, expectEventToBeFired } = renderWithAnalyticsListener({
22
- * children: (
23
- * <PeopleTeamsAnalyticsContext data={{ source: 'teamsApp' }}>
24
- * <ButtonWithAnalytics eventType="ui" testId="button-with-analytics"/>
25
- * </PeopleTeamsAnalyticsContext>
26
- * )
27
- * });
28
- *
29
- * // Test triggers event however it needs to
30
- * const button = screen.getByTestId('button-with-analytics');
31
- * await act(() => user.click(button));
32
- *
33
- * // Option 1: Use the helper function
34
- * expectEventToBeFired('ui', {
35
- * action: 'clicked',
36
- * source: 'teamsApp',
37
- * attributes: expect.objectContaining({
38
- * packageName: expect.any(String)
39
- * })
40
- * });
41
- *
42
- * // Option 2: Use mockClient directly for more control
43
- * expect(mockClient.sendUIEvent).toHaveBeenCalledWith(
44
- * expect.objectContaining({ source: 'teamsApp' })
45
- * );
46
- * ```
47
- */
48
- export const renderWithAnalyticsListener = (ui, options) => {
49
- const {
50
- setup,
51
- mockClient: providedMockClient
52
- } = options || {};
53
- if (setup) {
54
- setup();
55
- }
56
- const mockClient = providedMockClient || createMockAnalyticsClient();
57
- const user = userEvent.setup();
58
- const renderResult = render( /*#__PURE__*/React.createElement(FabricAnalyticsListeners, {
59
- excludedChannels: Object.values(FabricChannel).filter(channel => channel !== FabricChannel.peopleTeams),
60
- client: mockClient
61
- }, ui));
62
- const expectEventToBeFired = (eventType, expectedPayload) => {
63
- const getMockForEventType = type => {
64
- switch (type) {
65
- case 'ui':
66
- return mockClient.sendUIEvent;
67
- case 'operational':
68
- return mockClient.sendOperationalEvent;
69
- case 'track':
70
- return mockClient.sendTrackEvent;
71
- case 'screen':
72
- return mockClient.sendScreenEvent;
73
- default:
74
- throw new Error(`Unsupported event type: ${type}`);
75
- }
76
- };
77
- const targetMock = getMockForEventType(eventType);
78
- expect(targetMock).toHaveBeenCalledWith(expect.objectContaining({
79
- ...expectedPayload,
80
- attributes: expect.objectContaining(expectedPayload.attributes || {})
81
- }));
82
- };
83
- return {
84
- ...renderResult,
85
- user,
86
- mockClient,
87
- expectEventToBeFired
88
- };
89
- };
@@ -1,93 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import React from 'react';
5
- import { render } from '@testing-library/react';
6
- import userEvent from '@testing-library/user-event';
7
- import FabricAnalyticsListeners, { FabricChannel } from '@atlaskit/analytics-listeners';
8
- /**
9
- * Creates a mock analytics client for testing
10
- */
11
- export var createMockAnalyticsClient = function createMockAnalyticsClient() {
12
- return {
13
- sendUIEvent: jest.fn(),
14
- sendOperationalEvent: jest.fn(),
15
- sendTrackEvent: jest.fn(),
16
- sendScreenEvent: jest.fn()
17
- };
18
- };
19
-
20
- /**
21
- * Test utility for testing analytics payloads end-to-end.
22
- * Renders children with analytics listener and provides mock client for event verification.
23
- *
24
- * @example
25
- * ```tsx
26
- * const { user, mockClient, expectEventToBeFired } = renderWithAnalyticsListener({
27
- * children: (
28
- * <PeopleTeamsAnalyticsContext data={{ source: 'teamsApp' }}>
29
- * <ButtonWithAnalytics eventType="ui" testId="button-with-analytics"/>
30
- * </PeopleTeamsAnalyticsContext>
31
- * )
32
- * });
33
- *
34
- * // Test triggers event however it needs to
35
- * const button = screen.getByTestId('button-with-analytics');
36
- * await act(() => user.click(button));
37
- *
38
- * // Option 1: Use the helper function
39
- * expectEventToBeFired('ui', {
40
- * action: 'clicked',
41
- * source: 'teamsApp',
42
- * attributes: expect.objectContaining({
43
- * packageName: expect.any(String)
44
- * })
45
- * });
46
- *
47
- * // Option 2: Use mockClient directly for more control
48
- * expect(mockClient.sendUIEvent).toHaveBeenCalledWith(
49
- * expect.objectContaining({ source: 'teamsApp' })
50
- * );
51
- * ```
52
- */
53
- export var renderWithAnalyticsListener = function renderWithAnalyticsListener(ui, options) {
54
- var _ref = options || {},
55
- setup = _ref.setup,
56
- providedMockClient = _ref.mockClient;
57
- if (setup) {
58
- setup();
59
- }
60
- var mockClient = providedMockClient || createMockAnalyticsClient();
61
- var user = userEvent.setup();
62
- var renderResult = render( /*#__PURE__*/React.createElement(FabricAnalyticsListeners, {
63
- excludedChannels: Object.values(FabricChannel).filter(function (channel) {
64
- return channel !== FabricChannel.peopleTeams;
65
- }),
66
- client: mockClient
67
- }, ui));
68
- var expectEventToBeFired = function expectEventToBeFired(eventType, expectedPayload) {
69
- var getMockForEventType = function getMockForEventType(type) {
70
- switch (type) {
71
- case 'ui':
72
- return mockClient.sendUIEvent;
73
- case 'operational':
74
- return mockClient.sendOperationalEvent;
75
- case 'track':
76
- return mockClient.sendTrackEvent;
77
- case 'screen':
78
- return mockClient.sendScreenEvent;
79
- default:
80
- throw new Error("Unsupported event type: ".concat(type));
81
- }
82
- };
83
- var targetMock = getMockForEventType(eventType);
84
- expect(targetMock).toHaveBeenCalledWith(expect.objectContaining(_objectSpread(_objectSpread({}, expectedPayload), {}, {
85
- attributes: expect.objectContaining(expectedPayload.attributes || {})
86
- })));
87
- };
88
- return _objectSpread(_objectSpread({}, renderResult), {}, {
89
- user: user,
90
- mockClient: mockClient,
91
- expectEventToBeFired: expectEventToBeFired
92
- });
93
- };
@@ -1,107 +0,0 @@
1
- import React from 'react';
2
- import type { EventType } from '@atlaskit/analytics-gas-types';
3
- import { type AnalyticsWebClient } from '@atlaskit/analytics-listeners';
4
- import type { AnalyticsEventPayload } from '@atlaskit/analytics-next';
5
- interface AnalyticsTestUtilOptions {
6
- /** Additional setup before rendering */
7
- setup?: () => void;
8
- /** Optional mock client to use instead of creating a new one */
9
- mockClient?: AnalyticsWebClient;
10
- }
11
- /**
12
- * Creates a mock analytics client for testing
13
- */
14
- export declare const createMockAnalyticsClient: () => AnalyticsWebClient;
15
- /**
16
- * Test utility for testing analytics payloads end-to-end.
17
- * Renders children with analytics listener and provides mock client for event verification.
18
- *
19
- * @example
20
- * ```tsx
21
- * const { user, mockClient, expectEventToBeFired } = renderWithAnalyticsListener({
22
- * children: (
23
- * <PeopleTeamsAnalyticsContext data={{ source: 'teamsApp' }}>
24
- * <ButtonWithAnalytics eventType="ui" testId="button-with-analytics"/>
25
- * </PeopleTeamsAnalyticsContext>
26
- * )
27
- * });
28
- *
29
- * // Test triggers event however it needs to
30
- * const button = screen.getByTestId('button-with-analytics');
31
- * await act(() => user.click(button));
32
- *
33
- * // Option 1: Use the helper function
34
- * expectEventToBeFired('ui', {
35
- * action: 'clicked',
36
- * source: 'teamsApp',
37
- * attributes: expect.objectContaining({
38
- * packageName: expect.any(String)
39
- * })
40
- * });
41
- *
42
- * // Option 2: Use mockClient directly for more control
43
- * expect(mockClient.sendUIEvent).toHaveBeenCalledWith(
44
- * expect.objectContaining({ source: 'teamsApp' })
45
- * );
46
- * ```
47
- */
48
- export declare const renderWithAnalyticsListener: (ui: React.ReactElement, options?: AnalyticsTestUtilOptions) => {
49
- user: import("@testing-library/user-event").UserEvent;
50
- mockClient: AnalyticsWebClient;
51
- expectEventToBeFired: (eventType: EventType, expectedPayload: AnalyticsEventPayload) => void;
52
- container: HTMLElement;
53
- baseElement: HTMLElement;
54
- debug: (baseElement?: Element | DocumentFragment | Array<Element | DocumentFragment>, maxLength?: number, options?: import("pretty-format").OptionsReceived) => void;
55
- rerender: (ui: React.ReactElement) => void;
56
- unmount: () => void;
57
- asFragment: () => DocumentFragment;
58
- getByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
59
- getAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
60
- queryByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
61
- queryAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
62
- findByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
63
- findAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
64
- getByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
65
- getAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
66
- queryByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
67
- queryAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
68
- findByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
69
- findAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
70
- getByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
71
- getAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
72
- queryByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
73
- queryAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
74
- findByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
75
- findAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
76
- getByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
77
- getAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
78
- queryByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
79
- queryAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
80
- findByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
81
- findAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
82
- getByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
83
- getAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
84
- queryByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
85
- queryAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
86
- findByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
87
- findAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
88
- getByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
89
- getAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
90
- queryByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
91
- queryAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
92
- findByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
93
- findAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
94
- getByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement;
95
- getAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
96
- queryByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement | null;
97
- queryAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
98
- findByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
99
- findAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
100
- getByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
101
- getAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
102
- queryByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
103
- queryAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
104
- findByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
105
- findAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
106
- };
107
- export {};
@@ -1,107 +0,0 @@
1
- import React from 'react';
2
- import type { EventType } from '@atlaskit/analytics-gas-types';
3
- import { type AnalyticsWebClient } from '@atlaskit/analytics-listeners';
4
- import type { AnalyticsEventPayload } from '@atlaskit/analytics-next';
5
- interface AnalyticsTestUtilOptions {
6
- /** Additional setup before rendering */
7
- setup?: () => void;
8
- /** Optional mock client to use instead of creating a new one */
9
- mockClient?: AnalyticsWebClient;
10
- }
11
- /**
12
- * Creates a mock analytics client for testing
13
- */
14
- export declare const createMockAnalyticsClient: () => AnalyticsWebClient;
15
- /**
16
- * Test utility for testing analytics payloads end-to-end.
17
- * Renders children with analytics listener and provides mock client for event verification.
18
- *
19
- * @example
20
- * ```tsx
21
- * const { user, mockClient, expectEventToBeFired } = renderWithAnalyticsListener({
22
- * children: (
23
- * <PeopleTeamsAnalyticsContext data={{ source: 'teamsApp' }}>
24
- * <ButtonWithAnalytics eventType="ui" testId="button-with-analytics"/>
25
- * </PeopleTeamsAnalyticsContext>
26
- * )
27
- * });
28
- *
29
- * // Test triggers event however it needs to
30
- * const button = screen.getByTestId('button-with-analytics');
31
- * await act(() => user.click(button));
32
- *
33
- * // Option 1: Use the helper function
34
- * expectEventToBeFired('ui', {
35
- * action: 'clicked',
36
- * source: 'teamsApp',
37
- * attributes: expect.objectContaining({
38
- * packageName: expect.any(String)
39
- * })
40
- * });
41
- *
42
- * // Option 2: Use mockClient directly for more control
43
- * expect(mockClient.sendUIEvent).toHaveBeenCalledWith(
44
- * expect.objectContaining({ source: 'teamsApp' })
45
- * );
46
- * ```
47
- */
48
- export declare const renderWithAnalyticsListener: (ui: React.ReactElement, options?: AnalyticsTestUtilOptions) => {
49
- user: import("@testing-library/user-event").UserEvent;
50
- mockClient: AnalyticsWebClient;
51
- expectEventToBeFired: (eventType: EventType, expectedPayload: AnalyticsEventPayload) => void;
52
- container: HTMLElement;
53
- baseElement: HTMLElement;
54
- debug: (baseElement?: Element | DocumentFragment | Array<Element | DocumentFragment>, maxLength?: number, options?: import("pretty-format").OptionsReceived) => void;
55
- rerender: (ui: React.ReactElement) => void;
56
- unmount: () => void;
57
- asFragment: () => DocumentFragment;
58
- getByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
59
- getAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
60
- queryByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
61
- queryAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
62
- findByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
63
- findAllByLabelText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
64
- getByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
65
- getAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
66
- queryByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
67
- queryAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
68
- findByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
69
- findAllByPlaceholderText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
70
- getByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement;
71
- getAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
72
- queryByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement | null;
73
- queryAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined) => HTMLElement[];
74
- findByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
75
- findAllByText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").SelectorMatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
76
- getByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
77
- getAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
78
- queryByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
79
- queryAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
80
- findByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
81
- findAllByAltText: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
82
- getByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
83
- getAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
84
- queryByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
85
- queryAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
86
- findByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
87
- findAllByTitle: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
88
- getByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
89
- getAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
90
- queryByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
91
- queryAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
92
- findByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
93
- findAllByDisplayValue: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
94
- getByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement;
95
- getAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
96
- queryByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement | null;
97
- queryAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined) => HTMLElement[];
98
- findByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
99
- findAllByRole: (role: import("@testing-library/react").ByRoleMatcher, options?: import("@testing-library/react").ByRoleOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
100
- getByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement;
101
- getAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
102
- queryByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement | null;
103
- queryAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined) => HTMLElement[];
104
- findByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement>;
105
- findAllByTestId: (id: import("@testing-library/react").Matcher, options?: import("@testing-library/react").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/react").waitForOptions | undefined) => Promise<HTMLElement[]>;
106
- };
107
- export {};
@@ -1,17 +0,0 @@
1
- {
2
- "name": "@atlaskit/teams-app-internal-analytics/test-utils",
3
- "main": "../dist/cjs/common/test-utils/index.js",
4
- "module": "../dist/esm/common/test-utils/index.js",
5
- "module:es2019": "../dist/es2019/common/test-utils/index.js",
6
- "sideEffects": [
7
- "*.compiled.css"
8
- ],
9
- "types": "../dist/types/common/test-utils/index.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/common/test-utils/index.d.ts"
14
- ]
15
- }
16
- }
17
- }