test: cypress setup
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -8,3 +8,5 @@ lms/public/dist
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
12
cypress.config.js
Normal file
12
cypress.config.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
const { defineConfig } = require("cypress");
|
||||||
|
|
||||||
|
module.exports = defineConfig({
|
||||||
|
projectId: "",
|
||||||
|
adminPassword: "admin",
|
||||||
|
testUser: "ash@ipp.com",
|
||||||
|
retries: {
|
||||||
|
runMode: 2,
|
||||||
|
openMode: 0,
|
||||||
|
},
|
||||||
|
e2e: {},
|
||||||
|
});
|
||||||
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')
|
||||||
28
package.json
Normal file
28
package.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "frappe_lms",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Easy to use, open-source, Learning Management System",
|
||||||
|
"scripts": {
|
||||||
|
"test-local": "cypress open --e2e --browser chrome"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/frappe/lms.git"
|
||||||
|
},
|
||||||
|
"author": "Frappe",
|
||||||
|
"license": "AGPL-3.0-or-later",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/frappe/lms/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/frappe/lms#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"cypress": "^10"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@4tw/cypress-drag-drop": "^2",
|
||||||
|
"@cypress/code-coverage": "^3",
|
||||||
|
"@testing-library/cypress": "^8",
|
||||||
|
"@testing-library/dom": "8.17.1",
|
||||||
|
"cypress-real-events": "^1.7.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user