Skip to content

Commit

Permalink
test(video-player): Test that video player correcly plays HLS playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanagez committed Sep 23, 2021
1 parent 6d78f79 commit a6d7a6f
Show file tree
Hide file tree
Showing 12 changed files with 749 additions and 17 deletions.
6 changes: 2 additions & 4 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ yarn-error.log*

# Cypress
cypress.env.json

cypress/videos/**/*.mp4

cypress/screenshots/**/*.png

cypress/fixtures/upload-response.json
cypress/fixtures/upload-response.json
cypress/fixtures/playback-url.json
9 changes: 6 additions & 3 deletions e2e/cypress/integration/01-upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ describe('File upload', () => {
it('Video.upload method', () => {
cy.visit('/');
const filepath = 'video/video-sample.mp4';
cy.get('input[type="file"]').attachFile(filepath);
cy.get('input[type="file"]').attachFile({
filePath: filepath,
encoding: 'binary',
});
cy.get('[data-cy=submit]').click();

cy.intercept('/graphql', (req) => {
Expand All @@ -28,7 +31,7 @@ describe('File upload', () => {
expect(s3Put.response.statusCode).to.equal(200);
cy.wait(1000);
cy.get('[data-cy=pre-upload]')
.invoke('html')
.invoke('text')
.then((response) => {
cy.wrap(response).as('response');
});
Expand All @@ -46,7 +49,7 @@ describe('File upload', () => {

cy.wait(1000);
cy.get('[data-cy=pre-upload]')
.invoke('html')
.invoke('text')
.then((content) => {
const { data } = JSON.parse(content);
expect(data).to.have.ownProperty('createVideoObject');
Expand Down
14 changes: 7 additions & 7 deletions e2e/cypress/integration/03-playback.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RESPONSE_FILE_PATH } from '../utils/constant';
import { RESPONSE_FILE_PATH, PLAYBACK_URL_FILE_PATH } from '../utils/constant';
import { aliasMutation } from '../utils/graphql-test-utils';

describe('Generate playback url', () => {
Expand All @@ -19,13 +19,13 @@ describe('Generate playback url', () => {
cy.wait('@getVodAsset').then(() => {
cy.wait(1000);
cy.get('[data-cy=pre-playback]')
.invoke('html')
.invoke('text')
.then((content) => {
const { data } = JSON.parse(content);
expect(data).to.not.equal(null);
expect(data).to.have.ownProperty('playbackUrl')
if (data.token)
expect(data.token).to.include("?Policy=ey")
expect(data).to.have.ownProperty('playbackUrl');
if (data.token) expect(data.token).to.include('?Policy=ey');
cy.writeFile(PLAYBACK_URL_FILE_PATH, JSON.parse(content));
});
});
});
Expand All @@ -37,14 +37,14 @@ describe('Generate playback url', () => {
cy.wait('@getVodAsset').then(() => {
cy.wait(1000);
cy.get('[data-cy=pre-playback]')
.invoke('html')
.invoke('text')
.then((content) => {
const { data } = JSON.parse(content);
expect(data).to.not.equal(null);
expect(data).to.have.ownProperty('playbackUrl');
expect(data).to.have.ownProperty('error');
expect(data.playbackUrl).to.equal(null);
expect(data.error).to.equal("Vod asset video ID not found");
expect(data.error).to.equal('Vod asset video ID not found');
});
});
});
Expand Down
23 changes: 23 additions & 0 deletions e2e/cypress/integration/04-video.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { PLAYBACK_URL_FILE_PATH } from '../utils/constant';
import { aliasMutation } from '../utils/graphql-test-utils';

describe('Generate playback url', () => {
beforeEach(() => {
/* cy.intercept('/graphql', (req) => {
aliasMutation(req, 'getVodAsset');
}); */
});

it('should generate playback url with token property if signed url', () => {
let id = null;
cy.visit('/');
cy.wait(12000); // WAIT FOR MEDIACONVERT JOB
cy.readFile(PLAYBACK_URL_FILE_PATH).then(({ data }) => {
cy.intercept(data.playbackUrl + data.token).as('HLS');
cy.get('[data-cy=video-url-input]').type(data.playbackUrl);
cy.get('[data-cy=video-token-input]').type(data.token);
cy.get('[data-cy=player]').click();
cy.wait('@HLS').its('response.statusCode').should('eq', 200)
});
});
});
1 change: 1 addition & 0 deletions e2e/cypress/utils/constant.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const RESPONSE_FILE_PATH = 'cypress/fixtures/upload-response.json';
export const PLAYBACK_URL_FILE_PATH = 'cypress/fixtures/playback-url.json';
Loading

0 comments on commit a6d7a6f

Please sign in to comment.