-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(upload-metadata): Test Upload and fetch metadata methods (#10)
* test(upload-metadata): Add integration test for upload & fetch metadata methods
- Loading branch information
1 parent
97161fd
commit 724a146
Showing
17 changed files
with
202 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.