Skip to content

Commit

Permalink
add tests for hedys choice
Browse files Browse the repository at this point in the history
  • Loading branch information
jpelay committed Sep 6, 2023
1 parent 78f0abd commit 3186544
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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, is_admin) %}
<div class="explore-program-box overflow-hidden">
<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}

0 comments on commit 3186544

Please sign in to comment.