Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TESTING] Adds test for Hedy's choice programs #4460

Merged
merged 4 commits into from
Sep 9, 2023
Merged
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
6 changes: 3 additions & 3 deletions templates/class-overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div>
{% if achievement %}
<script>
$(function() {
hedyApp.showAchievements({{ achievement|safe }}, false, "");
});
document.addEventListener("DOMContentLoaded", function() {
hedyApp.showAchievements({{ achievement|safe }}, false, "");
});
</script>
{% endif %}
<div class="flex flex-col gap-4">
Expand Down
10 changes: 5 additions & 5 deletions templates/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<div class="px-8 py-12">
{% if achievement %}
<script>
$(function() {
hedyApp.showAchievements({{ achievement|safe }}, false, "");
});
document.addEventListener("DOMContentLoaded", function() {
hedyApp.showAchievements({{ achievement|safe }}, false, "");
});
</script>
{% endif %}
<!-- <h2 class="px-8 mb-4">{{_('explore_programs')}}</h2> -->
Expand Down Expand Up @@ -39,7 +39,7 @@
<h2 class="text-center z-10 font-bold pb-0 mb-0 text-3xl">{{_('hedy_choice_title')}}</h2>
<div class="flex flex-wrap mx-auto justify-center gap-4 turn-pre-into-ace" id="explore_favourite_programs">
{% for program in favourite_programs %}
{{ public_programs.program_box(program, true) }}
{{ public_programs.program_box(program, true, is_admin) }}
{% endfor %}
</div>
</div>
Expand All @@ -50,7 +50,7 @@ <h2 class="text-center z-10 font-bold pb-0 mb-0 text-3xl">{{_('hedy_choice_title
{{_('no_programs')}}
{% else %}
{% for program in programs %}
{{ public_programs.program_box(program, false) }}
{{ public_programs.program_box(program, false, is_admin) }}
{% endfor %}
{% endif %}
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/macros/public-programs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% macro program_box(program, is_favorite) %}
<div class="explore-program-box overflow-hidden">
{% macro program_box(program, is_favorite, is_admin) %}
<div class="explore-program-box overflow-hidden" data-cy="{{ program.id }}">
<div class="flex flex-col h-full">
<div class="explore-program-box-title
{% if is_favorite %} bg-yellow-500
Expand Down
1 change: 1 addition & 0 deletions tests/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ module.exports = defineConfig({
admin_achievements_page: '/admin/achievements',
admin_classes_page: '/admin/classes',
programs_page: '/programs',
explore_programs_page: '/explore',
}
});
27 changes: 27 additions & 0 deletions tests/cypress/e2e/explore_programs_page/explore_programs.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { loginForAdmin } = require("../tools/login/login");
const { goToExploreProgramsPage } = require("../tools/navigation/nav");

describe('Explore programs page', () => {
beforeEach(() => {
loginForAdmin();
goToExploreProgramsPage();
});

it('When selecting a program as Hedys choice, it should be shown', ()=>{
// Get the id of the first program in the db
cy.get('#explore_page_programs')
.children()
.first()
.invoke('attr', 'data-cy')
.as('program_id');

cy.get('@program_id').then(program_id => {
// mark the program as Hedys choice
cy.get(`#${program_id}`).click();
cy.get('#modal-yes-button').click();
// reload the page to see the changes
cy.reload();
cy.get(`#explore_favourite_programs > [data-cy=${program_id}]`).should('be.visible');
});
});
});
5 changes: 5 additions & 0 deletions tests/cypress/e2e/tools/navigation/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,9 @@ export function goToEditAdventure()
.click();
}

export function goToExploreProgramsPage()
{
return goToPage(Cypress.env('explore_programs_page'));
}

export default {goToPage}
Loading