test: cypress setup
This commit is contained in:
14
cypress/e2e/course_creation.cy.js
Normal file
14
cypress/e2e/course_creation.cy.js
Normal file
@@ -0,0 +1,14 @@
|
||||
describe("Course Creation", () => {
|
||||
beforeEach(() => {
|
||||
cy.login();
|
||||
cy.visit("/courses");
|
||||
});
|
||||
|
||||
it("creates a new course", () => {
|
||||
cy.get("button").contains("Create a Course").click();
|
||||
cy.get("button").contains("Add Tag").click();
|
||||
cy.get(".course-card-pills").type("Test");
|
||||
cy.get("#title").type("Test Course");
|
||||
cy.get("#intro").type("Test Course Short Introduction");
|
||||
});
|
||||
});
|
||||
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
51
cypress/support/commands.js
Normal file
51
cypress/support/commands.js
Normal file
@@ -0,0 +1,51 @@
|
||||
// ***********************************************
|
||||
// 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) => { ... })
|
||||
|
||||
Cypress.Commands.add("login", (email, password) => {
|
||||
if (!email) {
|
||||
email = Cypress.config("testUser") || "Administrator";
|
||||
}
|
||||
if (!password) {
|
||||
password = Cypress.config("adminPassword");
|
||||
}
|
||||
cy.request({
|
||||
url: "/api/method/login",
|
||||
method: "POST",
|
||||
body: { usr: email, pwd: password },
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add("button", (text) => {
|
||||
return cy.get(`button:contains("${text}")`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("iconButton", (text) => {
|
||||
return cy.get(`button[aria-label="${text}"]`);
|
||||
});
|
||||
|
||||
Cypress.Commands.add("dialog", (selector) => {
|
||||
return cy.get(`[role=dialog] ${selector}`);
|
||||
});
|
||||
20
cypress/support/e2e.js
Normal file
20
cypress/support/e2e.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import "./commands";
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
Reference in New Issue
Block a user