Skip to content

Commit

Permalink
test(upload-metadata): Test Upload and fetch metadata methods (#10)
Browse files Browse the repository at this point in the history
* test(upload-metadata): Add integration test for upload & fetch metadata methods
  • Loading branch information
nathanagez authored Sep 20, 2021
1 parent 97161fd commit 724a146
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 311 deletions.
6 changes: 5 additions & 1 deletion e2e/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ yarn-error.log*
# Cypress
cypress.env.json

cypress/videos/**/*.mp4
cypress/videos/**/*.mp4

cypress/screenshots/**/*.png

cypress/fixtures/upload-response.json
5 changes: 0 additions & 5 deletions e2e/cypress/fixtures/example.json

This file was deleted.

5 changes: 0 additions & 5 deletions e2e/cypress/fixtures/profile.json

This file was deleted.

232 changes: 0 additions & 232 deletions e2e/cypress/fixtures/users.json

This file was deleted.

40 changes: 40 additions & 0 deletions e2e/cypress/integration/01-upload.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { RESPONSE_FILE_PATH } from '../utils/constant';
import { aliasMutation } from '../utils/graphql-test-utils';

describe('File upload', () => {
it('Video.upload method', () => {
cy.visit('/');
const filepath = 'video/video-sample.mp4';
cy.get('input[type="file"]').attachFile(filepath);
cy.get('[data-cy=submit]').click();

cy.intercept('/graphql', (req) => {
aliasMutation(req, 'createVideoObject');
});
cy.intercept('/graphql', (req) => {
aliasMutation(req, 'createVodAsset');
});
cy.intercept('PUT', '*PutObject').as('s3Put');

cy.wait(['@createVideoObject', '@createVodAsset', '@s3Put'], {
responseTimeout: 60000,
}).spread((createVideoObject, createVodAsset, s3Put) => {
expect(
createVideoObject.response.body.data.createVideoObject,
).to.not.equal(null);
expect(createVodAsset.response.body.data.createVodAsset).to.not.equal(
null,
);
expect(s3Put.response.statusCode).to.equal(200);
cy.wait(1000);
cy.get('[data-cy=pre-upload]')
.invoke('html')
.then((response) => {
cy.wrap(response).as('response');
});
cy.get('@response').then((response) => {
cy.writeFile(RESPONSE_FILE_PATH, response);
});
});
});
});
37 changes: 37 additions & 0 deletions e2e/cypress/integration/02-metadata.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { RESPONSE_FILE_PATH } from '../utils/constant';
import { aliasMutation } from '../utils/graphql-test-utils';

describe('Fetching metadata', () => {
beforeEach(() => {
cy.intercept('/graphql', (req) => {
aliasMutation(req, 'getVodAsset');
});
});

it('Video.metadata method should return null when id does not exist', () => {
cy.visit('/');
cy.readFile(RESPONSE_FILE_PATH).then(({ data }) => {
cy.get('input[type="text"]').type(data.key);
cy.get('[data-cy=fetch]').click();
});
cy.wait('@getVodAsset').then(({ response }) => {
const { getVodAsset } = response.body.data;
expect(getVodAsset).to.equal(null);
});
});

it('Video.metadata method should VodAsset metadata', () => {
let id = null;
cy.visit('/');
cy.readFile(RESPONSE_FILE_PATH).then(({ data }) => {
id = data.key.split('.')[0];
cy.get('input[type="text"]').type(id);
cy.get('[data-cy=fetch]').click();
});
cy.wait('@getVodAsset').then(({ response }) => {
const { getVodAsset } = response.body.data;
expect(getVodAsset).to.not.equal(null);
expect(expect(getVodAsset.id).to.equal(id));
});
});
});
56 changes: 0 additions & 56 deletions e2e/cypress/integration/upload/upload.spec.js

This file was deleted.

Loading

0 comments on commit 724a146

Please sign in to comment.