diff --git a/docs/architecture.png b/docs/#architecture.png similarity index 100% rename from docs/architecture.png rename to docs/#architecture.png diff --git a/frontend/scenarios/add_picture.feature b/frontend/scenarios/add_picture.feature index 0c682825..cc8c548d 100644 --- a/frontend/scenarios/add_picture.feature +++ b/frontend/scenarios/add_picture.feature @@ -6,5 +6,6 @@ Fonctionnalité: Ajouter une image à une glose Soit un document dont je suis l'auteur affiché comme glose Et une session active avec mon compte - Quand j'essaie d'ajouter une image à une glose - Alors je vois l'image "" dans la glose + Quand j'essaie d'ajouter une image "#architecture.png" à une glose + Alors je vois l'image "#architecture.png" dans la glose + Et l'image a un texte alternatif "" diff --git a/frontend/src/hyperglosae.js b/frontend/src/hyperglosae.js index 35d38743..cb3b7d58 100644 --- a/frontend/src/hyperglosae.js +++ b/frontend/src/hyperglosae.js @@ -59,8 +59,7 @@ function Hyperglosae(logger) { reader.readAsArrayBuffer(attachment); reader.onload = () => { const arrayBuffer = reader.result; - - fetch(`${service}/${id}/${attachment.name}`, { + fetch(`${service}/${id}/${attachment.name.split('#').join('%23')}`, { method: 'PUT', headers: { // ETag is the header that carries the current rev. diff --git a/frontend/tests/event.js b/frontend/tests/event.js index bd6cc9f8..fc3133aa 100644 --- a/frontend/tests/event.js +++ b/frontend/tests/event.js @@ -139,11 +139,10 @@ Quand("je supprime le lien entre le document principal et la référence", () => cy.get(".modal-dialog").get(".btn-primary").click(); }); -Quand("j'essaie d'ajouter une image à une glose", () => { +Quand("j'essaie d'ajouter une image {string} à une glose", (imagePath) => { context = cy.get('.scholium').eq(1); cy.click_on_contextual_menu_item(context, 'Add a picture...'); - cy.get('[id="image-input"]').selectFile('../docs/architecture.png', { + cy.get('[id="image-input"]').selectFile(`../docs/${imagePath}`, { force: true, }); }); - diff --git a/frontend/tests/outcome.js b/frontend/tests/outcome.js index cf23f917..705c8878 100644 --- a/frontend/tests/outcome.js +++ b/frontend/tests/outcome.js @@ -17,8 +17,14 @@ Alors("je ne peux pas lire {string}", (text) => { cy.get('body').should('not.contain', text); }); -Alors("je vois l'image {string} dans la glose", (alternative_text) => { - cy.get('.row:not(.runningHead)>.scholium').should('have.descendants', `img[alt='${alternative_text}']`); +Alors("je vois l'image {string} dans la glose", (image_name) => { + cy.get('.row:not(.runningHead)>.scholium img[src]') + .invoke('attr', 'src') + .should('match', /^http.*:\/\/(?!.*\/#).*/); +}); + +Alors("l'image a un texte alternatif {string}", (alternative_text) => { + cy.get('.row:not(.runningHead)>.scholium').should('have.descendants', `img[alt='${alternative_text}']`); }); Alors("je vois l'image {string} dans le document principal", (alternative_text) => {