Skip to content

Commit

Permalink
NAS-132245: Apps without ixVolumes cannot be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
undsoft committed Nov 4, 2024
1 parent 417a60a commit 98bc80e
Showing 4 changed files with 1,740 additions and 1,704 deletions.
Original file line number Diff line number Diff line change
@@ -165,4 +165,36 @@ describe('ConfirmDialogComponent', () => {
});
});
});

describe('secondary checkbox present, but false', () => {
const secondaryCheckboxOptions = {
...options,
secondaryCheckbox: false,
secondaryCheckboxText: 'Secondary checkbox',
} as ConfirmOptionsWithSecondaryCheckbox;

beforeEach(() => {
spectator = createComponent({
providers: [
{
provide: MAT_DIALOG_DATA,
useValue: secondaryCheckboxOptions,
},
],
});
loader = TestbedHarnessEnvironment.loader(spectator.fixture);
});

it('closes dialog with an object even when `secondaryCheckbox` is false, but present in options', async () => {
const checkbox = await loader.getHarness(MatCheckboxHarness.with({ label: options.confirmationCheckboxText }));
await checkbox.check();

const button = await loader.getHarness(MatButtonHarness.with({ text: options.buttonText }));
await button.click();
expect(spectator.inject(MatDialogRef).close).toHaveBeenCalledWith({
confirmed: true,
secondaryCheckbox: false,
});
});
});
});
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ export class ConfirmDialogComponent {
this.dialogRef.disableClose = options.hideCancel;
}

if (options.secondaryCheckbox) {
if (this.withSecondaryCheckbox) {
// Don't allow user to close via backdrop to ensure that object is returned.
this.dialogRef.disableClose = true;
}
@@ -75,7 +75,7 @@ export class ConfirmDialogComponent {
}

onCancel(): void {
const result = this.options.secondaryCheckbox
const result = this.withSecondaryCheckbox
? {
confirmed: false,
secondaryCheckbox: this.isSecondaryCheckboxChecked,
@@ -86,7 +86,7 @@ export class ConfirmDialogComponent {
}

onSubmit(): void {
const result = this.options.secondaryCheckbox
const result = this.withSecondaryCheckbox
? {
confirmed: true,
secondaryCheckbox: this.isSecondaryCheckboxChecked,
@@ -95,4 +95,8 @@ export class ConfirmDialogComponent {

this.dialogRef.close(result);
}

private get withSecondaryCheckbox(): boolean {
return 'secondaryCheckbox' in this.options;
}
}
Loading

0 comments on commit 98bc80e

Please sign in to comment.