Skip to content

Commit

Permalink
test: add generator tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilko01 committed Jan 9, 2025
1 parent a36d968 commit 55b5bb2
Show file tree
Hide file tree
Showing 9 changed files with 931 additions and 408 deletions.
26 changes: 11 additions & 15 deletions packages/adp-flp-config-sub-generator/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ export default class extends Generator {
async initializing(): Promise<void> {
// Generator does not support CF projects
if (isCFEnvironment(this.projectRootPath)) {
this.appWizard.showError(t('error.cfNotSupported'), MessageType.notification);
return;
throw new Error(t('error.cfNotSupported'));
}
// Add telemetry to be sent once adp-flp-config is generated
await TelemetryHelper.initTelemetrySettings({
Expand Down Expand Up @@ -111,17 +110,13 @@ export default class extends Generator {

end(): void {
if (!this.launchAsSubGen) {
this.appWizard.showInformation(t('info.flpConfigAdded'), MessageType.notification);
this.appWizard?.showInformation(t('info.flpConfigAdded'), MessageType.notification);
}
try {
const telemetryData = TelemetryHelper.createTelemetryData();
if (telemetryData) {
sendTelemetry(EventName.ADP_FLP_CONFIG_ADDED, telemetryData, this.projectRootPath).catch((error) => {
this.logger.error(t('error.telemetry', { error }));
});
}
} catch (error) {
this.logger.error(t('error.endPhase', { error }));
const telemetryData = TelemetryHelper.createTelemetryData() ?? {};
if (telemetryData) {
sendTelemetry(EventName.ADP_FLP_CONFIG_ADDED, telemetryData, this.projectRootPath).catch((error) => {
this.logger.error(t('error.telemetry', { error }));
});
}
}

Expand Down Expand Up @@ -160,10 +155,9 @@ export default class extends Generator {
* @returns {Promise<void>} A promise that resolves when the manifest has been fetched.
*/
private async _fetchManifest(): Promise<void> {
const { target } = await getAdpConfig(this.projectRootPath, join(this.projectRootPath, FileName.Ui5Yaml));
const configuredSystem = await this._findConfiguredSystem(target);
try {
const { target } = await getAdpConfig(this.projectRootPath, join(this.projectRootPath, FileName.Ui5Yaml));

const configuredSystem = await this._findConfiguredSystem(target);
const systemSelectionQuestions = await getSystemSelectionQuestions({
systemSelection: { onlyShowDefaultChoice: true, defaultChoice: configuredSystem },
serviceSelection: { hide: true }
Expand Down Expand Up @@ -204,3 +198,5 @@ export default class extends Generator {
};
}
}

export type { FlpConfigOptions };
2 changes: 1 addition & 1 deletion packages/adp-flp-config-sub-generator/src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type Generator from 'yeoman-generator';
export interface FlpConfigOptions extends Generator.GeneratorOptions {
force?: boolean;
appWizard?: AppWizard;
launchFlpConfigAsSubGenerator?: boolean;
launchAsSubGen?: boolean;
manifest: Manifest;
data?: {
projectRootPath: string;
Expand Down
Loading

0 comments on commit 55b5bb2

Please sign in to comment.