Commit fb5996e6 authored by Nacim Goura's avatar Nacim Goura

add test for search

parent 62b80078
......@@ -17,14 +17,12 @@
},
"plugins": [
"meteor",
"promise",
"lodash"
"promise"
],
"extends": [
"@meteorjs/eslint-config-meteor",
"plugin:meteor/recommended",
"airbnb",
"plugin:lodash/recommended"
"airbnb"
],
"settings": {
"import/resolver": "meteor"
......
......@@ -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';
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