feat: only show google attribution for google-translated transcripts (#36619)
* feat: only show google attribution for google-translated transcripts * fixup! feat: only show google attribution for google-translated transcripts
This commit is contained in:
@@ -637,6 +637,7 @@
|
||||
spyOn(Caption, 'renderCaption');
|
||||
spyOn(Caption, 'bindHandlers');
|
||||
spyOn(Caption, 'updatePlayTime');
|
||||
spyOn(Caption, 'renderGoogleDisclaimer');
|
||||
spyOn(Caption, 'hideCaptions');
|
||||
spyOn(state, 'youtubeId').and.returnValue('Z5KLxerq05Y');
|
||||
});
|
||||
@@ -715,6 +716,7 @@
|
||||
expect($.ajaxWithPrefix).toHaveBeenCalled();
|
||||
expect(Caption.bindHandlers).toHaveBeenCalled();
|
||||
expect(Caption.renderCaption).toHaveBeenCalled();
|
||||
expect(Caption.renderGoogleDisclaimer).toHaveBeenCalled()
|
||||
expect(Caption.updatePlayTime).not.toHaveBeenCalled();
|
||||
expect(Caption.loaded).toBeTruthy();
|
||||
});
|
||||
@@ -808,6 +810,8 @@
|
||||
expect($.ajaxWithPrefix).toHaveBeenCalled();
|
||||
expect(Caption.fetchAvailableTranslations).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
describe('fetchAvailableTranslations', function() {
|
||||
@@ -1327,5 +1331,48 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('google disclaimer', () => {
|
||||
const BASE_CAPTIONS = [
|
||||
'this is a caption',
|
||||
'this is another caption',
|
||||
'quite lovely weather we\'re having today',
|
||||
'indeed',
|
||||
]
|
||||
var Caption;
|
||||
|
||||
const makeCaptions = (provider) => {
|
||||
const providerAttr = provider ? ` data-provider="${provider}"` : '';
|
||||
const aiGeneratedTag = `<span id="captions-ai-generated" ${providerAttr}></span>`;
|
||||
var captions = [...BASE_CAPTIONS];
|
||||
captions[0] = aiGeneratedTag + captions[0];
|
||||
return captions;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
state = jasmine.initializePlayer();
|
||||
Caption = state.videoCaption;
|
||||
})
|
||||
|
||||
it('not shown when captions are not ai generated', () => {
|
||||
Caption.renderGoogleDisclaimer(BASE_CAPTIONS)
|
||||
expect(state.shouldShowGoogleDisclaimer).toBe(false);
|
||||
});
|
||||
|
||||
it('not shown when captions are not generated by gcp', () => {
|
||||
Caption.renderGoogleDisclaimer(makeCaptions('someoneElse'))
|
||||
expect(state.shouldShowGoogleDisclaimer).toBe(false);
|
||||
});
|
||||
|
||||
it('shown when captions are generated by gcp', () => {
|
||||
Caption.renderGoogleDisclaimer(makeCaptions('gcp'))
|
||||
expect(state.shouldShowGoogleDisclaimer).toBe(true);
|
||||
});
|
||||
|
||||
it('shown when captions have no provider', () => {
|
||||
Caption.renderGoogleDisclaimer(makeCaptions())
|
||||
expect(state.shouldShowGoogleDisclaimer).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
}).call(this);
|
||||
|
||||
Reference in New Issue
Block a user