From 3062cb1ac49c366c6a7db4910fb9e0de4724523b Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 19:04:44 +0200 Subject: [PATCH 1/8] Show title attribute --- static/tests/frontend/specs/comment_l10n.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 36de474d..91b0c134 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -123,11 +123,10 @@ const changeEtherpadLanguageTo = async (lang) => { // hide settings again $settingsButton.click(); + const $boldButton = chrome$('.buttonicon-bold').parent(); + console.log($boldButton[0].title); await helper.waitForPromise( - () => { - console.log(chrome$('.buttonicon-bold').parent()[0].title); - return chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang]; - }); + () => chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang]); }; const getCommentId = () => { From 18136a687b7c054b7e78347e17db93038943101c Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 19:16:03 +0200 Subject: [PATCH 2/8] Increase timeout. --- static/tests/frontend/specs/comment_l10n.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 91b0c134..6e6e9549 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -108,23 +108,22 @@ const changeEtherpadLanguageTo = async (lang) => { 'pt-br': 'Negrito (Ctrl-B)', 'oc': 'Gras (Ctrl-B)', }; + this.timeout(1000); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); - // select the language + // click the language button const $language = chrome$('#languagemenu'); const $languageoption = $language.find(`[value=${lang}]`); + + // select language $languageoption.attr('selected', 'selected'); $language.trigger('change'); + this.timeout(2000); - // hide settings again - $settingsButton.click(); - - const $boldButton = chrome$('.buttonicon-bold').parent(); - console.log($boldButton[0].title); await helper.waitForPromise( () => chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang]); }; From a3bc09a9cef37f396981d57edbca7af8f1eb9bd1 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:31:44 +0200 Subject: [PATCH 3/8] Fixed line endings. Use exact code snippet from etherpad. --- static/tests/frontend/specs/comment_l10n.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 6e6e9549..46de3f6a 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -117,15 +117,14 @@ const changeEtherpadLanguageTo = async (lang) => { // click the language button const $language = chrome$('#languagemenu'); - const $languageoption = $language.find(`[value=${lang}]`); + // select passed language + $language.val(lang); + $language.change(); - // select language - $languageoption.attr('selected', 'selected'); - $language.trigger('change'); - this.timeout(2000); + // get the value of the bold button + const $boldButton = chrome$('.buttonicon-bold').parent(); - await helper.waitForPromise( - () => chrome$('.buttonicon-bold').parent()[0].title === boldTitles[lang]); + return helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); }; const getCommentId = () => { From f5db91922449b5fbbed9de238889db549cb3c4c9 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:38:24 +0200 Subject: [PATCH 4/8] Added missing await. --- static/tests/frontend/specs/comment_l10n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 46de3f6a..9a3d6374 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -124,7 +124,7 @@ const changeEtherpadLanguageTo = async (lang) => { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - return helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); + return await helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); }; const getCommentId = () => { From ae2cd9b20bf85cc195fbc7369814b79283c51a59 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:42:43 +0200 Subject: [PATCH 5/8] Don't return promise. --- static/tests/frontend/specs/comment_l10n.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 9a3d6374..184a1809 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -119,12 +119,12 @@ const changeEtherpadLanguageTo = async (lang) => { const $language = chrome$('#languagemenu'); // select passed language $language.val(lang); - $language.change(); + $language.trigger('change') // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - return await helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); + await helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); }; const getCommentId = () => { From 248425797157ffd9208f8e3aa4c3160d775adf17 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:46:01 +0200 Subject: [PATCH 6/8] Don't return promise. --- static/tests/frontend/specs/comment_l10n.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 184a1809..bb14b37d 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -108,7 +108,6 @@ const changeEtherpadLanguageTo = async (lang) => { 'pt-br': 'Negrito (Ctrl-B)', 'oc': 'Gras (Ctrl-B)', }; - this.timeout(1000); const chrome$ = helper.padChrome$; // click on the settings button to make settings visible @@ -119,12 +118,12 @@ const changeEtherpadLanguageTo = async (lang) => { const $language = chrome$('#languagemenu'); // select passed language $language.val(lang); - $language.trigger('change') + $language.trigger('change'); // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - await helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); + return helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); }; const getCommentId = () => { From 9f3d2c5ed10b6036e63177140a1ae405e1f84f09 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:55:14 +0200 Subject: [PATCH 7/8] Use == --- static/tests/frontend/specs/comment_l10n.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index bb14b37d..65a0a4b5 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -123,7 +123,7 @@ const changeEtherpadLanguageTo = async (lang) => { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - return helper.waitForPromise(() => $boldButton[0].title.contains(boldTitles[lang])); + return helper.waitForPromise(() => $boldButton[0].title == boldTitles[lang]); }; const getCommentId = () => { From 9f5c0912bbfb015238f2192bb0bddfdfe3e34028 Mon Sep 17 00:00:00 2001 From: SamTV12345 <40429738+samtv12345@users.noreply.github.com> Date: Wed, 9 Aug 2023 21:14:54 +0200 Subject: [PATCH 8/8] Output for testing. --- static/tests/frontend/specs/comment_l10n.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/tests/frontend/specs/comment_l10n.js b/static/tests/frontend/specs/comment_l10n.js index 65a0a4b5..a226c0a5 100644 --- a/static/tests/frontend/specs/comment_l10n.js +++ b/static/tests/frontend/specs/comment_l10n.js @@ -122,8 +122,8 @@ const changeEtherpadLanguageTo = async (lang) => { // get the value of the bold button const $boldButton = chrome$('.buttonicon-bold').parent(); - - return helper.waitForPromise(() => $boldButton[0].title == boldTitles[lang]); + console.log($boldButton[0].title); + return helper.waitForPromise(() => $boldButton[0].title === boldTitles[lang]); }; const getCommentId = () => {