Skip to content
Snippets Groups Projects
Commit b62c28d2 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #14127 TIME 4:30 add e2e cypress

parent a6a873f4
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ apps/maarch_entreprise/xml/mailevaConfig.xml ...@@ -6,6 +6,7 @@ apps/maarch_entreprise/xml/mailevaConfig.xml
apps/maarch_entreprise/xml/log4php.xml apps/maarch_entreprise/xml/log4php.xml
*.log *.log
test/unitTests/build/ test/unitTests/build/
cypress/
modules/visa/xml/remoteSignatoryBooks.xml modules/visa/xml/remoteSignatoryBooks.xml
dist/ dist/
node_modules/ node_modules/
......
...@@ -47,22 +47,13 @@ job_e2e: ...@@ -47,22 +47,13 @@ job_e2e:
image: php:7.4-apache image: php:7.4-apache
stage: test stage: test
script: script:
- service apache2 start
- touch installed.lck
- chown -R www-data. /opt/maarch/
- chown -R www-data. /var/www/html/
- chmod -R 775 /opt/maarch/
- chmod -R 775 /var/www/html/
- curl -sL https://deb.nodesource.com/setup_14.x | bash - > /dev/null - curl -sL https://deb.nodesource.com/setup_14.x | bash - > /dev/null
- apt-get install -yqq nodejs > /dev/null - apt-get install -yqq nodejs > /dev/null
- npm install npm@latest -g - npm install npm@latest -g
- node -v - node -v
- npm set registry https://registry.npmjs.org/ - npm set registry https://registry.npmjs.org/
- npm install > /dev/null - npm install > /dev/null
- npm run build-prod - npm run cypress:run
- curl -o /dev/null --silent --head --write-out '%{http_code}\n' http://127.0.0.1/MaarchCourrier
- firefox --version
- npm run ee-launch
artifacts: artifacts:
paths: paths:
- queries_error.log - queries_error.log
......
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
"upgrade": "ncu -u", "upgrade": "ncu -u",
"create-component": "echo Component name ? && read varname && ng g c $varname --module app --style=scss", "create-component": "echo Component name ? && read varname && ng g c $varname --module app --style=scss",
"create-component-admin": "echo Component name ? && read varname && ng g c administration/$varname --module administration --style=scss", "create-component-admin": "echo Component name ? && read varname && ng g c administration/$varname --module administration --style=scss",
"ee-launch": "webdriver-manager update && webdriver-manager start --detach && protractor test/e2e/conf.js && webdriver-manager shutdown && fuser -k 4444/tcp", "cypress:open": "cypress open --config-file test/e2e/cypress-config.json",
"ee-update": "webdriver-manager update", "cypress:run": "cypress run --browser firefox --headless --config-file test/e2e/cypress-config.json"
"ee-start-server": "webdriver-manager start",
"ee-test": "protractor test/e2e/conf.js"
}, },
"keywords": [], "keywords": [],
"author": "Maarch", "author": "Maarch",
...@@ -53,6 +51,7 @@ ...@@ -53,6 +51,7 @@
"bootstrap": "^3.4.1", "bootstrap": "^3.4.1",
"chosen-js": "^1.8.7", "chosen-js": "^1.8.7",
"codelyzer": "^6.0.1", "codelyzer": "^6.0.1",
"cypress": "^6.2.1",
"flat-to-nested": "^1.1.0", "flat-to-nested": "^1.1.0",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"html-minifier": "^4.0.0", "html-minifier": "^4.0.0",
...@@ -71,7 +70,6 @@ ...@@ -71,7 +70,6 @@
"npm-check-updates": "^9.2.4", "npm-check-updates": "^9.2.4",
"pdfjs-dist": "2.5.207", "pdfjs-dist": "2.5.207",
"photoswipe": "^4.1.3", "photoswipe": "^4.1.3",
"protractor": "^7.0.0",
"rxjs": "^6.6.3", "rxjs": "^6.6.3",
"tinymce": "^5.6.1", "tinymce": "^5.6.1",
"tinymce-i18n": "^20.12.25", "tinymce-i18n": "^20.12.25",
......
describe('about-us page', function() {
it('test page', function() {
browser.sleep(2000);
element(by.css('[title="Accueil"]')).click();
browser.sleep(2000);
});
});
exports.config = {
baseUrl: 'http://127.0.0.1/MaarchCourrier',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: [
'login-spec.js',
'index-resource-spec.js',
//'about-us-spec.js'
],
multiCapabilities: [
{
'browserName': 'chrome',
'chromeOptions': {
'args': ["--no-sandbox", "--headless", "--disable-gpu", "--window-size=1920,1080"]
},
},
{
'browserName': 'firefox',
'moz:firefoxOptions': {
'args': ["--headless", "--width=1920", "--height=1080"]
}
}
],
chromeDriver: '/usr/bin/chromedriver',
maxSessions: 1,
onPrepare: () => {
browser.driver.getCapabilities().then(function(caps){
browser.browserName = caps.get('browserName');
});
}
};
{
"baseUrl": "https://demo.maarchcourrier.com/dist/index.html#/",
"integrationFolder" : "test/e2e",
"testFiles" : "**/*.spec.ts",
"supportFile" : "test/e2e/support"
}
\ No newline at end of file
var ScreenshotReporter = require('./screenshotReporter.js');
afterEach(function() {
if (browser.browserName === 'chrome') {
browser.manage().logs().get('browser').then(function(browserLog) {
console.log('log: ' + require('util').inspect(browserLog));
});
}
});
describe('index resource page', function () {
it('index a document whitout file', function () {
browser.sleep(2000);
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + "/dist/index.html#/home");
browser.takeScreenshot().then(function (png) {
ScreenshotReporter(png, 'test/e2e/screenshots/home_' + browser.browserName);
});
element(by.id('indexing')).click();
browser.sleep(500);
browser.takeScreenshot().then(function (png) {
ScreenshotReporter(png, 'test/e2e/screenshots/index_a_document_' + browser.browserName);
});
element(by.id('doctype')).click();
browser.sleep(500);
element(by.css('[title="Demande de renseignements"]')).click();
browser.sleep(500);
element(by.id('priority')).click();
browser.sleep(500);
element(by.css('[title="Normal"]')).click();
browser.sleep(500);
element(by.id('documentDate')).click();
browser.sleep(500);
element(by.css('.mat-calendar-body-active')).click();
browser.sleep(500);
element(by.id('subject')).sendKeys('test ee');
browser.sleep(500);
element(by.id('senders')).sendKeys('pascon');
browser.sleep(1000);
element(by.id('senders-6')).click();
browser.sleep(500);
element(by.id('destination')).click();
browser.sleep(500);
element(by.css('[title="Pôle Jeunesse et Sport"]')).click();
browser.sleep(500);
element(by.cssContainingText('.mat-button-wrapper', 'Valider')).click();
browser.sleep(500);
element(by.cssContainingText('.mat-button-wrapper', 'Ok')).click();
browser.sleep(500);
element(by.css('[placeholder="Ajouter une annotation"]')).sendKeys('test ee');
browser.sleep(500);
element(by.cssContainingText('.mat-dialog-content-container .mat-button-wrapper', 'Valider')).click();
browser.sleep(100);
browser.takeScreenshot().then(function (png) {
ScreenshotReporter(png, 'test/e2e/screenshots/validate_indexation_' + browser.browserName);
});
browser.sleep(500);
expect(browser.getCurrentUrl()).toContain('/resources/');
browser.sleep(4000);
});
});
describe('Indexing document EE', () => {
it('Record incoming mail', () => {
cy.login();
cy.visit('home')
cy.wait(500)
cy.get('#indexing')
.click()
cy.get('#doctype')
.click()
cy.wait(500)
cy.get('[title="Demande de renseignements"]')
.click({force: true});
cy.get('#priority')
.click()
cy.get('[title="Normal"]')
.click({force: true})
cy.get('#documentDate')
.click()
cy.get('.mat-calendar-body-active')
.click();
cy.get('#subject')
.type('test ee')
cy.get('#senders')
.type('pascon')
cy.get('#senders-6')
.click()
cy.get('#destination')
.click()
cy.wait(500)
cy.get('[title="Pôle Jeunesse et Sport"]')
.click({force: true});
cy.wait(500)
cy.get('.mat-button-wrapper')
.contains('Valider')
.click()
cy.wait(500)
cy.get('.mat-button-wrapper')
.contains('Ok')
.click()
cy.wait(500)
cy.get('[placeholder="Ajouter une annotation"]')
.type('test ee')
cy.get('.mat-dialog-content-container .mat-button-wrapper')
.contains('Valider')
.click()
cy.wait(500)
cy.url().should('include', '/resources/')
})
})
\ No newline at end of file
var ScreenshotReporter = require('./screenshotReporter.js');
afterEach(function() {
if (browser.browserName === 'chrome') {
browser.manage().logs().get('browser').then(function(browserLog) {
console.log('log: ' + require('util').inspect(browserLog));
});
}
});
describe('Login to app', function() {
it('login to app', function () {
browser.waitForAngularEnabled(true);
browser.get(browser.baseUrl + '/dist/index.html#/login');
browser.sleep(500);
browser.takeScreenshot().then(function (png) {
ScreenshotReporter(png, 'test/e2e/screenshots/login_to_app_' + browser.browserName);
});
var alertComponent = element(by.id('alertComponentClose'));
alertComponent.isPresent().then(function(result) {
if (result) {
element(by.id('alertComponentClose')).click();
browser.sleep(500);
}
});
element(by.id('login')).sendKeys('bblier');
browser.sleep(500);
element(by.id('password')).sendKeys('maarch');
browser.sleep(500);
element(by.id('submit')).click();
browser.sleep(100);
browser.takeScreenshot().then(function (png) {
ScreenshotReporter(png, 'test/e2e/screenshots/submitLogin_' + browser.browserName);
});
});
});
// it('should add a todo', function() {
// browser.waitForAngularEnabled(false);
// browser.get('http://127.0.0.1/maarch_trunk/apps/maarch_entreprise/index.php?display=true&page=login');
// element(by.id('login')).sendKeys('bbain');
// element(by.id('pass')).sendKeys('maarch');
// element(by.css('[name="submit"]')).click();
// // var todoList = element.all(by.repeater('todo in todoList.todos'));
// // expect(todoList.count()).toEqual(3);
// // expect(todoList.get(2).getText()).toEqual('write first protractor test');
// //
// // // You wrote your first test, cross it off the list
// // todoList.get(2).element(by.css('input')).click();
// // var completedAmount = element.all(by.css('.done-true'));
// // expect(completedAmount.count()).toEqual(2);
// });
// it('test 2', function() {
// var nbHeader = element.all(by.css('[class="bg-head-content"]'));
// expect(nbHeader.count()).toEqual(1);
// element(by.css('[routerLink="/about-us"]')).click();
// });
\ No newline at end of file
var fs = require('fs');
var ScreenshotReporter = function writeScreenShot(data, filename, mode = 'base64') {
if (mode === 'base64') {
var stream = fs.createWriteStream(filename+'.png');
stream.write(new Buffer.from(data, 'base64'));
stream.end();
} else if (mode === 'txt') {
var stream = fs.createWriteStream(filename+'.txt');
stream.write(data);
stream.end();
} else if (mode === 'console') {
console.log(data);
}
}
module.exports = ScreenshotReporter;
\ No newline at end of file
// ***********************************************
// 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", () => {
cy.visit('/')
cy.wait(1000)
cy.get('#alertComponentClose')
.click()
cy.get('#login')
.type('bblier')
cy.get('#password')
.type('maarch')
cy.get('#submit')
.click()
})
\ No newline at end of file
// ***********************************************************
// This example support/index.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')
{
"compilerOptions": {
"strict": true,
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress"]
},
"include": [
"**/*.ts"
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment