Skip to content

Commit

Permalink
Merge pull request #40 from EmmanuelDemey/master
Browse files Browse the repository at this point in the history
PR Zenika
  • Loading branch information
NicoLaval authored May 6, 2019
2 parents 39c5bee + 03c6634 commit fb98aa6
Show file tree
Hide file tree
Showing 35 changed files with 932 additions and 232 deletions.
38 changes: 38 additions & 0 deletions cypress/fixtures/sims.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,44 @@
"rangeType": "DATE",
"idAttribute": "S.2.2",
"value": "2019-01-01T11:00:00.000Z"
},
{
"rangeType": "RICH_TEXT",
"idAttribute": "S.3.1",
"documents": [
{
"uri": "uri1-bis",
"url": "http://google.fr?q=url-1",
"updatedDate": "01/01/2019",
"labelLg1": "labelLg1-0",
"labelLg2": "labelLg2-0",
"lang": "fr",
"descriptionLg1": "descriptionLg1",
"descriptionLg2": "descriptionLg2"
},
{
"uri": "uri2-bis",
"url": "http://google.fr?q=url-2",
"updatedDate": "01/02/2019",
"labelLg1": "labelLg1-1",
"labelLg2": "labelLg2-1",
"descriptionLg1": "descriptionLg1-2",
"descriptionLg2": "descriptionLg2-2"
},
{
"uri": "uri3-bis",
"url": "http://google.fr?q=url-2",
"labelLg1": "labelLg1-2",
"labelLg2": "labelLg2-2",
"lang": "fr",
"descriptionLg1": "descriptionLg1-2",
"descriptionLg2": "descriptionLg2-2"
}
]
},
{
"rangeType": "RICH_TEXT",
"idAttribute": "S.3.2"
}
],
"labelLg2": "Annual production survey 2012 SIMS",
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/family.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Family page', () => {
familiesPage.go();
familiesPage.getFamiliesList().should('have.length', 10);
familiesPage.getPaginationBlock().should('have.length', 7);
familiesPage.search('ZENIKA');
familiesPage.search('FAKE DATA');
familiesPage.getFamiliesList().should('have.length', 0);
familiesPage.resetSearch();
familiesPage.getFamiliesList().should('have.length', 10);
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/operations_list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
cy.get('.list-group').should('be.visible');
cy.get('.pagination').should('be.visible');

cy.get('input').type('Zenika');
cy.get('input').type('FAKE DATA');
cy.get('h4').should(h4 => {
expect(h4.first()).to.contain('0');
});
Expand Down
6 changes: 5 additions & 1 deletion cypress/integration/po/sims.po.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ export class SimsViewPage {
getUpdateButton() {
return 'div:nth-child(4) > a';
}

getDocumentsBlocForRubric(rubricId) {
return cy.get(rubricId);
}
}

export class SimsEditPage {
getTitle() {
return '.page-title-operations';
}

p;
getCancelButton() {
return '.btn-line div:first > button';
}
Expand Down
65 changes: 0 additions & 65 deletions cypress/integration/serie.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,69 +138,4 @@ describe('Series page', () => {
cy.get('.row:first-of-type > div.form-group').should('have.length', 2);
cy.get('label span.boldRed').should('have.length', 2);
});

it('should handle multi Select component', () => {
cy.server()
.fixture('series')
.then(json => {
cy.route(Cypress.env('API') + 'operations/series/s1161', json);
})

.visit('/operations/series', {
onBeforeLoad(win) {
delete win.fetch;
win.eval(polyfill);
win.fetch = win.unfetch;
},
});

cy.get('.list-group a')
.first()
.click();

cy.url().should('include', '/operations/series/');

cy.get('.btn-line a')
.first()
.click();

cy.url().should('include', '/modify');

cy.get('.Select--multi')
.eq(1)
.as('firstMultiSelect')
.get('@firstMultiSelect')
.find('.Select-multi-value-wrapper')
.children('.Select-value')
.then(children => {
cy.get('@firstMultiSelect')
.find('.Select-value')
.should('have.length', children.length);

cy.get('@firstMultiSelect').click();
cy.get('@firstMultiSelect').click();

cy.get('@firstMultiSelect')
.get('.Select-option')
.first()
.should('be.visible');

cy.get('@firstMultiSelect')
.get('.Select-option')
.first()
.click();

cy.get('@firstMultiSelect')
.find('.Select-value')
.should('have.length', children.length + 1);

cy.get('@firstMultiSelect')
.find('.Select-value-icon')
.first()
.click();
cy.get('@firstMultiSelect')
.find('.Select-value')
.should('have.length', children.length);
});
});
});
1 change: 1 addition & 0 deletions cypress/integration/sims.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('SIMS Page', function() {
// Visu Page
cy.url().should('contains', '/sims/1512');
cy.get(simsViewPage.getTitle()).should('exist');

cy.get(simsViewPage.getUpdateButton()).click();

// Update page
Expand Down
13 changes: 13 additions & 0 deletions docs/en/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ If you're new to JavaScript, you might need to first install [node](https://node
`yarn start` will launch the `dev` command defined in the `scripts` section of the same `package.json` file. This command will launch a local web server serving the main HTML file ([src/js/index.html](https://github.com/InseeFr/Bauhaus/blob/master/public/index.html)) and all the relevant assets.

`yarn build` will launch the compilation with some optimizations for production. It copies all the static assets and the resulting bundle file in the `dist` folder.

## Project Structure

In this paragraph, we will try to explain the rules we defined and try to follow when talking about the structure of the project.

### SCSS Mixin

If you have to define SCSS mixin, you have to define them in the `src/styles/mixin.scss` file, and import them in the stylesheet of the React component.

### I18N

In order to avoid big i18n file, we try to split this file in smaller files, based on `page` or `feature`. For example, we have a `src/js/i18n/dictionary/operations/documents.js` file for all messages dedicated to the documents feature.
This files have to be imported directly or not in the main file `js/i18n/dictionary/app.js`.
13 changes: 13 additions & 0 deletions docs/fr/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,16 @@ Si vous débutez avec ces technologies, vous aurez vraisemblablement besoin d'in
`yarn start` démarre un serveur de développement qui sert la page d'accueil de l'application ([src/js/index.html](https://github.com/InseeFr/Bauhaus/blob/master/public/index.html)) et toutes les ressources nécessaires.

`yarn build` lance la compilation du code avec des optimisations pour la mise en production. Elle copie toutes les ressources statiques et le fichier `JavaScript` compilé dans le dossier `dist`.

## Structure du projet

Dans ce paragraphe, nous allons définir les quelques règles que nous essayons de suivre concernant la structure du projet.

### Mixin SCSS

Si vous devez définir des mixins SCSS, vous devez les implémenter dans le fichier `src/styles/mixin.scss` et ensuite importer ce fichier lorsque vous souhaitez l'utiliser.

### I18N

Dans le but d'éviter d'avoir un fichier d'i18n trop gros, nous avons commencer à découper ce fichier par `page` ou `fontionnalité`. Il y a par exemple un fichier `src/js/i18n/dictionary/operations/documents.js` pour tous les messages utilisés dans la fonctionnalité de gestions des documents.
Ces fichiers doivent ensuite être importés directement ou indirectement dans le fichier principal `js/i18n/dictionary/app.js`
7 changes: 5 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"compilerOptions": {
"baseUrl": "./src"
}
"baseUrl": "./src",
"checkJs": true,
"jsx": "preserve"
},
"exclude": ["cypress/**/*.js"]
}
30 changes: 27 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"dependencies": {
"babel-polyfill": "6.26.0",
"bootstrap": "3.3.7",
"bootstrap": "3.4.1",
"dompurify": "0.8.7",
"draft-js": "0.10.4",
"draft-js-export-html": "1.2.0",
Expand Down Expand Up @@ -79,6 +79,8 @@
"@storybook/addon-links": "4.1.12",
"@storybook/addons": "4.1.12",
"@storybook/react": "4.1.12",
"@types/cypress": "^1.1.3",
"@types/jest": "^24.0.12",
"babel-loader": "8.0.5",
"concurrently": "3.5.1",
"coveralls": "3.0.0",
Expand Down
14 changes: 2 additions & 12 deletions src/app.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'src/styles/mixin.scss';

// Define concepts colors
$color_concepts_1: #044173;
$color_concepts_2: #234ca5;
Expand Down Expand Up @@ -55,18 +57,6 @@ a {
margin: 0;
}

@mixin btn-group-vertical() {
border-radius: 6px;
border-width: 2px;
border-style: solid;
margin-top: 200px;

.btn {
margin-top: 15px;
margin-bottom: 15px;
}
}

.btn-group-vertical {
border-color: $color_concepts_3;
@include btn-group-vertical();
Expand Down
1 change: 1 addition & 0 deletions src/js/actions/constants/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './operations/series';
export * from './operations/codeList';
export * from './operations/organisations';
export * from './operations/sims';
export * from './operations/documents';
5 changes: 5 additions & 0 deletions src/js/actions/constants/operations/documents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const LOAD_OPERATIONS_DOCUMENTS = 'LOAD_OPERATIONS_DOCUMENTS';
export const LOAD_OPERATIONS_DOCUMENTS_SUCCESS =
'LOAD_OPERATIONS_DOCUMENTS_SUCCESS';
export const LOAD_OPERATIONS_DOCUMENTS_FAILURE =
'LOAD_OPERATIONS_DOCUMENTS_FAILURE';
79 changes: 79 additions & 0 deletions src/js/actions/operations/documents/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import api from 'js/remote-api/operations-api';
import * as A from 'js/actions/constants';
import { sortArray } from 'js/utils/array-utils';

const sortByLabel = sortArray('label');

export default () => dispatch => {
dispatch({
type: A.LOAD_OPERATIONS_DOCUMENTS,
payload: {},
});
return api.getDocumentsList().then(
results =>
dispatch({
type: A.LOAD_OPERATIONS_DOCUMENTS_SUCCESS,
payload: { results: sortByLabel(results) },
}),
err => {
const results = [
{
uri: 'uri1-bis',
url: 'http://google.fr?q=url-1',
updatedDate: '01/01/2019',
lang: 'fr',
labelLg1: 'Document 1 - label en Langue 1',
labelLg2: 'Document 1 - label en Langue 2',
descriptionLg1: 'Description 1 en Langue 1',
descriptionLg2: 'Description 1 en Langue 2',
},
{
uri: 'uri2-bis',
url: 'http://google.fr?q=url-2',
updatedDate: '01/02/2019',
labelLg1: 'Document 2 - label en Langue 1',
labelLg2: 'Document 2 - label en Langue 2',
descriptionLg1: 'Description 2 en Langue 1',
descriptionLg2: 'Description 2 en Langue 2',
},
{
uri: 'uri3-bis',
url: 'http://google.fr?q=url-2',
labelLg1: 'Document 3 - label en Langue 1',
labelLg2: 'Document 3 - label en Langue 2',
descriptionLg1: 'Description 3 en Langue 1',
descriptionLg2: 'Description 3 en Langue 2',
lang: 'fr',
},

{
uri: 'uri5-bis',
url: 'http://google.fr?q=url-2',
labelLg1: 'Document 5 - label en Langue 1',
labelLg2: 'Document 5 - label en Langue 2',
descriptionLg1: 'Description 5 en Langue 1',
descriptionLg2: 'Description 5 en Langue 2',
lang: 'fr',
},
{
uri: 'uri4-bis',
url: 'http://google.fr?q=url-2',
updatedDate: '01/02/2019',
labelLg1: 'Document 4 - label en Langue 1',
labelLg2: 'Document 4 - label en Langue 2',
descriptionLg1: 'Description 4 en Langue 1',
descriptionLg2: 'Description 4 en Langue 2',
},
];
dispatch({
type: A.LOAD_OPERATIONS_DOCUMENTS_SUCCESS,
payload: { results: sortByLabel(results) },
});

/*dispatch({
type: A.LOAD_OPERATIONS_DOCUMENTS_FAILURE,
payload: { err },
})*/
}
);
};
5 changes: 4 additions & 1 deletion src/js/actions/operations/families/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export const saveFamily = (family, callback) => dispatch => {
results => {
dispatch({
type: A.SAVE_OPERATIONS_FAMILY_SUCCESS,
payload: family,
payload: {
...family,
id: family.id ? family.id : results
},
});
callback(results);
},
Expand Down
Loading

0 comments on commit fb98aa6

Please sign in to comment.