Skip to content

Commit 422d657

Browse files
committed
Fix for in-paradigm recordings
1 parent 97b286d commit 422d657

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

cypress/e2e/crkeng/recordings.spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ context("Recordings", function () {
2222
describe("On the definition page", () => {
2323
beforeEach(() => {
2424
// Intercept calls to our API
25-
cy.intercept("https://speech-db.altlab.app/maskwacis/api/bulk_search?*", {
25+
cy.intercept("https://speech-db.altlab.app/maskwacis/api/bulk_search?*q=w%C3%A2pam%C3%AAw*", {
2626
fixture: "recording/bulk_search/wâpamêw.json",
2727
}).as("recordingsResults");
2828
});
@@ -81,6 +81,21 @@ context("Recordings", function () {
8181
// clicking the link should open a new tab
8282
.should("have.attr", "target", "_blank");
8383
});
84+
85+
it("should display and play recordings inside the paradigm", function () {
86+
// Get to the definition/paradigm page for "wâpamêw"
87+
cy.setCookie("paradigm_audio", "yes");
88+
cy.visitLemma("wâpamêw");
89+
cy.wait("@recordingsResults");
90+
91+
// And we should be able to click it.
92+
cy.get("div[data-cy=play-paradigm-recording][data-inflection=wâpamêw]").click();
93+
94+
// Note: figuring out if the audio actually played is... involved,
95+
// and error-prone, so it is not tested.
96+
// If you *want* to mock the Audio constructor... I mean, you can...
97+
// https://github.com/cypress-io/cypress/issues/1750#issuecomment-390751415
98+
});
8499
});
85100

86101
describe("When there are no recordings available", () => {

src/morphodict/paradigm/templates/morphodict/components/paradigm.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
chunks.forEach((chunk) => {
5353
url = new URL("https://speech-db.altlab.app/{{source}}/api/bulk_search")
5454
chunk.forEach(element => {
55-
url.searchParams.append('q',search_key(element, source))
55+
url.searchParams.append('q',search_key(element, "{{source}}"))
5656
url.searchParams.append('exact', true)
5757
});
5858
promises.push(fetch(url).then(res => res.json()).then((json) =>{
@@ -91,7 +91,7 @@
9191
{% comment %}
9292
now I can begin adding the elements as they belong
9393
{% endcomment %}
94-
for (var element of document.getElementsByClassName("paradigm-cell-recording")){
94+
for (const element of document.getElementsByClassName("paradigm-cell-recording")){
9595
let word = element.getAttribute("data-inflection")
9696
var recording = best[word]
9797

@@ -110,7 +110,7 @@
110110
button.querySelector("button").addEventListener("click", () => {audio.play(); console.log(audio)}
111111
);
112112
element.appendChild(button)
113-
113+
element.setAttribute("data-cy","play-paradigm-recording")
114114
}
115115
}
116116
})

0 commit comments

Comments
 (0)