in integration/js/pages/AppPage.js [494:551]
async checkTranscriptsFromLastStart(expectedTranscriptContentBySpeaker, isMedicalTranscribe, compareFn) {
const transcriptContainerText = await this.driver.findElement(elements.transcriptContainer).getText();
const allTranscripts = transcriptContainerText.split('\n');
if (allTranscripts.length < 1) {
console.error(`Unable to find any transcripts`);
return false;
}
let lastStartedIdx = allTranscripts.length - 1;
while (lastStartedIdx >= 0) {
if (allTranscripts[lastStartedIdx].includes('Live Transcription started')) {
break;
}
lastStartedIdx--;
}
if (lastStartedIdx < 0) {
console.error(`Unexpected received lastStartedIdx < 0: ${lastStartedIdx}`);
return false;
}
const transcriptsToValidate = allTranscripts.slice(lastStartedIdx + 1);
// Verify that each speaker's content is as expected according to compareFn.
// Sequential transcripts for the same speaker are appended together for comparison.
const actualTranscriptContentBySpeaker = {};
for (let i = 0; i < transcriptsToValidate.length; i++) {
const transcriptText = transcriptsToValidate[i];
const speaker = transcriptText.slice(0, transcriptText.indexOf(':'));
const content = transcriptText.slice(transcriptText.indexOf(':') + 1).trim();
if (actualTranscriptContentBySpeaker[speaker]) {
actualTranscriptContentBySpeaker[speaker] += " " + content;
} else {
actualTranscriptContentBySpeaker[speaker] = content;
}
}
let actualSpeakers = Object.getOwnPropertyNames(actualTranscriptContentBySpeaker);
let expectedSpeaker = Object.getOwnPropertyNames(expectedTranscriptContentBySpeaker);
// Temporarily filtering empty speakers for medical transcribe test. Empty speaker issue - P68074811
if (isMedicalTranscribe) {
console.log(`Filtering empty speaker in medical transcribe.`);
actualSpeakers = actualSpeakers.filter(speaker => speaker !== "")
}
if (actualSpeakers.length !== expectedSpeaker.length) {
console.error(`Expected speaker length ${expectedSpeaker.length} but got ${actualSpeakers.length}`);
return false;
}
for (let i = 0; i < actualSpeakers.length; i++) {
const speaker = actualSpeakers[i];
if (!compareFn(actualTranscriptContentBySpeaker[speaker], expectedTranscriptContentBySpeaker[speaker], isMedicalTranscribe)) {
console.log(`Transcript comparison failed, speaker: ${speaker} isMedicalTranscribe: ${isMedicalTranscribe} actual content: "${actualTranscriptContentBySpeaker[speaker]}" does not match with expected: "${expectedTranscriptContentBySpeaker[speaker]}"`);
}
}
return true;
}