Skip to content

Commit

Permalink
Fixes oppia#19916 : Adds openExternalPDFLink() Method for Anchor Tag …
Browse files Browse the repository at this point in the history
…Verification for puppeteer acceptance tests. (oppia#19917)

* Update e2e_lighthouse_performance_acceptance_tests.yml

* Update e2e_lighthouse_performance_acceptance_tests.yml

* added function openExternalPdfLink() in puppeteer

* lint check

* lint fix

* changes reverted in assests/i18n

* corrected

* Revoked changes in assets/i18n

* updates

* update the comment of the funciton and other changes

* updated the error message

* changes
  • Loading branch information
Akhilesh-max authored Mar 16, 2024
1 parent 7d0d2ba commit 13a2f6a
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "The Oppia Foundation",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "Building a community to provide quality education to those who lack access to it",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "Millions of children are not receiving the education they deserve.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Of the <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 million children</a> worldwide who cannot attend primary school, 17 million will never step foot into a school if trends continue. Unfortunately, <a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">even those who are in school</a> may not be getting the effective education they need.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Of the <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 million children</a> worldwide who cannot attend primary school, 17 million will never step foot into a school if trends continue. Unfortunately, <a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">even those who are in school</a> may not be getting the effective education they need.",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "There's a role for you to play",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_1": "Are you a part of a school, NGO, or other organization who shares our passion for educational inequality? <a href=\"/partnerships\" class=\"inline-links\">Consider becoming a partner today!</a>",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_2": "Do you have time, skills, or other resources you’d like to share to help advance our mission? <a href=\"/volunteer\" class=\"inline-links\">Join our large volunteer community!</a>",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "ओपिया फाउंडेशन",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "उन लोगों को उच्च शिक्षा प्रदान करने के लिए एक समुदाय का निर्माण करना जिनके पास इसकी पहुंच नहीं है",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "लाखों बच्चों को वह शिक्षा नहीं मिल रही जिसके वे हकदार हैं।",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "दुनिया भर में <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 मिलियन बच्चे</a> जो प्राथमिक विद्यालय में नहीं जा सकते, उनमें से 17 मिलियन बच्चे कभी भी स्कूल में कदम नहीं रखेंगे यदि रुझान जारी रहा। दुर्भाग्य से, <a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">जो लोग स्कूल में हैं उन्हें भी</a> वह प्रभावी शिक्षा नहीं मिल पा रही है जिसकी उन्हें ज़रूरत है।",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "दुनिया भर में <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 मिलियन बच्चे</a> जो प्राथमिक विद्यालय में नहीं जा सकते, उनमें से 17 मिलियन बच्चे कभी भी स्कूल में कदम नहीं रखेंगे यदि रुझान जारी रहा। दुर्भाग्य से, <a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">जो लोग स्कूल में हैं उन्हें भी</a> वह प्रभावी शिक्षा नहीं मिल पा रही है जिसकी उन्हें ज़रूरत है।",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "आपको एक भूमिका निभानी है",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_1": "क्या आप किसी स्कूल, एनजीओ या अन्य संगठन का हिस्सा हैं जो शैक्षिक असमानता के प्रति हमारे जुनून को साझा करता है? <a href=\"/partnerships\" class=\"inline-links\">आज ही भागीदार बनने पर विचार करें!</a>",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_2": "क्या आपके पास समय, कौशल या अन्य संसाधन हैं जिन्हें आप हमारे मिशन को आगे बढ़ाने में मदद करने के लिए साझा करना चाहते हैं? <a href=\"/volunteer\" class=\"inline-links\">हमारे बड़े स्वयंसेवक समुदाय में शामिल हों!</a>",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/pcm.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "Di Oppia foundation",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "We dey build community wen go provide quality education for people wey no fit get quality education.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "Many Many children no dey fit get the kind beta education wey dem suppose get.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Of the <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 million children</a> worldwide who cannot attend primary school, 17 million will never step foot into a school if trends continue. Unfortunately, <a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">even those who are in school</a> may not be getting the effective education they need.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Of the <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 million children</a> worldwide who cannot attend primary school, 17 million will never step foot into a school if trends continue. Unfortunately, <a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">even those who are in school</a> may not be getting the effective education they need.",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "You sef get role to play.",
"I18N_ABOUT_FOUNDATION_PAGE_TITLE": "Oppia Foundation Tori | Oppia",
"I18N_ABOUT_FOUNDATION_PAGE_WE_CANNOT": "We no fit comot eye for the work wen quality education fit do to better pipo life.",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "A Fundação Oppia",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "Construindo uma comunidade para fornecer educação de qualidade àqueles que não tem acesso a ela",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "Milhões de crianças não estão recebendo a educação que merecem.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Em <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 milhões de crianças</a> no mundo inteiro que não podem ir para o ensino básico, 17 milhões nunca colocarão os pés em uma escola se isso continuar, Infelizmente <a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">até mesmo esses que estão na escola</a> podem não ter uma educação efetiva como precisam.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Em <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">61 milhões de crianças</a> no mundo inteiro que não podem ir para o ensino básico, 17 milhões nunca colocarão os pés em uma escola se isso continuar, Infelizmente <a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">até mesmo esses que estão na escola</a> podem não ter uma educação efetiva como precisam.",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "Há um papel para você desempenhar",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_1": "Você faz parte de uma escola, ONG, ou outra organização que compartilha nossa paixão pela desigualdade educacional?<a href=\"/partnerships\" class=\"inline-links\"></a>",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_2": "Você tem tempo, habilidades ou outros recursos que gostaria de compartilhar para avançar nossa missão?<a href=\"/volunteer\" class=\"inline-links\"></a>",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "Shirika la Oppia",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "Kujenga jumuiya ili kutoa elimu bora kwa wale ambao hawana fursa ya kupata",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "Mamilioni ya watoto hawapati elimu wanayostahili",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Kati ya <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">watoto milioni 61</a> duniani kote ambao hawawezi kuhudhuria shule ya msingi, milioni 17 hawataingia shuleni kama mtindo huo utaendelea. Kwa bahati mbaya, <a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">hata wale ambao wako shuleni</a> wanaweza kuwa hawapati elimu bora wanayohitaji.",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "Kati ya <a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\">watoto milioni 61</a> duniani kote ambao hawawezi kuhudhuria shule ya msingi, milioni 17 hawataingia shuleni kama mtindo huo utaendelea. Kwa bahati mbaya, <a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">hata wale ambao wako shuleni</a> wanaweza kuwa hawapati elimu bora wanayohitaji.",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "Kuna jukumu kwako kutimiza",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_1": "Je, wewe ni sehemu ya shule, shirika la kiserikali, au shirika lingine ambalo lina shauku yetu kwa kutokuwa sawa katika elimu? <a href=\"/partnerships\" class=\"inline-links\">Fikiria kuwa mwenzi leo!</a>",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_2": "Je, una muda, ujuzi, au nyenzo nyinginezo ungependa kushiriki ili kusaidia kuendeleza dhamira yetu? <a href=\"/volunteer\" class=\"inline-links\">Jiunge na jumuiya yetu kubwa ya kujitolea!</a>",
Expand Down
2 changes: 1 addition & 1 deletion assets/i18n/zh-hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"I18N_ABOUT_FOUNDATION_PAGE_HEADING": "Oppia 基金會",
"I18N_ABOUT_FOUNDATION_PAGE_HEADING_CONTENT": "建立一個社群,為缺少資源的人提供優質教育。",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF": "有數百萬計兒童尚未獲得他們應有的教育。",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "如果這種趨勢持續下去,全世界的<a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\"> 6100 萬名</a>無法上小學的兒童中,會有 1700 萬人永遠不會踏入學校。另外不幸的是,<a href=\"http://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">即使有在就學的人</a>也可能無法得到他們所需的實用教育。",
"I18N_ABOUT_FOUNDATION_PAGE_MILLIONS_OF_CONTENT": "如果這種趨勢持續下去,全世界的<a href=\"http://uis.unesco.org/en/news/world-poverty-could-be-cut-half-if-all-adults-completed-secondary-education\" class=\"inline-links\"> 6100 萬名</a>無法上小學的兒童中,會有 1700 萬人永遠不會踏入學校。另外不幸的是,<a href=\"https://uis.unesco.org/sites/default/files/documents/fs46-more-than-half-children-not-learning-en-2017.pdf\" class=\"inline-links\">即使有在就學的人</a>也可能無法得到他們所需的實用教育。",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX": "這裡有個您可扮演的角色",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_1": "您是否是學校、非政府組織、或其他組織的成員,與我們一樣熱衷於解決教育不平等問題?<a href=\"/partnerships\" class=\"inline-links\">今天就考慮成為我們的合作夥伴吧!</a>",
"I18N_ABOUT_FOUNDATION_PAGE_SECTION_SIX_PART_2": "您是否有時間、技能,或是其他資源願意分享來幫助推廣我們的使命?<a href=\"/volunteer\" class=\"inline-links\">請加入我們龐大的志工社群!</a>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ export class BaseUser {
inputUploadHandle.uploadFile(fileToUpload);
}

/**
* This function validates whether an anchor tag is correctly linked
* to external PDFs or not. Use this particularly when interacting with
* buttons associated with external PDF links, because Puppeteer,
* in headless-mode, does not natively support the opening of external PDFs.
*/
async openExternalPdfLink(
selector: string,
expectedUrl: string
): Promise<void> {
await this.page.waitForSelector(selector);
const href = await this.page.$eval(selector, element =>
element.getAttribute('href')
);
if (href === null) {
throw new Error(`The ${selector} does not have a href attribute!`);
}
if (href !== expectedUrl) {
throw new Error(`Actual URL differs from expected. It opens: ${href}.`);
}
}

/**
* This function logs out the current user.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,35 +314,27 @@ export class LoggedInUser extends BaseUser {
showMessage('The 61 Million Children link opens the right page.');
}
}

/**
* Function to click the even those who are in school link
* in the About Foundation page and check if it opens the right page.
*/
async clickEvenThoseWhoAreInSchoolLinkInAboutFoundation(): Promise<void> {
await this.page.waitForSelector(millionsOfContentId);
const anchorElementSelector = `${millionsOfContentId} a:nth-child(2)`;
const buttonText = await this.page.$eval(
millionsOfContentId,
element => element.getElementsByTagName('a')[1].textContent
anchorElementSelector,
element => element.textContent
);
if (buttonText !== 'even those who are in school') {
throw new Error(
'The Even Those Who Are In School button does not exist!'
);
}
await this.page.$eval(millionsOfContentId, element =>
element.getElementsByTagName('a')[1].click()
await this.openExternalPdfLink(
anchorElementSelector,
evenThoseWhoAreInSchoolUrl
);
if (this.page.url() !== evenThoseWhoAreInSchoolUrl) {
throw new Error(
'The Even Those Who Are In School link does not open ' +
'the right page!'
);
} else {
showMessage(
'The Even Those Who Are In School link opens the right page.'
);
}
showMessage('The Even Those Who Are In School link opens the right page.');
}

/**
Expand Down

0 comments on commit 13a2f6a

Please sign in to comment.