Skip to content
Open
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
12 changes: 6 additions & 6 deletions frontend/scenarios/link_document.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Scénario: pour commenter un document

Soit un document existant affiché comme document principal
Et une session active avec mon compte
Quand je réutilise "Glossaire" comme glose
Alors "Glossaire" est la glose ouverte
Et la glose contient :
Quand j'utilise un document existant comme commentaire
Alors la liste de mes documents s'affichent
Et la liste contient pour chaque document son titre, son auteur, sa dernière date de modification et son lien isPartOf
"""
"Il était une fois"
"Once upon a time" (eng)
"Bolo to raz" (svk)
"Comments on the video - Côme Peyrelongue, 24/03/2026 09:32 - My First Video Document"
"My Second Video Document - Côme Peyrelongue, 10/03/2026 20:15"
"Comments on the video - Côme Peyrelongue, 23/03/2026 10:44 - My Second Video Document"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • I see no reason to remove the existing scenario. It is really useful to check that its contents is linked and displayed.
  • I don't understand how you can be sure that everyone with just the code base, at any step of the tests will have your own documents. Nothing in the scenario tells that you should have them. And nothing in tests or data samples can make this assumption true.
  • Because your improvement is only a small part of Quand je réutilise {string} comme glose, you don't have to change the scenario: you just have to add conditions into the implementation of your test step.

It is important to understand all three objections. However if you take into account the third one it will fix the other two.

"""

Scénario: pour le comparer avec un autre
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/ExistingDocument.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Card from 'react-bootstrap/Card';
import { useNavigate } from 'react-router';
import {format } from 'date-fns';

function ExistingDocument({ document, relatedTo, verb, setLastUpdate, backend }) {
const navigate = useNavigate();
const title = document.dc_title || 'Untitled document';
const isPartOf = document.dc_isPartOf || '';
const creator = document.dc_creator || '';
const issued = format(new Date(document.dc_issued), 'dd/MM/yyyy HH:mm') || '';
const sourceChunksToBeLinked = (verb !== 'includes' && relatedTo.length)
? [{ verb, object: relatedTo[0] }]
: relatedTo.map(object =>({ verb, object }));
Expand Down Expand Up @@ -33,11 +37,10 @@ function ExistingDocument({ document, relatedTo, verb, setLastUpdate, backend })
})
.catch(console.error);
};

return (
<Card onClick={handleClick} className="existingDocument documentList">
<Card.Body>
<span>{title}</span>
<span><strong>{title}</strong> - <i>{isPartOf} - {creator} - {issued}</i></span>
</Card.Body>
</Card>
);
Expand Down
4 changes: 4 additions & 0 deletions frontend/tests/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ Quand("j'essaie d'ajouter une image à une glose", () => {
});
});

Quand("j'utilise un document existant comme commentaire", () => {
cy.get('.select-document').click();
cy.get('#select-dropdown').select('refersTo');
});
12 changes: 12 additions & 0 deletions frontend/tests/outcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,15 @@ Alors("la colonne {int} contient {string}", (column, text) => {
cy.contains(`.lectern .main .col .col:nth-child(${column})`, text);
});

Alors("la liste de mes documents s'affichent", () => {
cy.get('input[placeholder="Search documents"]').should('be.visible');
cy.get('.document-list-container .existingDocument').should('have.length.greaterThan', 0);
});

Alors("la liste contient pour chaque document son titre, son auteur, sa dernière date de modification et son lien isPartOf", (_documentsText) => {
cy.get('.document-list-container .existingDocument')
.should('have.length.greaterThan', 0)
.each(($card) => {
cy.wrap($card).find('span').invoke('text').should('match', /\S+/);
Comment on lines +211 to +214
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As explained in the comment of the scenario, move this condition into Quand je réutilise {string} comme glose.

});
});
Loading