@brightcove/components-embed-code-modal 1.1.0 → 1.1.2

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 (187) hide show
  1. package/__tests__/PrismPlayerControls.test.d.ts +2 -0
  2. package/__tests__/PrismPlayerControls.test.d.ts.map +1 -0
  3. package/{build/index.js → index.js} +1 -1
  4. package/index.js.map +1 -0
  5. package/package.json +5 -15
  6. package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts.map +1 -1
  7. package/.eslintignore +0 -7
  8. package/.eslintrc +0 -23
  9. package/.github/workflows/ci.yml +0 -23
  10. package/.husky/pre-commit +0 -4
  11. package/.nvmrc +0 -1
  12. package/.prettierignore +0 -7
  13. package/.prettierrc +0 -5
  14. package/.release-it.json +0 -40
  15. package/.whitesource +0 -3
  16. package/CHANGELOG.md +0 -398
  17. package/CODEOWNERS +0 -37
  18. package/PULL_REQUEST_TEMPLATE.md +0 -17
  19. package/__tests__/EmbedCode.test.tsx +0 -51
  20. package/__tests__/InteractivityProject.test.tsx +0 -50
  21. package/__tests__/PlayerPreview.test.tsx +0 -23
  22. package/__tests__/PrismPlayerPreview.test.tsx +0 -168
  23. package/__tests__/TabsHeader.test.tsx +0 -19
  24. package/__tests__/TabsSection.test.tsx +0 -46
  25. package/__tests__/TitleWithTooltip.test.tsx +0 -45
  26. package/__tests__/VideoPlayer.test.tsx +0 -38
  27. package/__tests__/embedCodeGenerator.test.ts +0 -111
  28. package/__tests__/util.test.ts +0 -89
  29. package/babel.config.json +0 -17
  30. package/build/README.md +0 -109
  31. package/build/index.js.map +0 -1
  32. package/build/package.json +0 -100
  33. package/etc/wildcard.brightcove.com.key +0 -27
  34. package/etc/wildcard.brightcove.com.pem +0 -96
  35. package/jest/jest.setup.js +0 -90
  36. package/jest/jest.stub.js +0 -4
  37. package/jest.config.js +0 -24
  38. package/scripts/create-dist-pkg-prod.js +0 -18
  39. package/src/index.ts +0 -17
  40. package/src/js/EmbedCodeModal.tsx +0 -105
  41. package/src/js/components/CustomSettingsDropdown.tsx +0 -184
  42. package/src/js/components/EmbedCopySection.tsx +0 -130
  43. package/src/js/components/ModalContainer.tsx +0 -367
  44. package/src/js/components/NoPlayerModal.tsx +0 -42
  45. package/src/js/components/PlayerPreview.tsx +0 -116
  46. package/src/js/components/TabsHeader.tsx +0 -31
  47. package/src/js/components/TabsSection.tsx +0 -74
  48. package/src/js/components/TitleWithTooltip.tsx +0 -39
  49. package/src/js/components/VideoLinks.tsx +0 -83
  50. package/src/js/components/VideoPlayer.tsx +0 -324
  51. package/src/js/components/index.ts +0 -9
  52. package/src/js/components/prism/PrismLiveModal.tsx +0 -162
  53. package/src/js/components/prism/PrismPlayerControls.tsx +0 -343
  54. package/src/js/components/prism/PrismPlayerPreview.tsx +0 -188
  55. package/src/js/components/prism/index.ts +0 -3
  56. package/src/js/constants/baseUrls.ts +0 -4
  57. package/src/js/constants/embed.ts +0 -12
  58. package/src/js/constants/player.ts +0 -32
  59. package/src/js/constants/pluginsRegistry.ts +0 -30
  60. package/src/js/hooks/useGetPlayers.ts +0 -12
  61. package/src/js/i18n.ts +0 -43
  62. package/src/js/services/players-api.ts +0 -26
  63. package/src/js/services/url-shortener.ts +0 -10
  64. package/src/js/types/EmbedCodeModalProps.ts +0 -72
  65. package/src/js/types/EmbedCodeProps.ts +0 -13
  66. package/src/js/types/brightcoveEmbedCode.d.ts +0 -18
  67. package/src/js/types/players.ts +0 -64
  68. package/src/js/types/react-i18next.d.ts +0 -8
  69. package/src/js/types/studioModule.ts +0 -7
  70. package/src/js/utils/addPluginsDataToPlayers.ts +0 -59
  71. package/src/js/utils/call.ts +0 -31
  72. package/src/js/utils/dimensions.ts +0 -53
  73. package/src/js/utils/embedCodeGenerator.ts +0 -120
  74. package/src/js/utils/featureSwitches.ts +0 -16
  75. package/src/js/utils/util.ts +0 -153
  76. package/src/module.tsx +0 -280
  77. package/src/styles/CustomSettingsDropdown.sass +0 -42
  78. package/src/styles/EmbedCode.sass +0 -30
  79. package/src/styles/EmbedCodeModal.sass +0 -76
  80. package/src/styles/base.sass +0 -1
  81. package/src/styles/prism/PrismLiveModal.sass +0 -155
  82. package/src/styles/theme.sass +0 -11
  83. package/src/styles/typings.td.ts +0 -9
  84. package/src/translations/en.json +0 -65
  85. package/src/translations/es.json +0 -65
  86. package/src/translations/fr.json +0 -65
  87. package/src/translations/ja.json +0 -65
  88. package/src/translations/ko.json +0 -65
  89. package/src/translations/zh.json +0 -65
  90. package/src/types/studio.ts +0 -197
  91. package/tsconfig.json +0 -34
  92. package/webpack.config.js +0 -117
  93. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts +0 -0
  94. /package/{build/__tests__ → __tests__}/EmbedCode.test.d.ts.map +0 -0
  95. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts +0 -0
  96. /package/{build/__tests__ → __tests__}/InteractivityProject.test.d.ts.map +0 -0
  97. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts +0 -0
  98. /package/{build/__tests__ → __tests__}/PlayerPreview.test.d.ts.map +0 -0
  99. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts +0 -0
  100. /package/{build/__tests__ → __tests__}/PrismPlayerPreview.test.d.ts.map +0 -0
  101. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts +0 -0
  102. /package/{build/__tests__ → __tests__}/TabsHeader.test.d.ts.map +0 -0
  103. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts +0 -0
  104. /package/{build/__tests__ → __tests__}/TabsSection.test.d.ts.map +0 -0
  105. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts +0 -0
  106. /package/{build/__tests__ → __tests__}/TitleWithTooltip.test.d.ts.map +0 -0
  107. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts +0 -0
  108. /package/{build/__tests__ → __tests__}/VideoPlayer.test.d.ts.map +0 -0
  109. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts +0 -0
  110. /package/{build/__tests__ → __tests__}/embedCodeGenerator.test.d.ts.map +0 -0
  111. /package/{build/__tests__ → __tests__}/util.test.d.ts +0 -0
  112. /package/{build/__tests__ → __tests__}/util.test.d.ts.map +0 -0
  113. /package/{build/src → src}/index.d.ts +0 -0
  114. /package/{build/src → src}/index.d.ts.map +0 -0
  115. /package/{build/src → src}/js/EmbedCodeModal.d.ts +0 -0
  116. /package/{build/src → src}/js/EmbedCodeModal.d.ts.map +0 -0
  117. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts +0 -0
  118. /package/{build/src → src}/js/components/CustomSettingsDropdown.d.ts.map +0 -0
  119. /package/{build/src → src}/js/components/EmbedCopySection.d.ts +0 -0
  120. /package/{build/src → src}/js/components/EmbedCopySection.d.ts.map +0 -0
  121. /package/{build/src → src}/js/components/ModalContainer.d.ts +0 -0
  122. /package/{build/src → src}/js/components/ModalContainer.d.ts.map +0 -0
  123. /package/{build/src → src}/js/components/NoPlayerModal.d.ts +0 -0
  124. /package/{build/src → src}/js/components/NoPlayerModal.d.ts.map +0 -0
  125. /package/{build/src → src}/js/components/PlayerPreview.d.ts +0 -0
  126. /package/{build/src → src}/js/components/PlayerPreview.d.ts.map +0 -0
  127. /package/{build/src → src}/js/components/TabsHeader.d.ts +0 -0
  128. /package/{build/src → src}/js/components/TabsHeader.d.ts.map +0 -0
  129. /package/{build/src → src}/js/components/TabsSection.d.ts +0 -0
  130. /package/{build/src → src}/js/components/TabsSection.d.ts.map +0 -0
  131. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts +0 -0
  132. /package/{build/src → src}/js/components/TitleWithTooltip.d.ts.map +0 -0
  133. /package/{build/src → src}/js/components/VideoLinks.d.ts +0 -0
  134. /package/{build/src → src}/js/components/VideoLinks.d.ts.map +0 -0
  135. /package/{build/src → src}/js/components/VideoPlayer.d.ts +0 -0
  136. /package/{build/src → src}/js/components/VideoPlayer.d.ts.map +0 -0
  137. /package/{build/src → src}/js/components/index.d.ts +0 -0
  138. /package/{build/src → src}/js/components/index.d.ts.map +0 -0
  139. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts +0 -0
  140. /package/{build/src → src}/js/components/prism/PrismLiveModal.d.ts.map +0 -0
  141. /package/{build/src → src}/js/components/prism/PrismPlayerControls.d.ts +0 -0
  142. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts +0 -0
  143. /package/{build/src → src}/js/components/prism/PrismPlayerPreview.d.ts.map +0 -0
  144. /package/{build/src → src}/js/components/prism/index.d.ts +0 -0
  145. /package/{build/src → src}/js/components/prism/index.d.ts.map +0 -0
  146. /package/{build/src → src}/js/constants/baseUrls.d.ts +0 -0
  147. /package/{build/src → src}/js/constants/baseUrls.d.ts.map +0 -0
  148. /package/{build/src → src}/js/constants/embed.d.ts +0 -0
  149. /package/{build/src → src}/js/constants/embed.d.ts.map +0 -0
  150. /package/{build/src → src}/js/constants/player.d.ts +0 -0
  151. /package/{build/src → src}/js/constants/player.d.ts.map +0 -0
  152. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts +0 -0
  153. /package/{build/src → src}/js/constants/pluginsRegistry.d.ts.map +0 -0
  154. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts +0 -0
  155. /package/{build/src → src}/js/hooks/useGetPlayers.d.ts.map +0 -0
  156. /package/{build/src → src}/js/i18n.d.ts +0 -0
  157. /package/{build/src → src}/js/i18n.d.ts.map +0 -0
  158. /package/{build/src → src}/js/services/players-api.d.ts +0 -0
  159. /package/{build/src → src}/js/services/players-api.d.ts.map +0 -0
  160. /package/{build/src → src}/js/services/url-shortener.d.ts +0 -0
  161. /package/{build/src → src}/js/services/url-shortener.d.ts.map +0 -0
  162. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts +0 -0
  163. /package/{build/src → src}/js/types/EmbedCodeModalProps.d.ts.map +0 -0
  164. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts +0 -0
  165. /package/{build/src → src}/js/types/EmbedCodeProps.d.ts.map +0 -0
  166. /package/{build/src → src}/js/types/players.d.ts +0 -0
  167. /package/{build/src → src}/js/types/players.d.ts.map +0 -0
  168. /package/{build/src → src}/js/types/studioModule.d.ts +0 -0
  169. /package/{build/src → src}/js/types/studioModule.d.ts.map +0 -0
  170. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts +0 -0
  171. /package/{build/src → src}/js/utils/addPluginsDataToPlayers.d.ts.map +0 -0
  172. /package/{build/src → src}/js/utils/call.d.ts +0 -0
  173. /package/{build/src → src}/js/utils/call.d.ts.map +0 -0
  174. /package/{build/src → src}/js/utils/dimensions.d.ts +0 -0
  175. /package/{build/src → src}/js/utils/dimensions.d.ts.map +0 -0
  176. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts +0 -0
  177. /package/{build/src → src}/js/utils/embedCodeGenerator.d.ts.map +0 -0
  178. /package/{build/src → src}/js/utils/featureSwitches.d.ts +0 -0
  179. /package/{build/src → src}/js/utils/featureSwitches.d.ts.map +0 -0
  180. /package/{build/src → src}/js/utils/util.d.ts +0 -0
  181. /package/{build/src → src}/js/utils/util.d.ts.map +0 -0
  182. /package/{build/src → src}/module.d.ts +0 -0
  183. /package/{build/src → src}/module.d.ts.map +0 -0
  184. /package/{build/src → src}/styles/typings.td.d.ts +0 -0
  185. /package/{build/src → src}/styles/typings.td.d.ts.map +0 -0
  186. /package/{build/src → src}/types/studio.d.ts +0 -0
  187. /package/{build/src → src}/types/studio.d.ts.map +0 -0
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import { ModalContainer } from '../src/js/components';
4
- import { EmbedCodeModalTypes } from '../src';
5
- import { QueryClientProvider, QueryClient } from 'react-query';
6
-
7
- const DEFAULT_MODAL_COMP = {
8
- videoId: '123',
9
- videoName: 'test video',
10
- accountId: '456',
11
- duration: 10,
12
- };
13
-
14
- const wrappedComponent = (children: React.ReactElement) => (
15
- <QueryClientProvider client={new QueryClient()}>
16
- {children}
17
- </QueryClientProvider>
18
- );
19
-
20
- const handleSetComponentKey = jest.fn;
21
- const handleSetHasCreatedPlayer = jest.fn;
22
-
23
- test('does not render player with wrong information but right type', () => {
24
- const { container } = render(
25
- wrappedComponent(
26
- <ModalContainer
27
- handleSetComponentKey={handleSetComponentKey}
28
- data={DEFAULT_MODAL_COMP}
29
- hasCreatedPlayer={false}
30
- handleSetHasCreatedPlayer={handleSetHasCreatedPlayer}
31
- embedCodeModalType={EmbedCodeModalTypes.PLAYER}
32
- />,
33
- ),
34
- );
35
- expect(container.innerHTML).toBe('');
36
- });
37
-
38
- test('does not render project with wrong information but right type', () => {
39
- const { container } = render(
40
- wrappedComponent(
41
- <ModalContainer
42
- handleSetComponentKey={handleSetComponentKey}
43
- data={DEFAULT_MODAL_COMP}
44
- hasCreatedPlayer={false}
45
- handleSetHasCreatedPlayer={handleSetHasCreatedPlayer}
46
- embedCodeModalType={EmbedCodeModalTypes.PROJECT}
47
- />,
48
- ),
49
- );
50
- expect(container.innerHTML).toBe('');
51
- });
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import { QueryClientProvider, QueryClient } from 'react-query';
3
- import { render, screen } from '@testing-library/react';
4
- import { VideoPlayer } from 'js/components';
5
- import { EmbedCodeModalTypes } from 'js/types/EmbedCodeModalProps';
6
- import { PLAYER_LIST_FOR_SELECTION, PLAYERS } from 'js/constants/player';
7
-
8
- jest.mock('../src/js/utils/featureSwitches');
9
-
10
- const wrappedComponent = (children: React.ReactElement) => (
11
- <QueryClientProvider client={new QueryClient()}>
12
- {children}
13
- </QueryClientProvider>
14
- );
15
-
16
- const DEFAULT_MODAL_COMP = {
17
- videoId: '123',
18
- videoName: 'test video',
19
- interactivityProjectId: '9876',
20
- interactivityProjectName: 'test project',
21
- accountId: '456',
22
- duration: 10,
23
- };
24
-
25
- test('renders EmbedCodeModal component with right information', () => {
26
- render(
27
- wrappedComponent(
28
- <VideoPlayer
29
- video={DEFAULT_MODAL_COMP}
30
- embedCodeModalType={EmbedCodeModalTypes.PROJECT}
31
- playerListForSelection={PLAYER_LIST_FOR_SELECTION}
32
- players={PLAYERS}
33
- />,
34
- ),
35
- );
36
- expect(
37
- screen.getByText(DEFAULT_MODAL_COMP.interactivityProjectId),
38
- ).toBeInTheDocument();
39
- expect(
40
- screen.getByText(DEFAULT_MODAL_COMP.interactivityProjectName),
41
- ).toBeInTheDocument();
42
- expect(
43
- screen.queryByText(DEFAULT_MODAL_COMP.videoId),
44
- ).not.toBeInTheDocument();
45
- expect(
46
- screen.queryByText(DEFAULT_MODAL_COMP.videoName),
47
- ).not.toBeInTheDocument();
48
- expect(screen.getByRole('tab', { name: /javascript/i })).toBeInTheDocument();
49
- expect(screen.getByRole('tab', { name: /IFrame/i })).toBeInTheDocument();
50
- });
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import { PlayerPreview } from '../src/js/components';
4
- import { QueryClientProvider, QueryClient } from 'react-query';
5
-
6
- const DEFAULT_MODAL_COMP = {
7
- id: 'default',
8
- accountId: '456',
9
- };
10
-
11
- const wrappedComponent = (children: React.ReactElement) => (
12
- <QueryClientProvider client={new QueryClient()}>
13
- {children}
14
- </QueryClientProvider>
15
- );
16
-
17
- test('renders PlayerPreview component with right information', () => {
18
- render(wrappedComponent(<PlayerPreview {...DEFAULT_MODAL_COMP} />));
19
- expect(screen.getByText('getURL')).toBeInTheDocument();
20
- expect(screen.getByText('previewButton')).toBeInTheDocument();
21
- expect(screen.getByRole('tab', { name: /javascript/i })).toBeInTheDocument();
22
- expect(screen.getByRole('tab', { name: /IFrame/i })).toBeInTheDocument();
23
- });
@@ -1,168 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
- import { PrismPlayerPreview } from '../src/js/components/prism/PrismPlayerPreview';
4
- import { shortenUrl } from '../src/js/services/url-shortener';
5
-
6
- jest.mock('../src/js/services/url-shortener');
7
-
8
- const mockedShortenUrl = shortenUrl as jest.MockedFunction<typeof shortenUrl>;
9
-
10
- const PREVIEW_URL =
11
- 'https://players.brightcove.net/456/default_default/index.html?videoId=123&livePlaybackToken=abc';
12
- const SHORT_URL = 'https://bcove.video/4whTWpq';
13
-
14
- const DEFAULT_PROPS = {
15
- accountId: '456',
16
- playerId: 'default',
17
- videoId: '123',
18
- previewUrl: PREVIEW_URL,
19
- };
20
-
21
- const toaster = {
22
- success: jest.fn(),
23
- error: jest.fn(),
24
- };
25
-
26
- beforeEach(() => {
27
- Object.assign(window, { brightcove: { Toaster: toaster } });
28
- Object.assign(navigator, {
29
- clipboard: {
30
- writeText: jest.fn(() => Promise.resolve()),
31
- write: jest.fn(() => Promise.reject(new Error('unsupported'))),
32
- },
33
- });
34
- });
35
-
36
- afterEach(() => {
37
- jest.clearAllMocks();
38
- });
39
-
40
- const openCopyUrlMenu = () => {
41
- fireEvent.click(screen.getByRole('button', { name: /prism.copyURL/ }));
42
- };
43
-
44
- test('offers both a short and a full URL option', () => {
45
- render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
46
-
47
- openCopyUrlMenu();
48
-
49
- expect(screen.getByText('prism.shortURL')).toBeInTheDocument();
50
- expect(screen.getByText('prism.fullURL')).toBeInTheDocument();
51
- });
52
-
53
- test('copies the full URL as-is without shortening it', async () => {
54
- render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
55
-
56
- openCopyUrlMenu();
57
- fireEvent.click(screen.getByText('prism.fullURL'));
58
-
59
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith(PREVIEW_URL);
60
- expect(mockedShortenUrl).not.toHaveBeenCalled();
61
- await waitFor(() => expect(screen.getByText('prism.copied')));
62
- });
63
-
64
- test('copies the shortened URL when the short URL option is picked', async () => {
65
- mockedShortenUrl.mockResolvedValue(SHORT_URL);
66
- render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
67
-
68
- openCopyUrlMenu();
69
- fireEvent.click(screen.getByText('prism.shortURL'));
70
-
71
- await waitFor(() =>
72
- expect(mockedShortenUrl).toHaveBeenCalledWith({ longUrl: PREVIEW_URL }),
73
- );
74
- await waitFor(() =>
75
- expect(navigator.clipboard.writeText).toHaveBeenCalledWith(SHORT_URL),
76
- );
77
- });
78
-
79
- test('reports progress on the button while the URL is being shortened', async () => {
80
- let resolveShortening: (value: string) => void = (value) => {
81
- throw new Error(`shortening resolved before it started: ${value}`);
82
- };
83
- mockedShortenUrl.mockReturnValue(
84
- new Promise<string>((resolve) => {
85
- resolveShortening = resolve;
86
- }),
87
- );
88
- render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
89
-
90
- openCopyUrlMenu();
91
- fireEvent.click(screen.getByText('prism.shortURL'));
92
-
93
- await waitFor(() => expect(screen.getByText('prism.copying')));
94
-
95
- resolveShortening(SHORT_URL);
96
-
97
- await waitFor(() => expect(screen.getByText('prism.copied')));
98
- expect(toaster.success).not.toHaveBeenCalled();
99
- });
100
-
101
- test('surfaces an error toast when the shortening service fails', async () => {
102
- mockedShortenUrl.mockRejectedValue(new Error('invalid URL'));
103
- render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
104
-
105
- openCopyUrlMenu();
106
- fireEvent.click(screen.getByText('prism.shortURL'));
107
-
108
- await waitFor(() =>
109
- expect(toaster.error).toHaveBeenCalledWith({
110
- message: 'toasterGetURLError',
111
- }),
112
- );
113
- expect(navigator.clipboard.writeText).not.toHaveBeenCalled();
114
- expect(toaster.success).not.toHaveBeenCalled();
115
- });
116
-
117
- test('ignores a shortening result that lands after the preview URL changed', async () => {
118
- let resolveShortening: (value: string) => void = (value) => {
119
- throw new Error(`shortening resolved before it started: ${value}`);
120
- };
121
- mockedShortenUrl.mockReturnValue(
122
- new Promise<string>((resolve) => {
123
- resolveShortening = resolve;
124
- }),
125
- );
126
- const { rerender } = render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
127
-
128
- openCopyUrlMenu();
129
- fireEvent.click(screen.getByText('prism.shortURL'));
130
- await waitFor(() => expect(screen.getByText('prism.copying')));
131
-
132
- rerender(
133
- <PrismPlayerPreview
134
- {...DEFAULT_PROPS}
135
- previewUrl={`${PREVIEW_URL}&playerId=other`}
136
- />,
137
- );
138
- resolveShortening(SHORT_URL);
139
-
140
- await waitFor(() => expect(screen.getByText('prism.copyURL')));
141
- expect(screen.queryByText('prism.copied')).not.toBeInTheDocument();
142
- });
143
-
144
- test('drops the copied state as soon as the preview URL changes', async () => {
145
- const { rerender } = render(<PrismPlayerPreview {...DEFAULT_PROPS} />);
146
-
147
- openCopyUrlMenu();
148
- fireEvent.click(screen.getByText('prism.fullURL'));
149
- await waitFor(() => expect(screen.getByText('prism.copied')));
150
-
151
- rerender(
152
- <PrismPlayerPreview
153
- {...DEFAULT_PROPS}
154
- previewUrl={`${PREVIEW_URL}&playerId=other`}
155
- />,
156
- );
157
-
158
- expect(screen.getByText('prism.copyURL')).toBeInTheDocument();
159
- expect(
160
- screen.getByRole('button', { name: /prism.copyURL/ }),
161
- ).not.toBeDisabled();
162
- });
163
-
164
- test('disables the copy URL button while no player is selected', () => {
165
- render(<PrismPlayerPreview {...DEFAULT_PROPS} previewUrl='' />);
166
-
167
- expect(screen.getByRole('button', { name: /prism.copyURL/ })).toBeDisabled();
168
- });
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import { act, fireEvent, render } from '@testing-library/react';
3
- import { TabsHeader } from '../src/js/components';
4
-
5
- const DEFAULT_MODAL_COMP = {
6
- currentTab: 'iframe',
7
- handleTabChange: jest.fn(),
8
- iframeLabel: 'iframe',
9
- jsLabel: 'js',
10
- };
11
-
12
- test('renders TabsHeader clickeable tabs', async () => {
13
- const { getByRole } = render(<TabsHeader {...DEFAULT_MODAL_COMP} />);
14
- const jsBtn = getByRole('tab', { name: DEFAULT_MODAL_COMP.jsLabel });
15
- act(() => {
16
- fireEvent.click(jsBtn);
17
- });
18
- expect(DEFAULT_MODAL_COMP.handleTabChange).toBeCalled();
19
- });
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import { act, fireEvent, render } from '@testing-library/react';
3
- import { TabsSection } from 'js/components';
4
-
5
- const DEFAULT_MODAL_COMP = {
6
- playerId: 'default',
7
- videoId: '1234',
8
- accountId: 'default',
9
- isBcMapTracking: false,
10
- };
11
-
12
- test('renders TabsSection clickeable tabs', async () => {
13
- const { getByRole, getByText } = render(
14
- <TabsSection {...DEFAULT_MODAL_COMP} isCampaign isViewerIdSource={false} />,
15
- );
16
- const jsBtn = getByRole('tab', { name: /javascript/i });
17
- act(() => {
18
- fireEvent.click(jsBtn);
19
- });
20
- expect(getByText(/data-video-id/i)).toBeInTheDocument();
21
- });
22
-
23
- test('renders helper text for campaign players', async () => {
24
- const { getByText } = render(
25
- <TabsSection {...DEFAULT_MODAL_COMP} isCampaign isViewerIdSource={false} />,
26
- );
27
- expect(getByText('tabs.helperTextWarning')).toBeInTheDocument();
28
- });
29
-
30
- test('renders helper text for viewer id source players', async () => {
31
- const { getByText } = render(
32
- <TabsSection {...DEFAULT_MODAL_COMP} isCampaign={false} isViewerIdSource />,
33
- );
34
- expect(getByText('tabs.viewerIdTextWarning')).toBeInTheDocument();
35
- });
36
-
37
- test('renders iframe content if it is not campaign or viewer id', async () => {
38
- const { getByText } = render(
39
- <TabsSection
40
- {...DEFAULT_MODAL_COMP}
41
- isCampaign={false}
42
- isViewerIdSource={false}
43
- />,
44
- );
45
- expect(getByText(/allowfullscreen/i)).toBeInTheDocument();
46
- });
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import { TitleWithTooltip } from '../src/js/components';
4
- import { truncateVideoTitle } from '../src/js/utils/util';
5
-
6
- const DEFAULT_VIDEO_COMP = {
7
- videoId: '123',
8
- videoName:
9
- 'The cat is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is often referred to as the domestic cat to distinguish it from the wild members of the family. ',
10
- accountId: '456',
11
- duration: 10,
12
- };
13
-
14
- const DEFAULT_PROJECT_COMP = {
15
- videoId: '456',
16
- interactivityProjectId: '987',
17
- interactivityProjectName:
18
- "The dog is a domesticated descendant of the wolf. Also called the domestic dog, it is derived from the extinct Pleistocene wolf, and the modern wolf is the dog's nearest living relative. ",
19
- accountId: '456',
20
- duration: 10,
21
- };
22
-
23
- test('renders TitleWithTooltip for Video with truncated title if its too long', () => {
24
- const truncatedTitle = truncateVideoTitle(DEFAULT_VIDEO_COMP.videoName);
25
- render(
26
- <TitleWithTooltip
27
- name={DEFAULT_VIDEO_COMP.videoName}
28
- id={DEFAULT_VIDEO_COMP.videoId}
29
- />,
30
- );
31
- expect(screen.getByText(truncatedTitle)).toBeInTheDocument();
32
- });
33
-
34
- test('renders TitleWithTooltip for Project with truncated title if its too long', () => {
35
- const truncatedTitle = truncateVideoTitle(
36
- DEFAULT_PROJECT_COMP.interactivityProjectName,
37
- );
38
- render(
39
- <TitleWithTooltip
40
- name={DEFAULT_PROJECT_COMP.interactivityProjectName}
41
- id={DEFAULT_PROJECT_COMP.videoId}
42
- />,
43
- );
44
- expect(screen.getByText(truncatedTitle)).toBeInTheDocument();
45
- });
@@ -1,38 +0,0 @@
1
- import React from 'react';
2
- import { QueryClientProvider, QueryClient } from 'react-query';
3
- import { render, screen } from '@testing-library/react';
4
- import { VideoPlayer } from '../src/js/components/VideoPlayer';
5
- import { EmbedCodeModalTypes } from '../src/js/types/EmbedCodeModalProps';
6
- import { PLAYER_LIST_FOR_SELECTION, PLAYERS } from '../src/js/constants/player';
7
-
8
- jest.mock('../src/js/utils/featureSwitches');
9
-
10
- const wrappedComponent = (children: React.ReactElement) => (
11
- <QueryClientProvider client={new QueryClient()}>
12
- {children}
13
- </QueryClientProvider>
14
- );
15
-
16
- const DEFAULT_MODAL_COMP = {
17
- videoId: '123',
18
- videoName: 'test video',
19
- accountId: '456',
20
- duration: 10,
21
- };
22
-
23
- test('renders EmbedCodeModal component with right information', () => {
24
- render(
25
- wrappedComponent(
26
- <VideoPlayer
27
- video={DEFAULT_MODAL_COMP}
28
- embedCodeModalType={EmbedCodeModalTypes.VIDEO}
29
- playerListForSelection={PLAYER_LIST_FOR_SELECTION}
30
- players={PLAYERS}
31
- />,
32
- ),
33
- );
34
- expect(screen.getByText(DEFAULT_MODAL_COMP.videoId)).toBeInTheDocument();
35
- expect(screen.getByText(DEFAULT_MODAL_COMP.videoName)).toBeInTheDocument();
36
- expect(screen.getByRole('tab', { name: /javascript/i })).toBeInTheDocument();
37
- expect(screen.getByRole('tab', { name: /IFrame/i })).toBeInTheDocument();
38
- });
@@ -1,111 +0,0 @@
1
- import {
2
- formatEmbedSnippet,
3
- generateEmbedCode,
4
- } from '../src/js/utils/embedCodeGenerator';
5
- import {
6
- EmbedCodeAspectRatio,
7
- EmbedCodeProperties,
8
- EmbedCodeUnits,
9
- } from '../src/js/types/EmbedCodeModalProps';
10
-
11
- test('formats iframe snippet with one attribute per line', () => {
12
- const input =
13
- '<iframe src="https://players.brightcove.net/x/index.html?videoId=1" allowfullscreen="" allow="encrypted-media" width="960" height="540"></iframe>';
14
- const expected = `<iframe
15
- src="https://players.brightcove.net/x/index.html?videoId=1"
16
- allowfullscreen=""
17
- allow="encrypted-media"
18
- width="960"
19
- height="540"></iframe>`;
20
- expect(formatEmbedSnippet(input)).toBe(expected);
21
- });
22
-
23
- test('formats javascript snippet by breaking video-js attrs and isolating <script>', () => {
24
- const input =
25
- '<video-js data-video-id="1" data-account="2" data-player="3" data-embed="default" controls=""></video-js><script src="https://players.brightcove.net/2/3_default/index.min.js"></script>';
26
- const expected = `<video-js
27
- data-video-id="1"
28
- data-account="2"
29
- data-player="3"
30
- data-embed="default"
31
- controls=""></video-js>
32
- <script
33
- src="https://players.brightcove.net/2/3_default/index.min.js"></script>`;
34
- expect(formatEmbedSnippet(input)).toBe(expected);
35
- });
36
-
37
- test('preserves spaces inside attribute values', () => {
38
- const input =
39
- '<iframe src="https://x?a=foo bar&b=baz qux" allowfullscreen=""></iframe>';
40
- const expected = `<iframe
41
- src="https://x?a=foo bar&b=baz qux"
42
- allowfullscreen=""></iframe>`;
43
- expect(formatEmbedSnippet(input)).toBe(expected);
44
- });
45
-
46
- describe('generateEmbedCode', () => {
47
- const buildEmbedProperties = (
48
- overrides: Partial<EmbedCodeProperties> = {},
49
- ): EmbedCodeProperties => ({
50
- width: 540,
51
- height: 540,
52
- units: EmbedCodeUnits.PX,
53
- responsive: false,
54
- aspectRatio: EmbedCodeAspectRatio.SIXTEEN_NINE,
55
- ...overrides,
56
- });
57
-
58
- test('does not throw when aspectRatio is CUSTOM and produces fluid embed code', () => {
59
- expect(() =>
60
- generateEmbedCode({
61
- accountId: 'acc-1',
62
- playerId: 'player-1',
63
- videoId: 'video-1',
64
- embedProperties: buildEmbedProperties({
65
- aspectRatio: EmbedCodeAspectRatio.CUSTOM,
66
- }),
67
- }),
68
- ).not.toThrow();
69
-
70
- const { embedCode, embedCodeJS } = generateEmbedCode({
71
- accountId: 'acc-1',
72
- playerId: 'player-1',
73
- videoId: 'video-1',
74
- embedProperties: buildEmbedProperties({
75
- aspectRatio: EmbedCodeAspectRatio.CUSTOM,
76
- responsive: true,
77
- }),
78
- });
79
-
80
- expect(typeof embedCode).toBe('string');
81
- expect(typeof embedCodeJS).toBe('string');
82
- expect(embedCode.length).toBeGreaterThan(0);
83
- expect(embedCodeJS).toContain('vjs-fluid');
84
- });
85
-
86
- test('does not mutate the caller-provided embedProperties', () => {
87
- const props = buildEmbedProperties({
88
- aspectRatio: EmbedCodeAspectRatio.CUSTOM,
89
- });
90
- generateEmbedCode({
91
- accountId: 'acc-1',
92
- playerId: 'player-1',
93
- videoId: 'video-1',
94
- embedProperties: props,
95
- });
96
- expect(props.aspectRatio).toBe(EmbedCodeAspectRatio.CUSTOM);
97
- });
98
-
99
- test('forwards known aspectRatio values unchanged', () => {
100
- const { embedCodeJS } = generateEmbedCode({
101
- accountId: 'acc-1',
102
- playerId: 'player-1',
103
- videoId: 'video-1',
104
- embedProperties: buildEmbedProperties({
105
- aspectRatio: EmbedCodeAspectRatio.SIXTEEN_NINE,
106
- responsive: true,
107
- }),
108
- });
109
- expect(embedCodeJS).toContain('vjs-16-9');
110
- });
111
- });
@@ -1,89 +0,0 @@
1
- import {
2
- getVideoPreviewLink,
3
- sortAsc,
4
- truncateVideoTitle,
5
- } from '../src/js/utils/util';
6
-
7
- test('sorting working as expected', () => {
8
- const data = [
9
- { value: '6B9lFzOYe', label: '#1212' },
10
- { value: 'BKCEJEm0L', label: 'other 2' },
11
- { value: 'WbMYTw0lh', label: '&^qwe' },
12
- { value: 'ZLJg8MzKS', label: '123' },
13
- { value: 'default', label: 'Brightcove' },
14
- ];
15
- const expected = [
16
- { value: 'WbMYTw0lh', label: '&^qwe' },
17
- { value: '6B9lFzOYe', label: '#1212' },
18
- { value: 'ZLJg8MzKS', label: '123' },
19
- { value: 'default', label: 'Brightcove' },
20
- { value: 'BKCEJEm0L', label: 'other 2' },
21
- ];
22
- expect(sortAsc(data)).toEqual(expected);
23
- });
24
-
25
- test('video preview url created correctly', () => {
26
- const video = {
27
- videoId: 'test',
28
- videoName: 'test',
29
- accountId: 'test',
30
- posterUrl: 'test',
31
- duration: 10,
32
- };
33
- const expected =
34
- 'https://players.qa.brightcove.net/test/default_default/index.html?videoId=test';
35
- expect(
36
- getVideoPreviewLink({
37
- accountId: video.accountId,
38
- videoId: video.videoId,
39
- playerId: 'default',
40
- }),
41
- ).toBe(expected);
42
- });
43
-
44
- test('interactivity project preview url created correctly', () => {
45
- const video = {
46
- interactivityProjectId: 'test',
47
- accountId: 'test',
48
- posterUrl: 'test',
49
- duration: 10,
50
- };
51
- const expected =
52
- 'https://players.qa.brightcove.net/test/default_default/index.html?interactivityProjectId=test';
53
- expect(
54
- getVideoPreviewLink({
55
- accountId: video.accountId,
56
- interactivityProjectId: video.interactivityProjectId,
57
- playerId: 'default',
58
- }),
59
- ).toBe(expected);
60
- });
61
-
62
- test('long video titles are truncated properly', () => {
63
- const video = {
64
- videoId: 'test',
65
- videoName:
66
- 'The cat is a domestic species of small carnivorous mammal. It is the only domesticated species in the family Felidae and is often referred to as the domestic cat to distinguish it from the wild members of the family. ',
67
- accountId: 'test',
68
- posterUrl: 'test',
69
- duration: 10,
70
- };
71
- const expected =
72
- 'The cat is a domestic species of small carnivorous mammal. I...';
73
- const truncatedTitle = truncateVideoTitle(video.videoName);
74
-
75
- expect(expected).toEqual(truncatedTitle);
76
- });
77
-
78
- test('short video titles are truncated properly', () => {
79
- const video = {
80
- videoId: 'test',
81
- videoName: 'This is a normal video title',
82
- accountId: 'test',
83
- posterUrl: 'test',
84
- duration: 10,
85
- };
86
- const truncatedTitle = truncateVideoTitle(video.videoName);
87
-
88
- expect(video.videoName).toEqual(truncatedTitle);
89
- });
package/babel.config.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "useBuiltIns": "entry",
7
- "corejs": 3
8
- }
9
- ],
10
- "@babel/preset-typescript",
11
- "@babel/preset-react"
12
- ],
13
- "plugins": [
14
- "@babel/proposal-class-properties",
15
- "@babel/plugin-transform-runtime"
16
- ]
17
- }