@playkit-js/transcript 3.1.0 → 3.2.0-canary.2-0254f9e

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/transcript",
3
- "version": "3.1.0",
3
+ "version": "3.2.0-canary.2-0254f9e",
4
4
  "main": "dist/playkit-transcript.js",
5
5
  "license": "AGPL-3.0",
6
6
  "private": false,
@@ -13,16 +13,10 @@
13
13
  "url": "git+https://github.com/kaltura/playkit-js-transcript.git"
14
14
  },
15
15
  "devDependencies": {
16
- "@typescript-eslint/eslint-plugin": "^5.23.0",
17
- "@typescript-eslint/parser": "^5.23.0",
18
16
  "conventional-github-releaser": "3.1.3",
19
17
  "cross-env": "^7.0.3",
20
18
  "css-loader": "^6.7.1",
21
- "documentation": "^13.2.5",
22
- "husky": "^8.0.1",
23
- "jest": "^28.1.0",
24
19
  "kaltura-player-js": "https://github.com/kaltura/kaltura-player-js.git#master",
25
- "lint-staged": "^12.4.1",
26
20
  "preact": "^10.4.1",
27
21
  "prettier": "^2.6.2",
28
22
  "sass": "^1.54.3",
@@ -30,8 +24,7 @@
30
24
  "standard-version": "^9.3.2",
31
25
  "style-loader": "1.3.0",
32
26
  "ts-loader": "^9.3.0",
33
- "tslint": "^6.1.3",
34
- "typescript": "^4.6.4",
27
+ "typescript": "^4.9.4",
35
28
  "uglifyjs-webpack-plugin": "^2.2.0",
36
29
  "webpack": "^5.72.1",
37
30
  "webpack-cli": "^4.9.2",
@@ -46,14 +39,13 @@
46
39
  "build": "webpack --mode production",
47
40
  "dev": "webpack-dev-server --mode development",
48
41
  "watch": "webpack --progress --color --watch --mode development",
49
- "test": "jest",
42
+ "cypress:open": "cypress open",
43
+ "cypress:run": "cypress run",
44
+ "test:prepare": "yarn run build && yes | cp -i ./dist/playkit-transcript.js ./cypress/public/plugin.js",
45
+ "test:watch": "yarn run test:prepare && cypress open",
46
+ "test": "yarn run test:prepare && cypress run",
50
47
  "release": "standard-version",
51
48
  "pushTaggedRelease": "git push --follow-tags --no-verify origin master",
52
- "eslint": "eslint . --color",
53
- "commit:dist": "git add --force --all dist && (git commit -m 'chore: update dist' || exit 0)",
54
- "docs:generate": "documentation build flow-typed/** src/** -f md -o docs/configuration.md",
55
- "docs:serve": "documentation serve flow-typed/** src/** --watch",
56
- "precommit": "lint-staged",
57
49
  "prettier:fix": "prettier --write ."
58
50
  },
59
51
  "publishConfig": {
@@ -77,6 +69,7 @@
77
69
  "dependencies": {
78
70
  "@playkit-js/common": "^1.0.7",
79
71
  "@playkit-js/ui-managers": "^1.3.1",
72
+ "cypress": "^12.3.0",
80
73
  "stream-browserify": "^3.0.0"
81
74
  },
82
75
  "kaltura": {
@@ -16,7 +16,7 @@ interface CloseButtonProps {
16
16
 
17
17
  export const CloseButton = withText(translates)((props: CloseButtonProps) => (
18
18
  <A11yWrapper onClick={props.onClick}>
19
- <button className={styles.closeBtn} tabIndex={0} aria-label={props.closeLabel}>
19
+ <button className={styles.closeBtn} tabIndex={0} aria-label={props.closeLabel} data-testid="transcriptCloseButton">
20
20
  <Icon
21
21
  id="transcript-plugin-close-button"
22
22
  height={icons.BigSize}
@@ -12,16 +12,22 @@ interface PluginButtonProps {
12
12
  id: string;
13
13
  icon: string;
14
14
  label?: string;
15
+ dataTestId?: string;
15
16
  }
16
17
 
17
- export const PluginButton = ({isActive, onClick, label, id, icon}: PluginButtonProps) => {
18
+ export const PluginButton = ({isActive, onClick, label, id, icon, dataTestId}: PluginButtonProps) => {
18
19
  return (
19
20
  <Tooltip label={label} type="bottom">
20
21
  <A11yWrapper onClick={onClick}>
21
- <button aria-label={label} className={[ui.style.upperBarIcon, styles.pluginButton, isActive ? styles.active : ''].join(' ')}>
22
+ <button aria-label={label} className={[ui.style.upperBarIcon, styles.pluginButton, isActive ? styles.active : ''].join(' ')}
23
+ data-testid={dataTestId}>
22
24
  <Icon id={id} height={icons.BigSize} width={icons.BigSize} viewBox={`0 0 ${icons.BigSize} ${icons.BigSize}`} path={icon} />
23
25
  </button>
24
26
  </A11yWrapper>
25
27
  </Tooltip>
26
28
  );
27
29
  };
30
+
31
+ PluginButton.defaultProps = {
32
+ dataTestId: "transcript_pluginButton"
33
+ }
@@ -141,7 +141,8 @@ class SearchComponent extends Component<SearchProps, SearchState> {
141
141
  const {searchQuery, totalSearchResults, activeSearchIndex} = this.props;
142
142
  return (
143
143
  <div
144
- className={[styles.searchWrapper, searchQuery || this.state.active ? styles.active : '', this.state.focused ? styles.focused : ''].join(' ')}>
144
+ className={[styles.searchWrapper, searchQuery || this.state.active ? styles.active : '', this.state.focused ? styles.focused : ''].join(' ')}
145
+ data-testid="transcript_searchBar">
145
146
  <div className={styles.searchIcon}>
146
147
  <svg
147
148
  width="32px"
@@ -174,7 +175,7 @@ class SearchComponent extends Component<SearchProps, SearchState> {
174
175
  />
175
176
  {searchQuery && (
176
177
  <A11yWrapper onClick={this._onClear}>
177
- <button className={styles.clearIcon} tabIndex={0} aria-label={this.props.clearSearchLabel}>
178
+ <button className={styles.clearIcon} tabIndex={0} aria-label={this.props.clearSearchLabel} data-testid="transcript_clearSearchButton">
178
179
  <svg
179
180
  width="32px"
180
181
  height="32px"
@@ -193,7 +194,7 @@ class SearchComponent extends Component<SearchProps, SearchState> {
193
194
  </A11yWrapper>
194
195
  )}
195
196
  {searchQuery && (
196
- <div className={styles.searchResults} aria-live="polite" aria-label={this.props.searchResultsLabel}>{`${
197
+ <div className={styles.searchResults} aria-live="polite" aria-label={this.props.searchResultsLabel} data-testid="transcript_searchResultLabel">{`${
197
198
  totalSearchResults > 0 ? `${activeSearchIndex}/${totalSearchResults}` : '0/0'
198
199
  }`}</div>
199
200
  )}
@@ -379,7 +379,8 @@ export class TranscriptComponent extends Component<TranscriptProps, TranscriptSt
379
379
  ref={node => {
380
380
  this._widgetRootRef = node;
381
381
  }}
382
- onKeyUp={this._handleEsc}>
382
+ onKeyUp={this._handleEsc}
383
+ data-testid="transcript_root">
383
384
  <div className={styles.globalContainer}>
384
385
  {this._renderHeader()}
385
386
 
@@ -391,7 +392,8 @@ export class TranscriptComponent extends Component<TranscriptProps, TranscriptSt
391
392
  onScroll={this._onScroll}
392
393
  ref={node => {
393
394
  this._transcriptListRef = node;
394
- }}>
395
+ }}
396
+ data-testid="transcript_list">
395
397
  {isLoading ? this._renderLoading() : this._renderTranscript()}
396
398
  </div>
397
399
  {renderTranscriptButtons && this._renderScrollToButton()}
@@ -86,10 +86,6 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
86
86
  this.eventManager.listen(this.player, this.player.Event.TIMED_METADATA_CHANGE, this._onTimedMetadataChange);
87
87
  this.eventManager.listen(this.player, this.player.Event.TIMED_METADATA_ADDED, this._onTimedMetadataAdded);
88
88
  this.eventManager.listen(this.player, this.player.Event.TEXT_TRACK_CHANGED, this._handleLanguageChange);
89
- this._addDownloadIcon();
90
- this._addPrintIcon();
91
- this._addTranscriptItem();
92
- this._initLoading();
93
89
  }
94
90
  });
95
91
  }
@@ -131,6 +127,9 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
131
127
  });
132
128
  if (captionData.length) {
133
129
  this._addCaptionData(captionData);
130
+ this._addDownloadIcon();
131
+ this._addPrintIcon();
132
+ this._addTranscriptItem();
134
133
  }
135
134
  };
136
135
 
@@ -206,6 +205,7 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
206
205
  private _addDownloadIcon(): void {
207
206
  const {downloadDisabled} = this.config;
208
207
  if (this._downloadIcon > 0 || downloadDisabled) {
208
+ // download icon already exist or download disabled
209
209
  return;
210
210
  }
211
211
  const translate = {
@@ -216,13 +216,15 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
216
216
  svgIcon: {path: icons.DOWNLOAD_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
217
217
  onClick: this._handleDownload,
218
218
  component: withText(translate)((props: {label: string}) => (
219
- <PluginButton isActive={false} onClick={this._handleDownload} id={'download-transcript'} icon={icons.DOWNLOAD_ICON} label={props.label} />
219
+ <PluginButton isActive={false} onClick={this._handleDownload} id={'download-transcript'} icon={icons.DOWNLOAD_ICON} label={props.label}
220
+ dataTestId="transcript_downloadButton" />
220
221
  ))
221
222
  }) as number;
222
223
  }
223
224
  private _addPrintIcon(): void {
224
225
  const {printDisabled} = this.config;
225
226
  if (this._printIcon > 0 || printDisabled) {
227
+ // print icon already exist or download disabled
226
228
  return;
227
229
  }
228
230
  const translate = {
@@ -233,13 +235,15 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
233
235
  svgIcon: {path: icons.PRINT_ICON, viewBox: `0 0 ${icons.BigSize} ${icons.BigSize}`},
234
236
  onClick: this._handlePrint,
235
237
  component: withText(translate)((props: {label: string}) => (
236
- <PluginButton isActive={false} onClick={this._handlePrint} id={'print-transcript'} icon={icons.PRINT_ICON} label={props.label} />
238
+ <PluginButton isActive={false} onClick={this._handlePrint} id={'print-transcript'} icon={icons.PRINT_ICON} label={props.label}
239
+ dataTestId="transcript_printButton" />
237
240
  ))
238
241
  }) as number;
239
242
  }
240
243
 
241
244
  private _addTranscriptItem(): void {
242
- if (this._transcriptPanel > 0) {
245
+ if (Math.max(this._transcriptPanel, this._transcriptIcon) > 0) {
246
+ // transcript panel or icon already exist
243
247
  return;
244
248
  }
245
249
 
@@ -285,7 +289,8 @@ export class TranscriptPlugin extends KalturaPlayer.core.BasePlugin {
285
289
  const isActive = this._isPluginActive();
286
290
  const label = isActive ? props.hideTranscript : props.showTranscript;
287
291
  return (
288
- <PluginButton isActive={isActive} onClick={this._handleClickOnPluginIcon} id="transcript-icon" label={label} icon={icons.PLUGIN_ICON} />
292
+ <PluginButton isActive={isActive} onClick={this._handleClickOnPluginIcon} id="transcript-icon" label={label} icon={icons.PLUGIN_ICON}
293
+ dataTestId="transcript_pluginButton" />
289
294
  );
290
295
  })
291
296
  }) as number;