<commit_before>import { expect, request } from 'chai';
import api from '../../src/server';
import { loadFixture } from '../../src/utils/test';
import Episode from '../../src/models/episode';
import { withLogin } from '../utils.js';
import nock from 'nock';
import config from '../../src/config';

describe('Episode controller', () => {
	let episode;

	before(async () => {
		await loadFixture('initialData');
		episode = await Episode.findOne({});
		expect(episode).to.not.be.null;
		expect(episode.rss).to.not.be.null;
	});

	describe('get', () => {
		it('should return the right article via /episodes/:episodeId', async () => {
			const response = await withLogin(
				request(api).get(`/episodes/${episode._id}`)
			);
			expect(response).to.have.status(200);
			expect(response.body._id).to.eq(`${episode._id}`);
		});
	});

	describe('list', () => {
		it('should return the list of episodes', async () => {
			const response = await withLogin(
				request(api).get('/episodes')
			);
			expect(response).to.have.status(200);
			expect(response.body.length).to.be.at.least(1);
		});
	});

	describe('list with recommendations', () => {
		after(function () {
			nock.cleanAll();
		});

		it('should return the list of episodes', async () => {
			nock(config.stream.baseUrl)
				.get(/winds_episode_recommendations/)
				.reply(200, { results: [
					{foreign_id:`episode:${episode.id}`}, {foreign_id:'episode:5ae0c71a0e7cbc4ee14a7c81'}] });


			const response = await withLogin(
				request(api).get('/episodes').query({
					type: 'recommended',
				})
			);
			expect(response).to.have.status(200);
			expect(response.body.length).to.be.at.least(1);
			expect(response.body[0].url).to.eq(episode.url);
		});

	});
});
<commit_msg>add missing reset<commit_after>import { expect, request } from 'chai';
import api from '../../src/server';
import { loadFixture } from '../../src/utils/test';
import Episode from '../../src/models/episode';
import { withLogin } from '../utils.js';
import nock from 'nock';
import config from '../../src/config';
import {reset} from "../utils";

describe('Episode controller', () => {
	let episode;

	before(async () => {
		await reset();
		await loadFixture('initialData');
		episode = await Episode.findOne({});
		expect(episode).to.not.be.null;
		expect(episode.rss).to.not.be.null;
	});

	describe('get', () => {
		it('should return the right article via /episodes/:episodeId', async () => {
			const response = await withLogin(
				request(api).get(`/episodes/${episode._id}`)
			);
			expect(response).to.have.status(200);
			expect(response.body._id).to.eq(`${episode._id}`);
		});
	});

	describe('list', () => {
		it('should return the list of episodes', async () => {
			const response = await withLogin(
				request(api).get('/episodes')
			);
			expect(response).to.have.status(200);
			expect(response.body.length).to.be.at.least(1);
		});
	});

	describe('list with recommendations', () => {
		after(function () {
			nock.cleanAll();
		});

		it('should return the list of episodes', async () => {
			nock(config.stream.baseUrl)
				.get(/winds_episode_recommendations/)
				.reply(200, { results: [
					{foreign_id:`episode:${episode.id}`}, {foreign_id:'episode:5ae0c71a0e7cbc4ee14a7c81'}] });


			const response = await withLogin(
				request(api).get('/episodes').query({
					type: 'recommended',
				})
			);
			expect(response).to.have.status(200);
			expect(response.body.length).to.be.at.least(1);
			expect(response.body[0].url).to.eq(episode.url);
		});

	});
});

{'fraction_non_alphanumeric': 0.20680851063829786, 'fraction_numerical': 0.015319148936170212, 'mean_word_length': 3.713903743315508, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5372007', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1211, 'n_words': 208}