Skip to content

Commit

Permalink
all tests work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyOei committed Nov 26, 2022
1 parent bfb953d commit 90e7d7c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 14 deletions.
2 changes: 1 addition & 1 deletion templates/customize-adventure.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h3 class="text-center">{{_('directly_add_adventure_to_classes')}}</h3>
<div class="flex flex-row justify-end gap-2 my-4">
<button class="blue-btn" id="preview_adventure_button" onclick="hedyApp.preview_adventure();event.preventDefault();">{{_('preview')}}</button>
<button type="submit" class="green-btn" id="save_adventure_button">{{_('save')}}</button>
<button type="reset" class="red-btn" id="delete_adventure_button" onclick="hedyApp.delete_adventure('{{ adventure.id }}', '{{_('delete_adventure_prompt')}}')">{{_('remove')}}</button>
<button type="reset" class="red-btn" id="remove_adventure_button" onclick="hedyApp.delete_adventure('{{ adventure.id }}', '{{_('delete_adventure_prompt')}}')">{{_('remove')}}</button>
</div>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/for-teachers.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h2>{{_('my_adventures')}}</h2>
</tbody>
</table>
{% endif %}
<button class="green-btn mt-4" onclick='hedyApp.create_adventure({{_('adventure_prompt')|tojson}})'>{{_('create_adventure')}}</button>
<button class="green-btn mt-4" id="create_adventure_button" onclick='hedyApp.create_adventure({{_('adventure_prompt')|tojson}})'>{{_('create_adventure')}}</button>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import {loginForTeacher} from '../../tools/login/login.js'
import {goToEditAdventure} from '../../tools/navigation/nav.js'
import { createAdventure } from '../../tools/adventures/adventure.js'

describe('Preview button test', () => {
it('passes', () => {
loginForTeacher();
goToEditAdventure();

// Initially this should not be visible
cy.get('#modal-confirm')
.should('not.be.visible');

// Testing not removing adventure (clicking on remove and then on 'no')
cy.get('#remove_adventure_button')
.should('be.visible');
.should('be.visible')
.should('have.attr', 'type', 'reset')
.click();

cy.get('#modal-confirm')
.should('be.visible');

cy.get('#modal-yes-button')
.should('be.visible');

cy.get('#modal-no-button')
.should('be.visible')
.click();
Expand All @@ -28,5 +28,20 @@ describe('Preview button test', () => {

cy.get('#modal-confirm')
.should('not.be.visible');

// Creating a new adventure to remove
createAdventure();

// Testing removing adventure (clicking on remove and then on 'yes')
cy.get('#remove_adventure_button')
.click();

cy.get('#modal-yes-button')
.should('be.visible')
.click();

// back to for-teacher page
cy.url()
.should('eq', Cypress.config('baseUrl') + Cypress.env('teachers_page'));
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ describe('Save button test', () => {
cy.get('#save_adventure_button')
.click();

cy.get('#modal-confirm')
.should('be.visible');

cy.get('#modal-no-button')
.should('be.visible')
.click();
Expand All @@ -56,10 +53,5 @@ describe('Save button test', () => {
.should('not.be.visible');
cy.get('#modal_alert_text')
.should('not.be.visible');

cy.wait(500);

cy.get('#modal-confirm')
.should('not.be.visible');
})
})
19 changes: 19 additions & 0 deletions tests/cypress/e2e/tools/adventures/adventure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { goToTeachersPage } from "../navigation/nav";

export function createAdventure()
{
goToTeachersPage();

// Click 'Create new class' button
cy.get('#create_adventure_button').click();

// Type 'test class'
cy.get('#modal-prompt-input').type("test adventure");

// Click 'ok'
cy.get('#modal-ok-button').click();

cy.wait(500);
}

export default {createAdventure};

0 comments on commit 90e7d7c

Please sign in to comment.