Skip to content

Commit 0b5462e

Browse files
committed
added data-cy and backofficecourses-test
1 parent 96dffb9 commit 0b5462e

File tree

7 files changed

+26
-3
lines changed

7 files changed

+26
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"mongo": {
33
"url": "mongodb://localhost:27017/backoffice-backend-test"
4+
},
5+
"elastic": {
6+
"indexName": "backofficecourses-test"
47
}
58
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"mongo": {
33
"url": "mongodb://localhost:27017/backoffice-backend-test"
4+
},
5+
"elastic": {
6+
"indexName": "backofficecourses-test"
47
}
58
}

src/apps/backoffice/frontend/templates/pages/courses/partials/new_course_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form class="w-full max-w-lg float-right" method="post" action="/courses">
1+
<form class="w-full max-w-lg float-right" method="post" action="/courses" id="create-course" data-cy="create-course">
22
<h2 class="block uppercase tracking-wide text-gray-700 text-3xl font-bold mb-2">Crear curso</h2>
33
<div class="flex flex-wrap mb-6 -mx-3">
44
<div class="w-full md:w-full px-3 mb-6 md:mb-0">

tests/Contexts/Backoffice/Courses/domain/BackofficeCourseCriteriaMother.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import { FilterValue } from '../../../../../src/Contexts/Shared/domain/criteria/
77
import { Order } from '../../../../../src/Contexts/Shared/domain/criteria/Order';
88

99
export class BackofficeCourseCriteriaMother {
10+
static whithoutFilter(): Criteria {
11+
return new Criteria(new Filters([]), Order.fromValues());
12+
}
13+
1014
static nameAndDurationContainsSortAscById(name: string, duration: string): Criteria {
1115
const filterFieldName = new FilterField('name');
1216
const filterFieldDuration = new FilterField('duration');

tests/Contexts/Backoffice/Courses/infrastructure/BackofficeCourseRepository.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ describe('BackofficeCourseRepository', () => {
3131
});
3232

3333
describe('#searchByCriteria', () => {
34+
it('should return all courses', async () => {
35+
const courses = [
36+
BackofficeCourseMother.withNameAndDuration('DDD in Typescript', '8 days'),
37+
BackofficeCourseMother.withNameAndDuration('DDD in Golang', '3 days'),
38+
BackofficeCourseMother.random()
39+
];
40+
41+
await Promise.all(courses.map(async course => repository.save(course)));
42+
const result = await repository.matching(BackofficeCourseCriteriaMother.whithoutFilter());
43+
44+
expect(result).toHaveLength(3);
45+
});
46+
3447
it('should return courses using a criteria sorting by id', async () => {
3548
const courses = [
3649
BackofficeCourseMother.withNameAndDuration('DDD in Typescript', '8 days'),

tests/Contexts/Shared/infrastructure/elastic/ElasticEnvironmentArranger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class ElasticEnvironmentArranger extends EnvironmentArranger {
1414
const client = await this.client();
1515

1616
await client.deleteByQuery({
17-
index: 'backofficecourses',
17+
index: 'backofficecourses-test',
1818
body: {
1919
query: {
2020
match_all: {}

tests/apps/backoffice/frontend/features/courses/create_course.cypress.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('Create courses', () => {
2525
const courseName = faker.random.words(1);
2626
cy.get('input[name="name"]').type(courseName);
2727
cy.get('input[name="duration"]').type('8 days');
28-
cy.get('form').submit();
28+
cy.get('form[data-cy="create-course"]').submit();
2929

3030
cy.get('div[role="alert"]').contains(`Felicidades, el curso ${courseName} ha sido creado!`);
3131

0 commit comments

Comments
 (0)