feat(test, e2e) test suit for cypress (#42138)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Sem Bauke
2021-06-14 18:37:52 +02:00
committed by GitHub
parent 08fc4014c7
commit 22b45761a7
35 changed files with 367 additions and 55 deletions

View File

@ -1,37 +1,4 @@
/* global cy Cypress*/
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => {});
//
//
// -- This is a child command --
// Cypress.Commands.add(
// 'drag',
// { prevSubject: 'element' },
// (subject, options) => {}
// );
//
//
// -- This is a dual command --
// Cypress.Commands.add(
// 'dismiss',
// { prevSubject: 'optional' },
// (subject, options) => {}
// );
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => {});
/* global cy Cypress */
Cypress.Commands.add('login', () => {
cy.visit('/');
@ -52,3 +19,50 @@ Cypress.Commands.add('resetUsername', () => {
cy.contains('Account Settings for developmentuser').should('be.visible');
});
Cypress.Commands.add('testChallenges', () => {
// Test Meta tags
cy.get('head meta[charset=utf-8]');
cy.get('head meta[name=description]').should('have.attr', 'content');
// Test breadcrumbs
cy.get('.breadcrumb-right').should('have.attr', 'href');
cy.get('.ellipsis').should('be.visible');
cy.get('.breadcrumb-left').should('have.attr', 'href');
cy.get('.breadcrumb-left').should('be.visible', 'href');
cy.get('body').should('be.visible');
// Challenge content
cy.get('.challenge-title').should('be.visible');
cy.get('#description').should('be.visible');
// Monaco editor
cy.get('.react-monaco-editor-container')
.click()
.focused()
.type('<h1> Hello world! </h1>');
// Ensure that there are test
cy.get('.challenge-test-suite').children().its('length').should('be.gt', 0);
});
// This command can be used to test projects and back-end challenges
Cypress.Commands.add('testProjectsAndBackend', () => {
// Test breadcrumbs
cy.get('.breadcrumb-right').should('have.attr', 'href');
cy.get('.ellipsis').should('be.visible');
cy.get('.breadcrumb-left').should('have.attr', 'href');
cy.get('.breadcrumb-left').should('be.visible', 'href');
// Challenge content
cy.get('.challenge-title').should('be.visible');
cy.get('#description').should('be.visible');
// Shoud be possible to submit solution
cy.get('input[name=solution]')
.click()
.type('https://codepen.io/foobar/full/RKRbwL');
cy.get('button[type=submit]').first().click();
});