|
| 1 | +import { |
| 2 | + provideHttpClient, |
| 3 | + withInterceptorsFromDi, |
| 4 | +} from "@angular/common/http"; |
| 5 | +import { EventEmitter } from "@angular/core"; |
| 6 | +import { NoopAnimationsModule } from "@angular/platform-browser/animations"; |
| 7 | +import { ActivatedRoute, provideRouter } from "@angular/router"; |
| 8 | +import { apiUri } from "@modbus2mqtt/server.shared"; |
| 9 | +import { SelectSlaveComponent } from "angular/src/app/select-slave/select-slave.component"; |
| 10 | +import { from } from "rxjs"; |
| 11 | +let ev = new EventEmitter<number | undefined>() |
| 12 | +// entityApiService.getConfiguration {mqttbasetopic rootUrl apiUri.configuration |
| 13 | +// entityApiService.getBus bus.connectionData, bus.busId apiUri.bus |
| 14 | +// entityApiService.getSlaves Islave[] apiUri.slaves |
| 15 | +// getSpecsForSlave IidentificationSpecification[] apiUri.specsForSlaveId |
| 16 | +// not implemented yet deleteSlave |
| 17 | +// not implemented yet postSlave |
| 18 | + |
| 19 | +/** |
| 20 | + * mounts the specification-entity-component and opens all expansion panels |
| 21 | + * |
| 22 | + * The entity values must be changed in the UI using cypress methods |
| 23 | + * |
| 24 | + * The Modbus Value is a 32 bit array. It can be changed in specificationMethods.postModbusEntity if required |
| 25 | + * |
| 26 | + * If other initial values are required, a new test file is required |
| 27 | + */ |
| 28 | +export function beforeEachHelper() { |
| 29 | + cy.intercept("GET", "**/converters", { |
| 30 | + fixture: "converters.json", |
| 31 | + }); |
| 32 | + // This configures the rootUrl for /api... calls |
| 33 | + // they need to be relative in ingress scenarios, |
| 34 | + // but they must be absolute for cypress tests |
| 35 | + cy.window().then((win) => { |
| 36 | + (win as any).configuration = { rootUrl: "/" }; |
| 37 | + }); |
| 38 | + cy.mount(SelectSlaveComponent, { |
| 39 | + imports: [NoopAnimationsModule], |
| 40 | + providers: [provideHttpClient(withInterceptorsFromDi()), provideRouter([]),{ |
| 41 | + provide: ActivatedRoute, |
| 42 | + useValue: { |
| 43 | + params: from([{busid: 1}]), |
| 44 | + }, |
| 45 | + },], |
| 46 | + componentProperties: { |
| 47 | + slaveidEventEmitter:ev |
| 48 | + }, |
| 49 | + }); |
| 50 | +} |
| 51 | + |
0 commit comments