Skip to content

Commit

Permalink
Hide auto-scroll check for transcripts without time-synced content
Browse files Browse the repository at this point in the history
  • Loading branch information
Dananji Withana committed Feb 1, 2024
1 parent 6f8334c commit 130a7a6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/components/Transcript/TranscriptMenu/TranscriptSelector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import TranscriptDownloader from './TranscriptDownloader';
import { TRANSCRIPT_TYPES } from '@Services/transcript-parser';

const MACHINE_GEN_MESSAGE = 'Machine-generated transcript may contain errors.';

Expand All @@ -11,7 +12,7 @@ const TanscriptSelector = ({
noTranscript,
setAutoScroll
}) => {
const { filename, id, tUrl, tFileExt, isMachineGen } = transcriptInfo;
const { filename, id, tUrl, tFileExt, tType, isMachineGen } = transcriptInfo;

const [autoScrollCheck, setAutoScrollCheck] = React.useState(true);

Expand Down Expand Up @@ -63,17 +64,20 @@ const TanscriptSelector = ({
{MACHINE_GEN_MESSAGE}
</p>
}
<div className="ramp--transcript_auto_scroll_check">
<input
type="checkbox"
id="auto-scroll-check"
name="autoscrollcheck"
aria-checked={autoScrollCheck}
checked={autoScrollCheck}
onChange={handleOnChange}
/>
<label htmlFor="auto-scroll-check">Auto-scroll with media</label>
</div>
{tType === TRANSCRIPT_TYPES.timedText && (
<div className="ramp--transcript_auto_scroll_check"
data-testid="transcript-auto-scroll-check">
<input
type="checkbox"
id="auto-scroll-check"
name="autoscrollcheck"
aria-checked={autoScrollCheck}
checked={autoScrollCheck}
onChange={handleOnChange}
/>
<label htmlFor="auto-scroll-check">Auto-scroll with media</label>
</div>)
}
</div>
);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('TranscriptSelector component', () => {
tFileExt: 'json'
},
noTranscript: false,
setAutoScroll: jest.fn()
};
describe('with default props', () => {
beforeEach(() => {
Expand Down Expand Up @@ -96,4 +97,32 @@ describe('TranscriptSelector component', () => {
"Machine-generated transcript may contain errors."
);
});

test('with time synced transcript content', () => {
let updatedProps = {
...props,
transcriptInfo: {
...props.transcriptInfo,
tType: 1,
}
};
render(<TranscriptSelector {...updatedProps} />);
expect(screen.getByTestId('transcript-selector')).toBeInTheDocument();
expect(screen.getByTestId('transcript-downloader')).toBeInTheDocument();
expect(screen.queryByTestId('transcript-auto-scroll-check')).toBeInTheDocument();
});

test('without time synced transcript content', () => {
let updatedProps = {
...props,
transcriptInfo: {
...props.transcriptInfo,
tType: 3,
}
};
render(<TranscriptSelector {...updatedProps} />);
expect(screen.getByTestId('transcript-selector')).toBeInTheDocument();
expect(screen.getByTestId('transcript-downloader')).toBeInTheDocument();
expect(screen.queryByTestId('transcript-auto-scroll-check')).not.toBeInTheDocument();
});
});

0 comments on commit 130a7a6

Please sign in to comment.