Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(upload-metadata): Test Upload and fetch metadata methods #10

Merged
merged 5 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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