Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web-et-numerique/factory/pamn_plateforme-des-acteurs-de-la-mediation-numerique/pamn_server
1 result
Show changes
import { ElasticsearchService } from '@nestjs/elasticsearch';
import { Test, TestingModule } from '@nestjs/testing';
import { multipleUsers } from '../../../test/mock/data/users.mock.data';
import { ConfigurationModule } from '../../configuration/configuration.module';
......@@ -56,9 +57,11 @@ describe('UserRegistrySearchService Search cases', () => {
expect(res).toBeTruthy();
});
it('should delete index', async () => {
const mockDelete = jest.fn();
jest.spyOn(ElasticsearchService.prototype, 'delete').mockImplementation(mockDelete);
const resAdm = await service.search('adm');
const res = await service.deleteIndex(resAdm[0] as IUserRegistry);
expect(res).toBeTruthy();
await service.deleteIndex(resAdm[0] as IUserRegistry);
expect(mockDelete).toBeCalled();
});
});
});
......@@ -696,7 +696,7 @@ export class UsersService {
return (await this.getPendingStructures()) as PendingStructureDto[];
} else {
throw new HttpException(
'Cannot validate strucutre. It might have been already validate, or the structure doesn`t belong to the user',
'Cannot validate structure. It might have been already validate, or the structure doesn`t belong to the user',
HttpStatus.NOT_FOUND
);
}
......
export const PhotonResponseMock = {
data: {
features: [
{
geometry: {
coordinates: [4.735948029916814, 45.6963425],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 1668408,
osm_type: 'R',
extent: [4.3480714, 45.9393015, 5.1603205, 45.454026],
country: 'France',
osm_key: 'boundary',
osm_value: 'historic',
name: 'Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.735948029916814, 45.6963425],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 1663048,
osm_type: 'R',
extent: [4.3480714, 45.9393015, 5.1603205, 45.454026],
country: 'France',
osm_key: 'boundary',
osm_value: 'administrative',
name: 'Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.8320114, 45.7578137],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 120965,
osm_type: 'R',
extent: [4.7718134, 45.8082628, 4.8983774, 45.7073666],
country: 'France',
osm_key: 'place',
osm_value: 'city',
name: 'Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.8556858678641275, 45.7481616],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 4850450,
osm_type: 'R',
extent: [4.6917432, 45.9393015, 5.0619567, 45.5570954],
country: 'France',
osm_key: 'boundary',
osm_value: 'administrative',
name: 'Métropole de Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.326281018170559, 45.88027045],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 14059344,
osm_type: 'R',
extent: [3.6910581, 46.3064984, 5.1603205, 45.454026],
country: 'France',
osm_key: 'boundary',
osm_value: 'religious_administration',
name: 'Archidiocèse de Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.818241285814878, 45.8853321],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 224889906,
osm_type: 'W',
extent: [4.8177401, 45.8856094, 4.8188082, 45.8851333],
country: 'France',
osm_key: 'waterway',
city: 'Neuville-sur-Saône',
osm_value: 'boatyard',
postcode: '69250',
name: 'Lyon Nautic',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.7934767, 45.7362255],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 192369,
osm_type: 'R',
extent: [4.7716828, 45.7517608, 4.8134004, 45.7208035],
country: 'France',
osm_key: 'place',
osm_value: 'town',
postcode: '69110',
name: 'Sainte-Foy-lès-Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.3889953, 45.6375531],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 115172,
osm_type: 'R',
extent: [4.3329967, 45.6537234, 4.4105724, 45.6049949],
country: 'France',
osm_key: 'place',
osm_value: 'village',
postcode: '42140',
name: 'Chazelles-sur-Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.8268635, 45.7624951],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 5545047358,
osm_type: 'N',
country: 'France',
osm_key: 'place',
city: 'Lyon',
osm_value: 'suburb',
postcode: '69005',
name: 'Vieux Lyon',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.802166806624854, 45.7835048],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 120966,
osm_type: 'R',
extent: [4.783995, 45.8082628, 4.841247, 45.7586963],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69009',
name: 'Lyon 9e Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.869380334747735, 45.73407075],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 10686,
osm_type: 'R',
extent: [4.8476322, 45.7494375, 4.8921378, 45.718789],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69008',
name: 'Lyon 8e Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.850114065670057, 45.77642535],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 10679,
osm_type: 'R',
extent: [4.8394484, 45.7871481, 4.8699434, 45.7635554],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69006',
name: 'Lyon 6e Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.803639641660604, 45.75553155],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 10688,
osm_type: 'R',
extent: [4.7718134, 45.7679856, 4.8304943, 45.7442456],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69005',
name: 'Lyon 5e Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.825521507543241, 45.78035385],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 18510,
osm_type: 'R',
extent: [4.809026, 45.7897261, 4.8430325, 45.7711184],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69004',
name: 'Lyon 4e Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
{
geometry: {
coordinates: [4.826674363904056, 45.76940595],
type: 'Point',
},
type: 'Feature',
properties: {
osm_id: 10690,
osm_type: 'R',
extent: [4.8130698, 45.7747842, 4.8397727, 45.7645442],
country: 'France',
osm_key: 'boundary',
city: 'Lyon',
osm_value: 'administrative',
postcode: '69001',
name: 'Lyon 1er Arrondissement',
state: 'Auvergne-Rhône-Alpes',
},
},
],
type: 'FeatureCollection',
},
};
import { StructureDto } from '../../../src/structures/dto/structure.dto';
export const structureDtoMock: StructureDto = {
accountVerified: false,
address: { commune: '', inseeCode: '', numero: '', postcode: '69000', street: '' },
createdAt: new Date(),
updatedAt: new Date(),
deletedAt: new Date(),
structureName: '',
structureType: '',
description: '',
website: '',
facebook: '',
twitter: '',
instagram: '',
linkedin: '',
lockdownActivity: '',
otherDescription: '',
pmrAccess: false,
remoteAccompaniment: false,
categories: '',
freeWorkShop: '',
nbComputers: 0,
nbPrinters: 0,
nbScanners: 0,
exceptionalClosures: '',
hours: {
monday: { open: false, time: [] },
tuesday: { open: false, time: [] },
wednesday: { open: false, time: [] },
thursday: { open: false, time: [] },
friday: { open: false, time: [] },
saturday: { open: false, time: [] },
sunday: { open: false, time: [] },
},
coord: [],
dataShareConsentDate: new Date(),
personalOffers: [],
};
import { StructureDto } from '../../../src/structures/dto/structure.dto';
import { StructureDocument } from '../../../src/structures/schemas/structure.schema';
import { Structure, StructureDocument } from '../../../src/structures/schemas/structure.schema';
export const structuresDocumentDataMock: StructureDocument[] = [
{
......@@ -236,3 +236,330 @@ export const structureMockDto: StructureDto = {
remoteAccompaniment: true,
dataShareConsentDate: new Date(),
};
export const mockStructureDocument = ({
coord: [4.8498155, 45.7514817],
categories: {
accessModality: ['accesLibre'],
labelsQualifications: [
'monEspaceSante',
'numRelay',
'pix',
'passNumerique',
'fabriqueDeTerritoire',
'aidantsConnect',
'espacePublicNumeriqueepn',
'maisonFranceService',
'conseillerNumFranceServices',
],
onlineProcedures: [
'idDoc',
'training',
'health',
'work',
'caf',
'cpam',
'foreigners',
'needs',
'franceConnect',
'taxes',
'housing',
'retirement',
'scolarity',
'transport',
'autres',
],
selfServiceMaterial: ['wifiEnAccesLibre', 'computer', 'printer', 'scanner'],
solidarityMaterial: [],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young', 'family'],
languageAndIlliteracy: ['illettrisme', 'english'],
handicaps: ['physicalDisability'],
genre: ['uniquementFemmes'],
},
structureType: null,
structureName: 'a',
description: null,
lockdownActivity: null,
address: {
numero: null,
street: 'Rue Alphonse Daudet',
commune: 'Lyon 7ème Arrondissement',
postcode: '69007',
inseeCode: '69387',
},
contactMail: '',
contactPhone: '',
website: '',
facebook: null,
twitter: null,
instagram: null,
linkedin: null,
hours: {
monday: {
open: false,
time: [],
},
tuesday: {
open: false,
time: [],
},
wednesday: {
open: false,
time: [],
},
thursday: {
open: false,
time: [],
},
friday: {
open: false,
time: [],
},
saturday: {
open: false,
time: [],
},
sunday: {
open: false,
time: [],
},
},
pmrAccess: false,
exceptionalClosures: null,
otherDescription: null,
nbComputers: 1,
nbPrinters: 1,
nbScanners: 1,
freeWorkShop: 'Non',
accountVerified: true,
createdAt: new Date('2021-05-06T09:42:38.000Z'),
updatedAt: new Date('2021-05-06T09:42:38.000Z'),
numero: null,
remoteAccompaniment: null,
deletedAt: null,
dataShareConsentDate: null,
personalOffers: null,
} as unknown) as StructureDocument;
export const mockStructure: Structure = {
coord: [4.8498155, 45.7514817],
numero: '',
createdAt: null,
// _id: '',
// publicsAccompaniment: null,
// autresAccompagnements: null,
// __v: '',
dataShareConsentDate: null,
deletedAt: null,
personalOffers: [],
remoteAccompaniment: null,
updatedAt: null,
categories: {
accessModality: ['accesLibre'],
labelsQualifications: [
'monEspaceSante',
'numRelay',
'pix',
'passNumerique',
'fabriqueDeTerritoire',
'aidantsConnect',
'espacePublicNumeriqueepn',
'maisonFranceService',
'conseillerNumFranceServices',
],
onlineProcedures: [
'idDoc',
'training',
'health',
'work',
'caf',
'cpam',
'foreigners',
'needs',
'franceConnect',
'taxes',
'housing',
'retirement',
'scolarity',
'transport',
'autres',
],
selfServiceMaterial: ['wifiEnAccesLibre', 'computer', 'printer', 'scanner'],
solidarityMaterial: [],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young', 'family'],
languageAndIlliteracy: ['illettrisme', 'english'],
handicaps: ['physicalDisability'],
genre: ['uniquementFemmes'],
},
structureType: null,
structureName: 'a',
description: null,
lockdownActivity: null,
address: {
numero: null,
street: 'Rue Alphonse Daudet',
commune: 'Lyon 7ème Arrondissement',
postcode: '69007',
inseeCode: '69387',
},
contactMail: '',
contactPhone: '',
website: '',
facebook: null,
twitter: null,
instagram: null,
linkedin: null,
hours: {
monday: {
open: false,
time: [],
},
tuesday: {
open: false,
time: [],
},
wednesday: {
open: false,
time: [],
},
thursday: {
open: false,
time: [],
},
friday: {
open: false,
time: [],
},
saturday: {
open: false,
time: [],
},
sunday: {
open: false,
time: [],
},
},
pmrAccess: false,
exceptionalClosures: null,
otherDescription: null,
nbComputers: 1,
nbPrinters: 1,
nbScanners: 1,
freeWorkShop: 'Non',
accountVerified: true,
categoriesWithPersonalOffers: {},
};
export const mockDeletedStructure: Structure = {
structureType: null,
categoriesWithPersonalOffers: {},
dataShareConsentDate: new Date(2023, 1, 1),
remoteAccompaniment: true,
numero: '',
hours: {
monday: {
open: false,
time: [],
},
tuesday: {
open: false,
time: [],
},
wednesday: {
open: false,
time: [],
},
thursday: {
open: false,
time: [],
},
friday: {
open: false,
time: [],
},
saturday: {
open: false,
time: [],
},
sunday: {
open: false,
time: [],
},
},
categories: {
accessModality: ['accesLibre'],
labelsQualifications: [
'monEspaceSante',
'numRelay',
'pix',
'passNumerique',
'fabriqueDeTerritoire',
'aidantsConnect',
'espacePublicNumeriqueepn',
'maisonFranceService',
'conseillerNumFranceServices',
],
onlineProcedures: [
'idDoc',
'training',
'health',
'work',
'caf',
'cpam',
'foreigners',
'needs',
'franceConnect',
'taxes',
'housing',
'retirement',
'scolarity',
'transport',
'autres',
],
selfServiceMaterial: ['wifiEnAccesLibre', 'computer', 'printer', 'scanner'],
solidarityMaterial: [],
baseSkills: ['computer', 'internet'],
advancedSkills: [],
age: ['young', 'family'],
languageAndIlliteracy: ['illettrisme', 'english'],
handicaps: ['physicalDisability'],
genre: ['uniquementFemmes'],
},
freeWorkShop: 'Non',
structureName: "L'Atelier Numérique",
description:
"L'Atelier Numérique est l'Espace Public Numérique des Centres Sociaux de Rillieux-la-Pape, ayant pour mission la médiation numérique pour toutes et tous.",
lockdownActivity:
'accesLibres, permanences numériques téléphoniques, cours et ateliers à distance, formations professionnelles.',
contactPhone: '',
contactMail: '',
website: '',
facebook: null,
twitter: null,
instagram: null,
pmrAccess: true,
exceptionalClosures: '',
nbComputers: 16,
nbPrinters: 1,
address: {
numero: '30 bis',
street: 'Avenue Leclerc',
commune: 'Rillieux-la-Pape',
postcode: '69140',
inseeCode: '69286',
},
coord: [4.9036773, 45.8142196],
accountVerified: true,
linkedin: null,
nbScanners: 1,
otherDescription: null,
personalOffers: [],
createdAt: new Date('2020-11-16T09:30:00.000Z'),
updatedAt: new Date('2020-11-16T09:30:00.000Z'),
deletedAt: new Date('2020-11-16T09:30:00.000Z'),
};
......@@ -46,7 +46,7 @@ export class NewsletterServiceMock {
newsletterUnsubscribe(email: string) {
if (email === 'test@test.com') {
throw new HttpException('Invalid email', HttpStatus.BAD_REQUEST);
throw new HttpException('Invalid email', HttpStatus.BAD_REQUEST);
}
return {
_id: '607063e22b016303ad97f397',
......
......@@ -2,8 +2,8 @@ import { HttpException, HttpStatus } from '@nestjs/common';
import { Types } from 'mongoose';
import { PersonalOfferDocument } from '../../../src/personal-offers/schemas/personal-offer.schema';
import { CNFSStructure } from '../../../src/structures/interfaces/cnfs-structure.interface';
import { Structure, StructureDocument } from '../../../src/structures/schemas/structure.schema';
import { PhotonPoints } from '../../../src/structures/interfaces/photon-response.interface';
import { Structure, StructureDocument } from '../../../src/structures/schemas/structure.schema';
export class StructuresServiceMock {
findOne(id: Types.ObjectId) {
......@@ -1346,6 +1346,17 @@ export class StructuresServiceMock {
return {};
}
async create() {
return;
}
async updateAccountVerified() {
return;
}
async updateAllDenormalizedFields() {
return;
}
async updateDenormalizedFields() {
return;
}
......
import { HttpException, HttpStatus } from '@nestjs/common';
import { isValidObjectId, Types } from 'mongoose';
import { Types, isValidObjectId } from 'mongoose';
import { PendingStructureDto } from '../../../src/admin/dto/pending-structure.dto';
import { LoginDto } from '../../../src/auth/login-dto';
import { PersonalOffer, PersonalOfferDocument } from '../../../src/personal-offers/schemas/personal-offer.schema';
......@@ -103,7 +103,7 @@ export class UsersServiceMock {
}
}
getAdmins() {
return {
const admin = {
_id: '6231aefe76598527c8d0b5bc',
validationToken:
'cf1c74c22cedb6b575945098db42d2f493fb759c9142c6aff7980f252886f36ee086574ee99a06bc99119079257116c959c8ec870949cebdef2b293666dbca42',
......@@ -115,6 +115,7 @@ export class UsersServiceMock {
surname: 'admin',
personalOffers: [],
};
return [admin, admin];
}
getPendingStructures(): PendingStructureDto[] {
......@@ -172,7 +173,7 @@ export class UsersServiceMock {
role: 0,
name: 'DUPONT',
surname: 'Pauline',
structuresLink: ['abcdefgh', '18sfqfq', '6093ba0e2ab5775cfc01fffe'],
structuresLink: ['6093ba0e2ab5775cfc01ed3e', '6903ba0e2ab5775cfc01ed4d'],
personalOffers: [],
});
});
......@@ -332,4 +333,16 @@ export class UsersServiceMock {
if (user.job?.hasPersonalOffer) return personalOffersDataMock[0] as PersonalOfferDocument;
return null;
}
getStructureOwners() {
return [];
}
getStructureOwnersDetails() {
return ['', ''];
}
updateStructureLinkedClaim() {
return;
}
}