// yarn reset must be run in backend for the sign up test to work context('Happy Paths', () => { const min = 1; const max = 100; const email = Math.floor(min + (Math.random() * (max - min))) it('Successfully completes a happy path to add, edit, start and stop a quiz game', () => { // Sign in with new credentials cy.visit('localhost:3000/signup'); const name = 'sooria' const password = 'super secure password'; cy.get('input[name=name]').focus().type(name); cy.get('input[name=email]').focus().type(email); cy.get('input[name=password]').focus().type(password); cy.get('button[type=submit]').click(); // Check that sign up is successful cy.get('h1').then((h1) => { expect(h1.text()).to.contain('Dashboard'); }); // add a new quiz const quiz = 'test quiz' cy.get('input[name=newQuizInput]').focus().type(quiz); cy.get('button[type=submit]').click(); cy.wait(1000) // find edit button for quiz and go to edit quiz page cy.get('.editButton > .MuiButton-root').click(); // change quiz name and go back to dashboard to check that quiz name is changed const newQuizName = 'quiz name changed' cy.get('#quizName').focus().type(newQuizName); cy.get('.saveButton').click(); cy.get('.backToDashboard').click(); cy.get(':nth-child(1) > .quizName').should("have.text", newQuizName) // start the quiz game cy.get(':nth-child(5) > :nth-child(1) > .MuiButton-root').click() cy.get('.MuiBox-root > .MuiTypography-root').should("have.text", "New session has been started, click on button below to copy URL of game!") cy.get('body').click(0,0); // stop the quiz game cy.get(':nth-child(6) > :nth-child(1) > .MuiButton-root').click() cy.get('.MuiBox-root > .MuiTypography-root').should("have.text", "Game has been stopped, would you like to view results?") cy.get('body').click(0,0); // logout of BigBrain cy.get('.logoutButton').click(); cy.get('#email').should('be.visible') // sign in to BigBrain cy.get('input[name=email]').focus().type(email); cy.get('input[name=password]').focus().type(password); cy.get('button[type=submit]').click(); // Check that login is successful cy.get('h1').then((h1) => { expect(h1.text()).to.contain('Dashboard'); }); }); it('Successfully completes a happy path to add, edit and delete a question in a quiz', () => { cy.visit('localhost:3000/'); const password = 'super secure password'; // sign in to BigBrain cy.get('input[name=email]').focus().type(email); cy.get('input[name=password]').focus().type(password); cy.get('button[type=submit]').click(); // Check that sign in is successful cy.get('h1').then((h1) => { expect(h1.text()).to.contain('Dashboard'); }); // find edit button for quiz and go to edit quiz page cy.get('.editButton > .MuiButton-root').click(); // add question to quiz const questionTitle = '2 + 2 = ?' cy.get('.questionInput').type(questionTitle); cy.get('.addQuestionButton').click(); cy.get('.saveButton').click(); cy.get('.MuiTableBody-root > :nth-child(1) > :nth-child(1)').should('be.visible') // edit question's points, time limit and question type const points = '5' const timeLimit = '10' cy.get('.editQuesButton').click() cy.get('.pointsInput').type(points); cy.get('.timeInput').type(timeLimit); cy.get('.typeInput').type('Mul{enter}'); cy.get('.saveQuestion').click(); // go back to dashboard -> quiz edit page -> question edit page to ensure question changes reflect on the page cy.get('.backToDashboard').click(); cy.get('.editButton > .MuiButton-root').click(); cy.get('.editQuesButton').click() cy.get('.pointsCurrent').should("have.text", 'Points Currently: ' + points) cy.get('.timeCurrent').should("have.text", 'Time Limit Currently: ' + timeLimit) cy.get('.typeCurrent').should("have.text", 'Question Type Currently: Multiple Choice') // go back to dashboard -> quiz edit page to delete question cy.get('.backToDashboard').click(); cy.get('.editButton > .MuiButton-root').click(); cy.get('.deleteQuesButton').click(); cy.get('.saveButton').click(); }); });