Skip to content

Commit

Permalink
NAS-132484: Add stop options to containers
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft committed Nov 14, 2024
1 parent 4e14c21 commit 0541317
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectat
import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { fakeSuccessfulJob } from 'app/core/testing/utils/fake-job.utils';
import { mockApi, mockJob } from 'app/core/testing/utils/mock-api.utils';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { mockJob, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { VirtualizationStatus, VirtualizationType } from 'app/enums/virtualization.enum';
import { VirtualizationInstance } from 'app/interfaces/virtualization.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
Expand All @@ -18,7 +18,7 @@ import {
StopOptionsDialogComponent,
StopOptionsOperation,
} from 'app/pages/virtualization/components/all-instances/instance-list/stop-options-dialog/stop-options-dialog.component';
import { WebSocketService } from 'app/services/ws.service';
import { ApiService } from 'app/services/api.service';

const instance = {
id: 'my-instance',
Expand All @@ -41,7 +41,7 @@ describe('InstanceRowComponent', () => {
],
providers: [
mockAuth(),
mockWebSocket([
mockApi([
mockJob('virt.instance.restart', fakeSuccessfulJob()),
mockJob('virt.instance.start', fakeSuccessfulJob()),
mockJob('virt.instance.stop', fakeSuccessfulJob()),
Expand Down Expand Up @@ -126,7 +126,7 @@ describe('InstanceRowComponent', () => {
.toHaveBeenCalledWith(StopOptionsDialogComponent, { data: StopOptionsOperation.Stop });

expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith(
expect(spectator.inject(ApiService).job).toHaveBeenCalledWith(
'virt.instance.stop',
['my-instance', { force: true, timeout: -1 }],
);
Expand All @@ -141,7 +141,7 @@ describe('InstanceRowComponent', () => {
.toHaveBeenCalledWith(StopOptionsDialogComponent, { data: StopOptionsOperation.Restart });

expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith(
expect(spectator.inject(ApiService).job).toHaveBeenCalledWith(
'virt.instance.restart',
['my-instance', { force: true, timeout: -1 }],
);
Expand All @@ -158,7 +158,7 @@ describe('InstanceRowComponent', () => {
await startIcon.click();

expect(spectator.inject(DialogService).jobDialog).toHaveBeenCalled();
expect(spectator.inject(WebSocketService).job).toHaveBeenCalledWith('virt.instance.start', ['my-instance']);
expect(spectator.inject(ApiService).job).toHaveBeenCalledWith('virt.instance.start', ['my-instance']);
expect(spectator.inject(SnackbarService).success).toHaveBeenCalledWith('Instance started');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { TestDirective } from 'app/modules/test-id/test.directive';
import {
StopOptionsDialogComponent, StopOptionsOperation,
} from 'app/pages/virtualization/components/all-instances/instance-list/stop-options-dialog/stop-options-dialog.component';
import { ApiService } from 'app/services/api.service';
import { ErrorHandlerService } from 'app/services/error-handler.service';
import { WebSocketService } from 'app/services/ws.service';

@UntilDestroy()
@Component({
Expand Down Expand Up @@ -60,7 +60,7 @@ export class InstanceRowComponent {
constructor(
private dialog: DialogService,
private translate: TranslateService,
private ws: WebSocketService,
private api: ApiService,
private errorHandler: ErrorHandlerService,
private matDialog: MatDialog,
private snackbar: SnackbarService,
Expand All @@ -70,7 +70,7 @@ export class InstanceRowComponent {
const instanceId = this.instance().id;

this.dialog.jobDialog(
this.ws.job('virt.instance.start', [instanceId]),
this.api.job('virt.instance.start', [instanceId]),
{ title: this.translate.instant('Starting...') },
)
.afterClosed()
Expand All @@ -90,7 +90,7 @@ export class InstanceRowComponent {
filter(Boolean),
switchMap((options: VirtualizationStopParams) => {
return this.dialog.jobDialog(
this.ws.job('virt.instance.stop', [instanceId, options]),
this.api.job('virt.instance.stop', [instanceId, options]),
{ title: this.translate.instant('Stopping...') },
)
.afterClosed()
Expand All @@ -113,7 +113,7 @@ export class InstanceRowComponent {
filter(Boolean),
switchMap((options: VirtualizationStopParams) => {
return this.dialog.jobDialog(
this.ws.job('virt.instance.restart', [instanceId, options]),
this.api.job('virt.instance.restart', [instanceId, options]),
{ title: this.translate.instant('Restarting...') },
)
.afterClosed()
Expand Down

0 comments on commit 0541317

Please sign in to comment.