Skip to content

Commit

Permalink
Merge pull request #9 from SEPM-2022/feature/e2e-tests
Browse files Browse the repository at this point in the history
Feature/e2e tests
  • Loading branch information
Akk3d1s committed May 26, 2022
2 parents e75f3af + afeb3d0 commit 1376138
Show file tree
Hide file tree
Showing 14 changed files with 1,572 additions and 40 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ __pycache__/app.cpython-38.pyc
__pycache__/models.cpython-38.pyc
controllers/__pycache__
*.pyc
e2e/node_modules
e2e/cypress/videos
5 changes: 5 additions & 0 deletions e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"baseUrl": "http://host.docker.internal",
"pluginsFile": false,
"supportFile": false
}
80 changes: 80 additions & 0 deletions e2e/cypress/integration/dynamic-pages.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
describe('Test dynamic pages', () => {
const randomNumber = Math.floor(Math.random() * 1000);
const name = 'cypress_name' + randomNumber;
const password = 'cypress_password' + randomNumber;
const username = 'cypress_username' + randomNumber;
const email = 'email' + randomNumber + '@cypress.com';

it('when clicking on create an account, then should open respective page', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#signup').click()

cy.url().should('include', '/signup')
cy.contains('Create your profile')
})

it('when filling out registration form, should create account', () => {
cy.visit(Cypress.config().baseUrl + '/signup')


cy.get('#form-name')
.type(name)
.should('have.value', name)

cy.get('#form-password')
.type(password)
.should('have.value', password)

cy.get('#form-username')
.type(username)
.should('have.value', username)

cy.get('#form-email')
.type(email)
.should('have.value', email)

cy.get('[type="radio"]').check('girl')
cy.get('#next-step').click();
cy.get('#form-daisy').click()

cy.contains('Congrats! Your acount has been successfully created!')
})

it('when filling out correct login details, should be directed to dashboard', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#Username')
.type(username)
.should('have.value', username)

cy.get('#password')
.type(password)
.should('have.value', password)

cy.get('#form-login').submit()

cy.url().should('include', '/login')
cy.contains('User Dashboard')
})

it('when filling out false login details, should stay on same page', () => {
cy.visit(Cypress.config().baseUrl)

const notExistUsername = 'notExistUsername'
const notExistPassword = 'notExistPassword'

cy.get('#Username')
.type(notExistUsername)
.should('have.value', notExistUsername)

cy.get('#password')
.type(notExistPassword)
.should('have.value', notExistPassword)

cy.get('#form-login').submit()

cy.url().should('include', '/login')
cy.contains('Not Registered?')
})
})
60 changes: 60 additions & 0 deletions e2e/cypress/integration/static-pages.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
describe('Test static pages', () => {
it('when clicking on About link, then should open respective page', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#header-about').click()

cy.url().should('include', '/about')
cy.contains('How to play Clever Birds Game?')
})

it('when clicking on Talk to Tweety link, then should open respective page', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#header-tweety').click()

cy.url().should('include', '/tweety')
cy.get('#tweety-img').should('have.attr', 'src', '/static/img/tweety-wait.gif')
})

it('when clicking on privacy policy document link, then should open respective page', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#footer-privacy-policy').click()

cy.url().should('include', '/privacy')
cy.contains('Privacy Policy')
})

it('should have correct github url', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#footer-github-repo').should('have.attr', 'href', 'https://github.com/SEPM-2022/CleverBirds')
})

it('when clicking on play now link, then should open game page', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('#header-game').click()

cy.url().should('include', '/playgame')
cy.get('iframe').should('have.attr', 'src', 'http://localhost:8080?bird=birdy')
})

it('when clicking on chat icon, then should open chatbot', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('df-messenger').find('#widgetIcon', { includeShadowDom: true }).click();

cy.get('df-messenger').find('.df-messenger-wrapper', { includeShadowDom: true }).should('have.class', 'expanded')
})

it('when chatbot is open and clicking on close button, then should close chatbot', () => {
cy.visit(Cypress.config().baseUrl)

cy.get('df-messenger').find('#widgetIcon', { includeShadowDom: true }).click();
cy.get('df-messenger').find('#widgetIcon', { includeShadowDom: true }).click();

cy.get('df-messenger').find('.df-messenger-wrapper', { includeShadowDom: true }).should('not.have.class', 'expanded')
})
})
Loading

0 comments on commit 1376138

Please sign in to comment.