Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions assets/js/src/softwareForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,21 @@ function resetFieldsAdmin() {
$('#enteam').val('');
$('#frteam').val('');
}

window.softwareForm_func = {
getsoftwareObject,
// softwareObject,
getSelectedOrgType,
submitSoftwareFormNewAdmin,
getConfigUpdateSoftwareNewAdmin,
getConfigNewSoftwareNewAdmin,
submitFormSoftware,
getConfigUpdate,
getConfigNew,
selectSoftware,
addValueToFieldsSoftware,
resetFieldsSoftware,
selectAdmin,
addValueToFieldsAdmin,
resetFieldsAdmin,
};
5 changes: 5 additions & 0 deletions assets/js/src/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ function submitInit() {
}
return valid;
}

//Allows use of the function for testing so there isn't any real submission happening
window.submit_init = {
submitInit,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
context('Common parts', () => {
const selectTags = [
'#dt_govLevel',
'#dt_category',
'#dt_licence',
'#dt_tag'
];
// eslint-disable-next-line no-undef
beforeEach(() => {
cy.visit('http://localhost:4000/ore-ero/fr/logiciels-libres.html');
});

it('should reset inputs', function() {
//select first element of the select
//should test if it's null
selectTags.forEach(selectTag => {
cy.get(`${selectTag} > option`)
.eq(1)
.then(element => {
cy.get(selectTag).select(element.val());
});
});

cy.get('.wb-tables-filter > .row > :nth-child(2) > .btn').click();

selectTags.forEach(selectTag => {
cy.get(`${selectTag} > option`)
.eq(0)
.should('be.selected');
});
});

it('should filter the first element with the right values', () => {
cy.get('.sorting_1')
.first()
.then(projectName => {
cy.get('tbody > :nth-child(1) > :nth-child(2)').then(category => {
cy.get(`#dt_category`).select(category.text().trim());
});
cy.get('tbody > :nth-child(1) > :nth-child(4)').then(licence => {
cy.get(`#dt_licence`).select(licence.text().trim());
});
cy.get('.wb-tables-filter > .row > :nth-child(1) > .btn').click();
cy.get(':nth-child(1) > .sorting_1').contains(projectName.text().trim());
});
});

it('should open the correct modal', () => {
//25, 25 should hit the link no matter the size of the box
cy.get(':nth-child(1) > .sorting_1').click(25, 25);
cy.get(':nth-child(1) > .sorting_1').then(name => {
cy.get('.wb-overlay.open').contains(name.text().trim());
});

// click on the close button
cy.get('.wb-overlay.open .btn').click();
cy.get('.wb-overlay').should('not.be.visible');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/// <reference types="Cypress" />
/* global cy, context, it, before, expect */

context('date_func.js on English Form page', () => {
const now = new Date();
const output = (now.getFullYear() +
'-' +
((now.getMonth() + 1) < 10 ? '0' : '') +
(now.getMonth() + 1) +
'-' +
((now.getDate()) < 10 ? '0' : '') +
(now.getDate())
);

before(() => {
cy.visit('http://localhost:4000/ore-ero/en/open-source-software-form.html');
});

it('Loads the script', () => {
cy.window().should('have.property', 'Date');
});

it('It should call and return Date.now()', () => {
cy.window().then(win => {
let value = win.date_func.getToday();
expect(value).to.equal(output);
});
});

it('It should not equal to day time', () => {
cy.window().then(win => {
const outputDate = new Date(Date.now());
expect(win.date_func.getToday()).not.equal(outputDate);
});
});
});

context('date_func.js on French Form page', () => {
const now = new Date();
const output = (now.getFullYear() +
'-' +
((now.getMonth() + 1) < 10 ? '0' : '') +
(now.getMonth() + 1) +
'-' +
((now.getDate()) < 10 ? '0' : '') +
(now.getDate())
);

before(() => {
cy.visit('http://localhost:4000/ore-ero/fr/logiciel-libre-formulaire.html');
});

it('Loads the script', () => {
cy.window().should('have.property', 'Date');
});

it('It should call and return Date.now()', () => {
cy.window().then(win => {
let value = win.date_func.getToday();
expect(value).to.equal(output);
});
});

it('It should not equal to day time', () => {
cy.window().then(win => {
const outputDate = new Date(Date.now());
expect(win.date_func.getToday()).not.equal(outputDate);
});
});
});
15 changes: 15 additions & 0 deletions cypress/integration/unit-tests/open-software/software-form.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="Cypress" />
/* global cy, context, it, date_func */

context('softwareForm.js', () => {
let softwareObject = [];

before(() => {
cy.visit('http://localhost:4000/ore-ero/en/open-source-software-form.html');
});

it('Loads the script', () => {
cy.window().should('have.property', 'getsoftwareObject');
});

});
Loading