openvidu-test-e2e: API REST testing improved

pull/73/head
pabloFuente 2018-05-29 18:59:22 +02:00
parent cc1bb3aedf
commit 75ae4695a8
3 changed files with 81 additions and 16 deletions

View File

@ -787,12 +787,37 @@ public class OpenViduTestAppE2eTest {
user.getDriver().findElement(By.id("session-name-input-0")).clear(); user.getDriver().findElement(By.id("session-name-input-0")).clear();
user.getDriver().findElement(By.id("session-name-input-0")).sendKeys(sessionName); user.getDriver().findElement(By.id("session-name-input-0")).sendKeys(sessionName);
// Try to record a non-existing session // API REST test
user.getDriver().findElement(By.id("session-api-btn-0")).click(); user.getDriver().findElement(By.id("session-api-btn-0")).click();
Thread.sleep(1000); Thread.sleep(1000);
// Try to record a non-existing session
user.getDriver().findElement(By.id("start-recording-btn")).click(); user.getDriver().findElement(By.id("start-recording-btn")).click();
user.getWaiter() user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]")); .until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
listEmptyRecordings();
// Try to stop a non-existing recording
user.getDriver().findElement(By.id("recording-id-field")).sendKeys("FAIL");
user.getDriver().findElement(By.id("stop-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
listEmptyRecordings();
// Try to get a non-existing recording
user.getDriver().findElement(By.id("get-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
listEmptyRecordings();
// Try to delete a non-existing recording
user.getDriver().findElement(By.id("get-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
user.getDriver().findElement(By.id("close-dialog-btn")).click(); user.getDriver().findElement(By.id("close-dialog-btn")).click();
Thread.sleep(1000); Thread.sleep(1000);
@ -826,6 +851,28 @@ public class OpenViduTestAppE2eTest {
user.getDriver().findElement(By.id("recording-id-field")).clear(); user.getDriver().findElement(By.id("recording-id-field")).clear();
user.getDriver().findElement(By.id("recording-id-field")).sendKeys(sessionName); user.getDriver().findElement(By.id("recording-id-field")).sendKeys(sessionName);
// Try to start an ongoing recording
user.getDriver().findElement(By.id("start-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [409]"));
// Try to get a existing recording
user.getDriver().findElement(By.id("get-recording-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Recording got [" + sessionName + "]"));
// Try to delete a ongoing recording
user.getDriver().findElement(By.id("delete-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [409]"));
// List existing recordings (one)
user.getDriver().findElement(By.id("list-recording-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Recording list [" + sessionName + "]"));
// Stop ongoing recording
user.getDriver().findElement(By.id("stop-recording-btn")).click(); user.getDriver().findElement(By.id("stop-recording-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Recording stopped [" + sessionName + "]")); "Recording stopped [" + sessionName + "]"));
@ -841,6 +888,17 @@ public class OpenViduTestAppE2eTest {
Assert.assertTrue(file2.exists() || file2.length() > 0); Assert.assertTrue(file2.exists() || file2.length() > 0);
Assert.assertTrue(file3.exists() || file3.length() > 0); Assert.assertTrue(file3.exists() || file3.length() > 0);
// Try to get the stopped recording
user.getDriver().findElement(By.id("get-recording-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Recording got [" + sessionName + "]"));
// Try to list the stopped recording
user.getDriver().findElement(By.id("list-recording-btn")).click();
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value",
"Recording list [" + sessionName + "]"));
// Delete the recording
user.getDriver().findElement(By.id("delete-recording-btn")).click(); user.getDriver().findElement(By.id("delete-recording-btn")).click();
user.getWaiter() user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording deleted")); .until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording deleted"));
@ -853,6 +911,13 @@ public class OpenViduTestAppE2eTest {
} }
private void listEmptyRecordings() {
// List existing recordings (empty)
user.getDriver().findElement(By.id("list-recording-btn")).click();
user.getWaiter()
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording list []"));
}
private ExpectedCondition<Boolean> waitForVideoDuration(WebElement element, int durationInSeconds) { private ExpectedCondition<Boolean> waitForVideoDuration(WebElement element, int durationInSeconds) {
return new ExpectedCondition<Boolean>() { return new ExpectedCondition<Boolean>() {
@Override @Override

View File

@ -3,7 +3,7 @@ import { StreamManager } from 'openvidu-browser';
@Component({ @Component({
selector: 'app-ov-video', selector: 'app-ov-video',
template: '<video #videoElement [poster]=""></video>' template: '<video #videoElement [poster]="poster"></video>'
}) })
export class OpenViduVideoComponent implements AfterViewInit { export class OpenViduVideoComponent implements AfterViewInit {

View File

@ -291,13 +291,6 @@ export class VideoComponent implements OnInit, OnDestroy {
if (this.eventCollection.videoElementCreated) { if (this.eventCollection.videoElementCreated) {
if (!oldValues.videoElementCreated) { if (!oldValues.videoElementCreated) {
sub.on('videoElementCreated', (event: VideoElementEvent) => { sub.on('videoElementCreated', (event: VideoElementEvent) => {
if (!sub.stream.hasVideo) {
this.videoClasses = 'grey-background';
this.videoPoster = 'assets/images/volume.png';
} else {
this.videoClasses = '';
this.videoPoster = '';
}
this.updateEventListInParent.emit({ this.updateEventListInParent.emit({
event: 'videoElementCreated', event: 'videoElementCreated',
content: event.element.id content: event.element.id
@ -325,6 +318,13 @@ export class VideoComponent implements OnInit, OnDestroy {
if (this.eventCollection.streamPlaying) { if (this.eventCollection.streamPlaying) {
if (!oldValues.streamPlaying) { if (!oldValues.streamPlaying) {
sub.on('streamPlaying', (event: StreamManagerEvent) => { sub.on('streamPlaying', (event: StreamManagerEvent) => {
if (!sub.stream.hasVideo) {
this.videoClasses = 'grey-background';
this.videoPoster = 'assets/images/volume.png';
} else {
this.videoClasses = '';
this.videoPoster = '';
}
this.showButtons = true; this.showButtons = true;
this.updateEventListInParent.emit({ this.updateEventListInParent.emit({
event: 'streamPlaying', event: 'streamPlaying',
@ -341,13 +341,6 @@ export class VideoComponent implements OnInit, OnDestroy {
if (this.eventCollection.videoElementCreated) { if (this.eventCollection.videoElementCreated) {
if (!oldValues.videoElementCreated) { if (!oldValues.videoElementCreated) {
pub.on('videoElementCreated', (event: VideoElementEvent) => { pub.on('videoElementCreated', (event: VideoElementEvent) => {
if (!pub.stream.hasVideo) {
this.videoClasses = 'grey-background';
this.videoPoster = 'assets/images/volume.png';
} else {
this.videoClasses = '';
this.videoPoster = '';
}
this.updateEventListInParent.emit({ this.updateEventListInParent.emit({
event: 'videoElementCreated', event: 'videoElementCreated',
content: event.element.id content: event.element.id
@ -452,6 +445,13 @@ export class VideoComponent implements OnInit, OnDestroy {
if (this.eventCollection.streamPlaying) { if (this.eventCollection.streamPlaying) {
if (!oldValues.streamPlaying) { if (!oldValues.streamPlaying) {
pub.on('streamPlaying', (event: StreamManagerEvent) => { pub.on('streamPlaying', (event: StreamManagerEvent) => {
if (!pub.stream.hasVideo) {
this.videoClasses = 'grey-background';
this.videoPoster = 'assets/images/volume.png';
} else {
this.videoClasses = '';
this.videoPoster = '';
}
this.showButtons = true; this.showButtons = true;
this.updateEventListInParent.emit({ this.updateEventListInParent.emit({
event: 'streamPlaying', event: 'streamPlaying',