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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Scénario: d'une traduction avec licences compatibles
Scénario: d'une traduction avec licences non compatibles

Soit "Víly (Charles Perrault)" le document principal
Et "CC-BY-NC-ND" le code de la licence du document principal
Et "CC-BY-NC-ND" le nom de la licence du document principal
Copy link
Member

Choose a reason for hiding this comment

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

This change is not coherent with line 18 of the same file.
Either change both or keep both.

Quand je consulte le contenu de "Fairies (Charles Perrault)"
Alors je vois que le code de la licence est "CC-BY-NC-ND"
Et je peux lire "Licenses are not compatible"
Expand Down
16 changes: 16 additions & 0 deletions frontend/tests/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Soit("{string} le document principal", (title) => {
'Treignes, le 8 septembre 2012 (Christophe Lejeune)': '/6b56ee657c870dfacd34e9ae4e0643dd',
'Restaurer la vapeur': '/6b56ee657c870dfacd34e9ae4e050fcc',
'Vestiges (diagramme de classes)': '/146e6e8442f0405b721b79357d0021e3',
'Víly (Charles Perrault)' : '/420ab198674f11eda3b7a3fdd5ea984f',
'Entretien avec un responsable d\'opération' : '/05b61f5285c711ed97bf6b9b56808c45',
Copy link
Member

Choose a reason for hiding this comment

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

Previous lines (39) is related to your scenario but not this one.

};
expect(uris).to.contain.key(title);
cy.visit(uris[title]);
Expand Down Expand Up @@ -150,3 +152,17 @@ Soit("ayant les métadonnées", (metadata) => {
});
cy.get('.scholium>.icon.focus').click();
});

Soit("{string} le nom de la licence du document principal", (n_licence) => {
cy.get('.license-container').eq(0).find('.license').then($license => {
if ($license.find('img').length) {
cy.wrap($license).find('img').should('have.attr', 'alt', n_licence);
} else if ($license.find('span').length) {
cy.wrap($license).find('span').should('have.text', n_licence);
} else if ($license.text().includes(n_licence)) {
expect($license.text()).to.include(n_licence);
} else {
throw new Error('Neither img nor span found in .license, or license text does not contain expected value');
}
});
});
Copy link
Member

Choose a reason for hiding this comment

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

The existing Capybara code was perhaps too simple but why is this code so complicated?
Please have a look at cy.contains() documentation. You can do a lot, with just one call.

15 changes: 15 additions & 0 deletions frontend/tests/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,18 @@ Quand("je consulte les informations de création du document", function () {
cy.get('.info-icon-container').trigger('mouseover');
});

Quand("je consulte le contenu de {string}", function (title) {
const uris = {
'Les fées (Charles Perrault)': '/37b4b9ba5cdb11ed887beb5c373fa643',
'Vidéo Sherlock Jr. (Buster Keaton)': '/4e1a31e14b032f2fa9e161ee9b009125',
'Treignes, le 8 septembre 2012 (Christophe Lejeune)': '/6b56ee657c870dfacd34e9ae4e0643dd',
'Restaurer la vapeur': '/6b56ee657c870dfacd34e9ae4e050fcc',
'Vestiges (diagramme de classes)': '/146e6e8442f0405b721b79357d0021e3',
'Víly (Charles Perrault)' : '/420ab198674f11eda3b7a3fdd5ea984f',
'Fairies (Charles Perrault)' : '/96bddee6-24b2-11ef-a1f4-5351a35fcaac',
'Étiquetage de l\'entretien' : '/6327c5008d1f11ed9aa8e7ae771dee2e',
};
expect(uris).to.contain.key(title);
cy.get(`a.icon.open[href*="#${uris[title].slice(1)}"]`).click();
}
);
Copy link
Member

@benel benel Jun 14, 2025

Choose a reason for hiding this comment

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

I think there is a misunderstanding about what this step is intended to do. If you look at the existing in Capybara (see
https://github.com/Hypertopic/HyperGlosae/blob/main/features/step_definitions/event.rb#L1-L3), it only clicks the open button, in order to see this document content side by side with the focused one.
This step is a prerequisite to check that both licences are compatible.

9 changes: 9 additions & 0 deletions frontend/tests/outcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,12 @@ Alors("la glose ouverte a les métadonnées", (metadata) => {
});
});
});

Alors("je vois que le code de la licence est {string}", (n_licence) => {
cy.get('.license-container').eq(1).find('.license img[alt="' + n_licence + '"]').should('exist');
});

Alors("je ne peux pas lire {string}", (text) => {
cy.get('.license-compatibility').should('not.exist');
}
);