Merge pull request #3471 from NoelDeMartin/MOBILE-4081

MOBILE-4081: QA fixes
main
Dani Palou 2022-11-24 14:00:58 +01:00 committed by GitHub
commit ad708f78cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 3 deletions

View File

@ -340,7 +340,9 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro
ngOnDestroy(): void {
this.undeleteEventObserver?.off();
this.manager?.destroy();
this.managerUnsubscribe && this.managerUnsubscribe();
this.managerUnsubscribe?.();
delete this.manager;
}
}

View File

@ -457,7 +457,9 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy {
this.filterChangedObserver?.off();
this.manager?.getSource().forgetRelatedSources();
this.manager?.destroy();
this.managerUnsubscribe && this.managerUnsubscribe();
this.managerUnsubscribe?.();
delete this.manager;
}
}

View File

@ -314,8 +314,10 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy {
* @inheritdoc
*/
ngOnDestroy(): void {
this.managerUnsubscribe && this.managerUnsubscribe();
this.manager?.destroy();
this.managerUnsubscribe?.();
delete this.manager;
}
}

View File

@ -18,6 +18,7 @@ import { AlertController, Translate } from '@singletons';
import { mock, mockSingleton, mockTranslate } from '@/testing/utils';
import { CoreSiteError } from '@classes/errors/siteerror';
import { CoreSites } from '@services/sites';
import { OverlayEventDetail } from '@ionic/core';
describe('CoreDomUtilsProvider', () => {
@ -56,4 +57,30 @@ describe('CoreDomUtilsProvider', () => {
});
});
it('ignores alert inputs on cancel', async () => {
// Arrange.
const mockAlert = mock<HTMLIonAlertElement>({
present: () => Promise.resolve(),
onWillDismiss: () => Promise.resolve({
data: {
values: {
'textarea-prompt': 'Not empty!',
},
},
role: 'cancel',
} as OverlayEventDetail<any>), // eslint-disable-line @typescript-eslint/no-explicit-any
});
mockSingleton(AlertController, mock({ create: () => Promise.resolve(mockAlert) }));
// Act.
const result = await domUtils.showTextareaPrompt('Age', 'How old are you?', [
{ text: 'Cancel', role: 'cancel' },
{ text: 'Save' },
]);
// Assert.
expect(result).toBeUndefined();
});
});

View File

@ -1659,6 +1659,10 @@ export class CoreDomUtilsProvider {
const result = await alert.onWillDismiss();
if (result.role === 'cancel') {
return;
}
return result.data?.values?.['textarea-prompt'];
}