0

Hello, for my test, I need to do a request in cypress. The body to put in the request contains a file.jpeg or a file.mp4. I used cy.fixture for that, but my upload souned correct but it is not. I try that but without success. (I am sorry for my bad english)

When("user upload picture", () => {
cy.fixture('Test.jpeg', { encoding: 'base64' }).then((picture) => {
    cy.log(picture);
    cy.wait(10000);
    cy.log(picture);
    cy.request({
        timeout: 120000,
        method: 'PUT',
        url: 'https://'url',
        headers: {
            'apikey': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            'Content-Type': 'image/jpeg',
            'Accept': 'application/json',
            'Content-Length': '72800'
        },
        body: {
            'Test.jpeg': picture
        }
    }).then((response) => {
        expect(response).property('status').to.equal(200);
        cy.log(JSON.stringify(response.body));
        vignetteBrute = response.body.vignetteBrute;
        cy.log(JSON.stringify(vignetteBrute));
        vignetteBruteFichierTypeObtenu = response.body.vignetteBrute.fichier.type;
        cy.log(JSON.stringify(vignetteBruteFichierTypeObtenu));
    })
}).as('vignetteTelechargee')

})

the answer is like that

{"id":"xxxxx","version":2,"dateMaj":"2022-09-21T09:10:36","date":"2022-06-07T10:58:20","titre":"VIDEO.xxxxx","description":"1","accroche":"xxx","source":"xx","canal":"xxx","etat":"brouillon","auteurs":["xxx"],"auteurNoms":["xxx"],"signature":"xxxx","vignetteBrute":{"fichier":{"**type":"image/jpeg","taille":72800,"hash":"vvvvvvvvvvv"}}**,"videoBrute":{"fichier":{}},"habillageDemande":{"modes":["video","vignette"],"libelleLieu":"cccc","libelleDate":"1er juin 2022"},"paysDiffusion":["FR","DK"]}

the type, size and hash of the picture is good, but when i would to see it, I can see a false image as on google when the picture is not upload.

Can I have some help? Thank you

0 Answers0