Commit fb5996e6 authored by Nacim Goura's avatar Nacim Goura

add test for search

parent 62b80078
{
"env": {
"meteor": true,
"node": true,
"browser": true,
"mocha": true,
"env": {
"meteor": true,
"node": true,
"browser": true,
"mocha": true,
"es6": true
},
"parser": "babel-eslint",
"parserOptions": {
"allowImportExportEverywhere": true,
},
"parser": "babel-eslint",
"parserOptions": {
"allowImportExportEverywhere": true,
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": false,
"experimentalObjectRestSpread": true
}
},
"plugins": [
"meteor",
"promise",
"lodash"
],
"extends": [
},
"plugins": [
"meteor",
"promise"
],
"extends": [
"@meteorjs/eslint-config-meteor",
"plugin:meteor/recommended",
"airbnb",
"plugin:lodash/recommended"
],
"settings": {
"import/resolver": "meteor"
},
"rules": {
"airbnb"
],
"settings": {
"import/resolver": "meteor"
},
"rules": {
"indent": ["error", 4, { "SwitchCase": 1 }],
"import/extensions": ["off", "never"],
"import/no-extraneous-dependencies": "off",
"import/no-extraneous-dependencies": "off",
"no-underscore-dangle": "off",
"class-methods-use-this": "off"
}
}
}
......@@ -60,7 +60,7 @@ export default class IndexGeneric {
query: term,
fuzziness: 'AUTO',
fields: [
'title.stemmed',
'description',
'description.stemmed',
'body',
'body.stemmed',
......@@ -76,7 +76,7 @@ export default class IndexGeneric {
fuzziness: 'AUTO',
fields: [
'title',
'description',
'title.stemmed',
'url',
'breadcrumb',
'h1',
......
......@@ -105,7 +105,7 @@ export default class IndexWebsite extends IndexGeneric {
index: {
_index: Meteor.settings.private.elasticsearch.esIndex,
_type: Meteor.settings.private.elasticsearch.esType,
_id: url,
_id: decodeURI(url),
},
});
......
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import _ from 'lodash';
import testSearchCollection from '../../collections/testSearchCollection';
Meteor.methods({
addTest(test) {
check(test, Object);
test.urlExpected = _.replace(test.urlExpected, 'https', 'http');
const results = Meteor.call('searchByTerm', test.term);
_.forEach(results.list, (result, index) => {
if (test.urlExpected === result.url) {
test.urlPosition = index + 1;
}
});
testSearchCollection.insert(test);
},
deleteTest(id) {
check(id, String);
testSearchCollection.remove({ _id: id });
},
});
import SimpleSchema from 'simpl-schema';
import { Mongo } from 'meteor/mongo';
/**
* this local collection keep tracks of all tabs of this application
* @type {Mongo.Collection}
*/
const testSearchCollection = new Mongo.Collection('testSearch');
SimpleSchema.testSearchCollection = new SimpleSchema({
term: {
type: String,
},
urlExpected: {
type: String,
},
urlPosition: {
type: Number,
required: false,
},
createdAt: {
type: Date,
defaultValue: new Date(),
},
});
testSearchCollection.attachSchema(SimpleSchema.testSearchCollection);
export default testSearchCollection;
......@@ -2,4 +2,6 @@
import '../../api/indexation/methods';
import '../../api/account/methods';
import '../../api/testSearch/methods';
import '../../tabular/tabularUser';
import '../../tabular/tabularTestSearch';
<template name="accountActionTable">
<button type="button" class="btn btn-xs btn-danger delete-account">Supprimer</button>
</template>
<template name="testSearchActionTable">
<button type="button" class="btn btn-xs btn-danger delete-test-search">Supprimer</button>
</template>
import dataTablesBootstrap from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import './buttonTabular.html';
import './tabularUser';
import './tabularTestSearch';
dataTablesBootstrap(window, $);
import Tabular from 'meteor/aldeed:tabular';
import { Meteor } from 'meteor/meteor';
import testSearchCollection from '../collections/testSearchCollection';
new Tabular.Table({
name: 'testSearch',
collection: testSearchCollection,
columns: [
{
data: 'term', title: 'Terme',
},
{
data: 'urlExpected', title: 'url Attendu',
},
{
data: 'urlPosition', title: 'Position',
},
{
data: 'createdAt', title: 'Date',
},
{
tmpl: Meteor.isClient && Template.testSearchActionTable,
},
],
pageLength: 20,
language: {
sProcessing: 'Traitement en cours...',
sSearch: 'Rechercher&nbsp;:',
sLengthMenu: 'Afficher _MENU_ &eacute;l&eacute;ments',
sInfo: "Affichage de l'&eacute;l&eacute;ment _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
sInfoEmpty: "Affichage de l'&eacute;l&eacute;ment 0 &agrave; 0 sur 0 &eacute;l&eacute;ment",
sInfoFiltered: '(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)',
sInfoPostFix: '',
sLoadingRecords: 'Chargement en cours...',
sZeroRecords: 'Aucun &eacute;l&eacute;ment &agrave; afficher',
sEmptyTable: 'Aucune donn&eacute;e disponible dans le tableau',
oPaginate: {
sFirst: 'Premier',
sPrevious: 'Pr&eacute;c&eacute;dent',
sNext: 'Suivant',
sLast: 'Dernier',
},
oAria: {
sSortAscending: ': activer pour trier la colonne par ordre croissant',
sSortDescending: ': activer pour trier la colonne par ordre d&eacute;croissant',
},
},
});
<template name="testSearchTpl">
<!-- testSearchTpl -->
Tester le système de recherche :
<form class="form-inline" role="form" method="post">
<input class="form-control" name="termTestSearch" type="text" placeholder="terme">
<input class="form-control" name="urlTestSearch" type="url" placeholder="Url attendu">
<input class="btn btn-success" type="submit" value="Tester">
</form>
<div class="panel panel-default wrapper">
<div class="panel-heading text-center">
Résultat des tests
</div>
<div class="panel-body">
{{> tabular table=TabularTables.testSearch class="table table-striped table-bordered table-condensed text-center"}}
</div>
</div>
</template>
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import './testSearch.html';
import '../../../tabular/configClient';
Template.testSearchTpl.events({
'submit form': (event) => {
event.preventDefault();
const test = {
term: event.target.termTestSearch.value,
urlExpected: event.target.urlTestSearch.value,
};
Meteor.callPromise('addTest', test)
.then((results) => {
console.log(results);
}).catch((error) => {
console.log(error);
});
},
});
Template.testSearchActionTable.events({
'click .delete-test-search': function () {
Meteor.callPromise('deleteTest', this._id)
.then((results) => {
console.log(results);
}).catch((error) => {
console.log(error);
});
},
});
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import dataTablesBootstrap from 'datatables.net-bs';
import 'datatables.net-bs/css/dataTables.bootstrap.css';
import displayNotif from '../../../../components/notifs/notifs';
import '../../../../../tabular/buttonTabular.html';
import '../../../../../tabular/tabularUser';
import displayNotif from '../../../../components/notifs/notifs';
import '../../../../../tabular/configClient';
import './list.html';
dataTablesBootstrap(window, $);
Template.accountActionTable.events({
'click .delete-account': function () {
Meteor.callPromise('deleteAccount', this._id)
......
......@@ -4,4 +4,6 @@
{{> searchTpl ""}}
{{> testSearchTpl ""}}
</template>
import '../../components/search/search';
import '../../components/testSearch/testSearch';
import './home.html';
{
"name": "meteorSearch",
"author": "Nacim",
"private": true,
"scripts": {
"start": "meteor --settings settings.json",
"test": "meteor test --driver-package practicalmeteor:mocha --port 3001",
"eslint": "eslint .; exit 0"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"bcrypt": "^1.0.2",
"bootstrap-sass": "^3.3.7",
"crawler": "^1.0.5",
"datatables.net-bs": "^1.10.15",
"elasticsearch": "^13.1.0",
"izitoast": "^1.1.1",
"jquery": "^1.11.2",
"lodash": "^4.17.4",
"meteor-node-stubs": "~0.2.11",
"sanitize-html": "^1.14.1",
"simpl-schema": "^0.3.0",
"sitemapper": "^2.1.13",
"slug": "^0.9.1",
"sweetalert2": "^6.6.5"
},
"devDependencies": {
"@meteorjs/eslint-config-meteor": "^1.0.5",
"babel-eslint": "^7.2.3",
"eslint": "^4.0.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-import-resolver-meteor": "^0.4.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-lodash": "^2.4.2",
"eslint-plugin-meteor": "^4.0.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.0.1"
}
"name": "meteorSearch",
"author": "Nacim",
"private": true,
"scripts": {
"start": "meteor --settings settings.json",
"test": "meteor test --driver-package practicalmeteor:mocha --port 3001",
"eslint": "eslint .; exit 0"
},
"dependencies": {
"babel-runtime": "^6.23.0",
"bcrypt": "^1.0.2",
"bootstrap-sass": "^3.3.7",
"crawler": "^1.0.5",
"datatables.net-bs": "^1.10.15",
"elasticsearch": "^13.1.0",
"izitoast": "^1.1.1",
"jquery": "^1.11.2",
"lodash": "^4.17.4",
"meteor-node-stubs": "~0.2.11",
"sanitize-html": "^1.14.1",
"simpl-schema": "^0.3.0",
"sitemapper": "^2.1.13",
"slug": "^0.9.1",
"sweetalert2": "^6.6.5"
},
"devDependencies": {
"@meteorjs/eslint-config-meteor": "^1.0.5",
"babel-eslint": "^7.2.3",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-import-resolver-meteor": "^0.4.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-meteor": "^4.0.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.0.1"
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment