|
1 |
| -import container from '../../../../src/apps/mooc_backend/config/dependency-injection'; |
| 1 | +import moocContainer from '../../../../src/apps/mooc_backend/config/dependency-injection'; |
| 2 | +import backendBackofficecontainer from '../../../../src/apps/backoffice/backend/config/dependency-injection'; |
2 | 3 | import { EnvironmentArranger } from '../../../Contexts/Shared/infrastructure/arranger/EnvironmentArranger';
|
3 | 4 | import { seed } from '../../../../src/apps/backoffice/frontend/seed';
|
| 5 | +import { EventBus } from '../../../../src/Contexts/Shared/domain/EventBus'; |
| 6 | +import { DomainEventJsonDeserializer } from '../../../../src/Contexts/Shared/infrastructure/EventBus/DomainEventJsonDeserializer'; |
| 7 | +import { registerSubscribers } from '../../../../src/apps/backoffice/backend/subscribers'; |
| 8 | +import Cypress from 'cypress'; |
4 | 9 |
|
5 |
| -const environmentArranger: Promise<EnvironmentArranger> = container.get('Mooc.EnvironmentArranger'); |
| 10 | +const moocEnvironmentArranger: Promise<EnvironmentArranger> = moocContainer.get('Mooc.EnvironmentArranger'); |
| 11 | +const BackofficeBackendEnvironmentArranger: Promise<EnvironmentArranger> = backendBackofficecontainer.get( |
| 12 | + 'Backoffice.Backend.EnvironmentArranger' |
| 13 | +); |
| 14 | + |
| 15 | +const eventBus = backendBackofficecontainer.get('Shared.EventBus') as EventBus; |
| 16 | +const deserializer = backendBackofficecontainer.get( |
| 17 | + 'Shared.EventBus.DomainEventJsonDeserializer' |
| 18 | +) as DomainEventJsonDeserializer; |
| 19 | +registerSubscribers(); |
6 | 20 |
|
7 | 21 | export default (on: Cypress.PluginEvents, config: Cypress.PluginConfig) => {
|
8 | 22 | on('task', {
|
9 |
| - async 'reset:db'() { |
10 |
| - await (await environmentArranger).arrange(); |
| 23 | + async 'reset:mooc:db'() { |
| 24 | + await (await moocEnvironmentArranger).arrange(); |
| 25 | + await seed(); |
| 26 | + return null; |
| 27 | + }, |
| 28 | + |
| 29 | + async 'reset:backoffice:db'() { |
| 30 | + await (await BackofficeBackendEnvironmentArranger).arrange(); |
11 | 31 | await seed();
|
12 | 32 | return null;
|
| 33 | + }, |
| 34 | + |
| 35 | + async 'publish:course:created'(event) { |
| 36 | + const domainEvent = deserializer.deserialize(event); |
| 37 | + await eventBus.publish([domainEvent]); |
| 38 | + return null; |
13 | 39 | }
|
14 | 40 | });
|
15 | 41 | };
|
0 commit comments