mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-01 12:48:08 +09:00
Merge pull request #786 from FOSSBilling/cypress
This commit is contained in:
13 files changed
+2998
-263
No files matched your search
@@ -0,0 +1,19 @@
|
||||
const { defineConfig } = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
baseUrl: 'http://localhost',
|
||||
experimentalStudio: true,
|
||||
experimentalRunAllSpecs: true,
|
||||
credentials: {
|
||||
staff: {
|
||||
email: "admin@fossbilling.org",
|
||||
password: "Admin123+"
|
||||
},
|
||||
client: {
|
||||
email: "client@fossbilling.org",
|
||||
password: "Client123+"
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
describe('Admin:Index', () => {
|
||||
|
||||
it('redirects unauthorized users to the login page', function() {
|
||||
cy.visit('/admin/index');
|
||||
|
||||
cy.location('pathname').should('eq', '/admin/staff/login')
|
||||
});
|
||||
|
||||
it('successfully loads when logged in', function () {
|
||||
cy.staffLogin()
|
||||
|
||||
cy.visit('/admin/index');
|
||||
|
||||
cy.location('pathname').should('eq', '/admin/index')
|
||||
cy.get('.ml-2').should('have.text', 'Visit client area');
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,27 @@
|
||||
describe('Admin:Login', () => {
|
||||
|
||||
it('successfully loads', function() {
|
||||
cy.visit('/admin');
|
||||
|
||||
cy.location('pathname').should('eq', '/admin/staff/login') // test the redirect
|
||||
|
||||
cy.get('.h2').should('have.text', 'Log into your account');
|
||||
cy.get('.btn').should('be.visible');
|
||||
|
||||
});
|
||||
|
||||
it('displays an error for failed login attempts', function() {
|
||||
cy.visit('/admin/staff/login');
|
||||
|
||||
cy.get('#inputEmail').type('this-will-fail@fossbilling.org');
|
||||
cy.get('#inputPassword').type('fossbilling.org');
|
||||
|
||||
cy.get('.btn').click();
|
||||
cy.get('.toast-body').should('have.text', 'Check your login details (403)');
|
||||
});
|
||||
|
||||
it('successfully logs in', function () {
|
||||
cy.staffLogin()
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
describe('Huraga:Index', () => {
|
||||
|
||||
it('successfully loads', function() {
|
||||
cy.visit('/');
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
/* ==== Generated with Cypress Studio ==== */
|
||||
cy.get(':nth-child(4) > .show-tip').should('have.text', 'Login');
|
||||
cy.get(':nth-child(5) > .show-tip').should('have.text', 'Register');
|
||||
/* ==== End Cypress Studio ==== */
|
||||
});
|
||||
|
||||
it('successfully loads when logged in', function () {
|
||||
cy.clientLogin()
|
||||
|
||||
cy.visit('/');
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
/* ==== Generated with Cypress Studio ==== */
|
||||
cy.get(':nth-child(4) > .show-tip').should('have.text', 'Profile');
|
||||
cy.get(':nth-child(5) > .show-tip').should('have.text', 'Sign out');
|
||||
/* ==== End Cypress Studio ==== */
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
describe('Huraga:Login', () => {
|
||||
|
||||
it('successfully loads', function() {
|
||||
cy.visit('/login');
|
||||
|
||||
cy.get('h2').should('have.text', 'Login');
|
||||
cy.get('.btn').should('be.visible');
|
||||
});
|
||||
|
||||
it('displays an error for failed login attempts', function() {
|
||||
cy.visit('/login');
|
||||
|
||||
cy.get('#icon').type('this-will-fail@fossbilling.org');
|
||||
cy.get('#password').type('fossbilling.org');
|
||||
|
||||
cy.get('.btn').click();
|
||||
cy.get('.jGrowl-message').should('have.text', 'Unauthorized');
|
||||
});
|
||||
|
||||
it('successfully logs in', function () {
|
||||
cy.clientLogin()
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,37 @@
|
||||
describe('Huraga:Support', () => {
|
||||
|
||||
it('redirects to the login page when unauthorized', function() {
|
||||
cy.visit('/support');
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
});
|
||||
|
||||
it('creates a new ticket and closes it', function () {
|
||||
cy.clientLogin()
|
||||
|
||||
cy.visit('/support');
|
||||
cy.location('pathname').should('eq', '/support');
|
||||
|
||||
// The "submit new ticket" button should now be visible
|
||||
cy.get('#new-ticket-button').should('have.text', 'Submit new ticket');
|
||||
cy.get('#new-ticket-button').click();
|
||||
|
||||
// The modal should now be visible
|
||||
cy.get('input[name="subject"]').type('Testing')
|
||||
cy.get('textarea[name="content"]').type('This is a test message.')
|
||||
|
||||
cy.get('.modal-footer > .btn').should('be.visible');
|
||||
cy.get('.modal-footer > .btn').click();
|
||||
|
||||
// Make sure we are redirected to the ticket and the subject is correct
|
||||
cy.get(':nth-child(2) > .data-block > .data-container > :nth-child(1) > h2').should('have.text', 'Testing');
|
||||
|
||||
// Close the ticket
|
||||
cy.get('#ticket-close').should('be.visible');
|
||||
cy.get('#ticket-close').click();
|
||||
|
||||
// Make sure we are redirected to the support index
|
||||
cy.location('pathname').should('eq', '/support');
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,24 @@
|
||||
describe('/api/guest/system', () => {
|
||||
|
||||
it('returns the version', function() {
|
||||
cy.request('/api/guest/system/version').then((response) => {
|
||||
expect(response.status).to.eq(200)
|
||||
expect(response.body.result).to.be.a('string')
|
||||
expect(response.body.error).to.be.null
|
||||
|
||||
cy.log(`This instance of FOSSBilling is running on the version ${response.body.result}.`)
|
||||
})
|
||||
})
|
||||
|
||||
it('returns the company information', function() {
|
||||
cy.request('/api/guest/system/company').then((response) => {
|
||||
expect(response.status).to.eq(200)
|
||||
expect(response.body.result).to.be.a('object')
|
||||
expect(response.body.result.name).to.be.a('string')
|
||||
expect(response.body.error).to.be.null
|
||||
|
||||
cy.log(`This instance of FOSSBilling is named "${response.body.result.name}".`)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
describe('Test the API route for a non-existent module', () => {
|
||||
|
||||
it('the guest API returns an error', function() {
|
||||
cy.request('/api/guest/nonexistent/testing').then((response) => {
|
||||
// expect(response.status).to.eq(400) // FOSSBilling returns 200
|
||||
expect(response.body.result).to.be.null
|
||||
expect(response.body.error.message).eq('FOSSBilling module nonexistent is not installed/activated')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
@@ -0,0 +1,49 @@
|
||||
Cypress.Commands.add('staffLogin', (username, password) => {
|
||||
// If the username and the password are not provided, use the credentials from the config file
|
||||
username = username || Cypress.config("credentials").staff.email
|
||||
password = password || Cypress.config("credentials").staff.password
|
||||
|
||||
cy.session(
|
||||
username,
|
||||
() => {
|
||||
cy.visit('/admin/staff/login');
|
||||
|
||||
cy.get('#inputEmail').type(username);
|
||||
cy.get('#inputPassword').type(password);
|
||||
|
||||
cy.get('.btn').click();
|
||||
|
||||
cy.url().should('eq', `${Cypress.config().baseUrl}/admin/index`)
|
||||
},
|
||||
{
|
||||
validate: () => {
|
||||
cy.getCookie('PHPSESSID').should('exist')
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Cypress.Commands.add('clientLogin', (username, password) => {
|
||||
// If the username and the password are not provided, use the credentials from the config file
|
||||
username = username || Cypress.config("credentials").client.email
|
||||
password = password || Cypress.config("credentials").client.password
|
||||
|
||||
cy.session(
|
||||
username,
|
||||
() => {
|
||||
cy.visit('/login');
|
||||
|
||||
cy.get('#icon').type(username);
|
||||
cy.get('#password').type(password);
|
||||
|
||||
cy.get('.btn').click();
|
||||
|
||||
cy.url().should('eq', `${Cypress.config().baseUrl}/`)
|
||||
},
|
||||
{
|
||||
validate: () => {
|
||||
cy.getCookie('PHPSESSID').should('exist')
|
||||
},
|
||||
}
|
||||
)
|
||||
})
|
||||
Generated
+2734
-234
File diff suppressed because it is too large.
Load diff
+3
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "fossbilling",
|
||||
"version": "0.1.0",
|
||||
"author": "FOSSBilling Team",
|
||||
"homepage": "https://fossbilling.org",
|
||||
"license": "Apache License 2.0",
|
||||
"scripts": {
|
||||
"build": "gulp build",
|
||||
"watch": "gulp watch"
|
||||
"watch": "gulp watch",
|
||||
"cypress:open": "cypress open"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -30,6 +30,7 @@
|
||||
"babel-register": "^6.26.0",
|
||||
"bootstrap": "^5.2.3",
|
||||
"bootstrap-markdown": "^2.10.0",
|
||||
"cypress": "^12.5.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-autoprefixer": "^8.0.0",
|
||||
"gulp-cheerio": "^1.0.0",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"name": "fossbilling/fossbilling",
|
||||
"description": "Free and Open Source Billing System",
|
||||
"version": "4.22.0-beta.5",
|
||||
"support": {
|
||||
"docs": "https://fossbilling.org/docs",
|
||||
"source": "https://github.com/FOSSBilling/FOSSBilling",
|
||||
|
||||
Generated
+27
-26
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ba433e9f6174d13a867d6bcf8ade6e72",
|
||||
"content-hash": "cf4345f0e9235759dca2f88f8973b356",
|
||||
"packages": [
|
||||
{
|
||||
"name": "composer/ca-bundle",
|
||||
@@ -1292,29 +1292,30 @@
|
||||
},
|
||||
{
|
||||
"name": "nette/utils",
|
||||
"version": "v3.2.9",
|
||||
"version": "v4.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nette/utils.git",
|
||||
"reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c"
|
||||
"reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nette/utils/zipball/c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c",
|
||||
"reference": "c91bac3470c34b2ecd5400f6e6fdf0b64a836a5c",
|
||||
"url": "https://api.github.com/repos/nette/utils/zipball/cacdbf5a91a657ede665c541eda28941d4b09c1e",
|
||||
"reference": "cacdbf5a91a657ede665c541eda28941d4b09c1e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2 <8.3"
|
||||
"php": ">=8.0 <8.3"
|
||||
},
|
||||
"conflict": {
|
||||
"nette/di": "<3.0.6"
|
||||
"nette/finder": "<3",
|
||||
"nette/schema": "<1.2.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"jetbrains/phpstorm-attributes": "dev-master",
|
||||
"nette/tester": "~2.0",
|
||||
"nette/tester": "^2.4",
|
||||
"phpstan/phpstan": "^1.0",
|
||||
"tracy/tracy": "^2.3"
|
||||
"tracy/tracy": "^2.9"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-gd": "to use Image",
|
||||
@@ -1328,7 +1329,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.2-dev"
|
||||
"dev-master": "4.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -1372,9 +1373,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/nette/utils/issues",
|
||||
"source": "https://github.com/nette/utils/tree/v3.2.9"
|
||||
"source": "https://github.com/nette/utils/tree/v4.0.0"
|
||||
},
|
||||
"time": "2023-01-18T03:26:20+00:00"
|
||||
"time": "2023-02-02T10:41:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phenx/php-font-lib",
|
||||
@@ -3837,16 +3838,16 @@
|
||||
},
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
"version": "2.0.0",
|
||||
"version": "2.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/doctrine/annotations.git",
|
||||
"reference": "d02c9f3742044e17d5fa8d28d8402a2d95c33302"
|
||||
"reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/doctrine/annotations/zipball/d02c9f3742044e17d5fa8d28d8402a2d95c33302",
|
||||
"reference": "d02c9f3742044e17d5fa8d28d8402a2d95c33302",
|
||||
"url": "https://api.github.com/repos/doctrine/annotations/zipball/e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f",
|
||||
"reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3907,9 +3908,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/doctrine/annotations/issues",
|
||||
"source": "https://github.com/doctrine/annotations/tree/2.0.0"
|
||||
"source": "https://github.com/doctrine/annotations/tree/2.0.1"
|
||||
},
|
||||
"time": "2022-12-19T18:17:20+00:00"
|
||||
"time": "2023-02-02T22:02:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/deprecations",
|
||||
@@ -4991,21 +4992,21 @@
|
||||
},
|
||||
{
|
||||
"name": "rector/rector",
|
||||
"version": "0.15.10",
|
||||
"version": "0.15.12",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rectorphp/rector.git",
|
||||
"reference": "000bfb6f7974449399f39e1a210458395b75c887"
|
||||
"reference": "9b9b8ed4d918abcd999f4a7c2575834a8aede929"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/000bfb6f7974449399f39e1a210458395b75c887",
|
||||
"reference": "000bfb6f7974449399f39e1a210458395b75c887",
|
||||
"url": "https://api.github.com/repos/rectorphp/rector/zipball/9b9b8ed4d918abcd999f4a7c2575834a8aede929",
|
||||
"reference": "9b9b8ed4d918abcd999f4a7c2575834a8aede929",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2|^8.0",
|
||||
"phpstan/phpstan": "^1.9.7"
|
||||
"phpstan/phpstan": "^1.9.14"
|
||||
},
|
||||
"conflict": {
|
||||
"rector/rector-doctrine": "*",
|
||||
@@ -5020,7 +5021,7 @@
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "0.14-dev"
|
||||
"dev-main": "0.15-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
@@ -5035,7 +5036,7 @@
|
||||
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
|
||||
"support": {
|
||||
"issues": "https://github.com/rectorphp/rector/issues",
|
||||
"source": "https://github.com/rectorphp/rector/tree/0.15.10"
|
||||
"source": "https://github.com/rectorphp/rector/tree/0.15.12"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@@ -5043,7 +5044,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-21T14:30:16+00:00"
|
||||
"time": "2023-02-03T17:49:48+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/cli-parser",
|
||||
|
||||
Reference in new issue
Block a user