mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add test coverage for dacpac wizard import flow (#11483)
* Adding importConfig onPageEnter() test * Removing redundancy from dacpac wizard pages * promisifying file selection so it can be awaited in the test * removing debug prints * PR feedback
This commit is contained in:
@@ -12,13 +12,8 @@ import { DacFxConfigPage } from '../api/dacFxConfigPage';
|
||||
import { generateDatabaseName } from '../api/utils';
|
||||
|
||||
export class ImportConfigPage extends DacFxConfigPage {
|
||||
|
||||
protected readonly wizardPage: azdata.window.WizardPage;
|
||||
protected readonly instance: DataTierApplicationWizard;
|
||||
protected readonly model: DacFxDataModel;
|
||||
protected readonly view: azdata.ModelView;
|
||||
|
||||
private form: azdata.FormContainer;
|
||||
public selectionPromise: Promise<void>;
|
||||
|
||||
public constructor(instance: DataTierApplicationWizard, wizardPage: azdata.window.WizardPage, model: DacFxDataModel, view: azdata.ModelView) {
|
||||
super(instance, wizardPage, model, view);
|
||||
@@ -54,30 +49,7 @@ export class ImportConfigPage extends DacFxConfigPage {
|
||||
private async createFileBrowser(): Promise<azdata.FormComponent> {
|
||||
this.createFileBrowserParts();
|
||||
|
||||
this.fileButton.onDidClick(async (click) => {
|
||||
let fileUris = await vscode.window.showOpenDialog(
|
||||
{
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(this.getRootPath()),
|
||||
openLabel: loc.open,
|
||||
filters: {
|
||||
'bacpac Files': ['bacpac'],
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!fileUris || fileUris.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fileUri = fileUris[0];
|
||||
this.fileTextBox.value = fileUri.fsPath;
|
||||
this.model.filePath = fileUri.fsPath;
|
||||
this.model.database = generateDatabaseName(this.model.filePath);
|
||||
this.databaseTextBox.value = this.model.database;
|
||||
});
|
||||
this.fileButton.onDidClick(async (click) => { this.selectionPromise = this.handleFileSelection(); });
|
||||
|
||||
this.fileTextBox.onTextChanged(async () => {
|
||||
this.model.filePath = this.fileTextBox.value;
|
||||
@@ -91,4 +63,29 @@ export class ImportConfigPage extends DacFxConfigPage {
|
||||
actions: [this.fileButton]
|
||||
};
|
||||
}
|
||||
|
||||
private async handleFileSelection(): Promise<void> {
|
||||
let fileUris = await vscode.window.showOpenDialog(
|
||||
{
|
||||
canSelectFiles: true,
|
||||
canSelectFolders: false,
|
||||
canSelectMany: false,
|
||||
defaultUri: vscode.Uri.file(this.getRootPath()),
|
||||
openLabel: loc.open,
|
||||
filters: {
|
||||
'bacpac Files': ['bacpac'],
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (!fileUris || fileUris.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fileUri = fileUris[0];
|
||||
this.fileTextBox.value = fileUri.fsPath;
|
||||
this.model.filePath = fileUri.fsPath;
|
||||
this.model.database = generateDatabaseName(this.model.filePath);
|
||||
this.databaseTextBox.value = this.model.database;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user