mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Fire onDidSelect event when selecting event from code (#13691)
* Fire onDidSelect event when selecting event from code * Fix import tests * fix typo
This commit is contained in:
@@ -86,7 +86,7 @@ describe('File config page', function () {
|
||||
|
||||
it('checking if all components are initialized properly', async function () {
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
fileConfigPage = new FileConfigPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, fileConfigPage);
|
||||
@@ -143,7 +143,6 @@ describe('File config page', function () {
|
||||
providerName: 'PGSQL',
|
||||
connectionId: 'testConnection3Id',
|
||||
options: {
|
||||
user: undefined, // setting it undefined to check if function return user as 'default
|
||||
server: 'testcon3server',
|
||||
database: 'testdb3'
|
||||
}
|
||||
@@ -156,7 +155,7 @@ describe('File config page', function () {
|
||||
providerName: 'MSSQL',
|
||||
connectionId: 'testConnection2Id',
|
||||
options: {
|
||||
// default database. This datatabe will be the first value in the database dropdown
|
||||
// default database. This database will be the first value in the database dropdown
|
||||
database: 'testdb2',
|
||||
user: 'testcon2user',
|
||||
server: 'testcon2server'
|
||||
@@ -230,16 +229,16 @@ describe('File config page', function () {
|
||||
{ displayName: 'schema3', name: 'schema3' }
|
||||
];
|
||||
|
||||
let mockQueryProvider = TypeMoq.Mock.ofType(TestQueryProvider);
|
||||
sinon.stub(azdata.dataprotocol, 'getProvider').returns(mockQueryProvider.object);
|
||||
mockQueryProvider.setup(x => x.runQueryAndReturn(TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(async () => { return schemaQueryResult; });
|
||||
const testQueryProvider = new TestQueryProvider();
|
||||
sinon.stub(azdata.dataprotocol, 'getProvider').returns(testQueryProvider);
|
||||
sinon.stub(testQueryProvider, 'runQueryAndReturn').resolves(schemaQueryResult);
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
fileConfigPage = new FileConfigPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, fileConfigPage);
|
||||
await fileConfigPage.start();
|
||||
await fileConfigPage.setupNavigationValidator();
|
||||
fileConfigPage.setupNavigationValidator();
|
||||
resolve();
|
||||
});
|
||||
wizard.generateScriptButton.hidden = true;
|
||||
@@ -251,11 +250,11 @@ describe('File config page', function () {
|
||||
|
||||
await fileConfigPage.onPageEnter();
|
||||
|
||||
should.deepEqual(fileConfigPage.serverDropdown.value, expectedConnectionValues[0]);
|
||||
should.deepEqual(fileConfigPage.serverDropdown.values, expectedConnectionValues);
|
||||
should.deepEqual(fileConfigPage.databaseDropdown.value, expectedDatabaseDropdownValues[0]);
|
||||
should.deepEqual(fileConfigPage.databaseDropdown.values, expectedDatabaseDropdownValues);
|
||||
should.deepEqual(fileConfigPage.schemaDropdown.value, expectedSchemaValues[0]);
|
||||
should.deepEqual(fileConfigPage.schemaDropdown.values, expectedSchemaValues);
|
||||
should.deepEqual(fileConfigPage.serverDropdown.value, expectedConnectionValues[0], 'Server dropdown value was incorrect');
|
||||
should.deepEqual(fileConfigPage.serverDropdown.values, expectedConnectionValues, 'Server dropdown values were incorrect');
|
||||
should.deepEqual(fileConfigPage.databaseDropdown.value, expectedDatabaseDropdownValues[0], 'Database dropdown value was incorrect');
|
||||
should.deepEqual(fileConfigPage.databaseDropdown.values, expectedDatabaseDropdownValues, 'Database dropdown values were incorrect');
|
||||
should.deepEqual(fileConfigPage.schemaDropdown.value, expectedSchemaValues[0], 'Schema dropdown value was incorrect');
|
||||
should.deepEqual(fileConfigPage.schemaDropdown.values, expectedSchemaValues, 'Schema dropdown values were incorrect');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('import extension modify Column Page', function () {
|
||||
|
||||
it('checking if all components are initialized properly', async function () {
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
modifyColumnsPage = new ModifyColumnsPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, modifyColumnsPage);
|
||||
@@ -81,7 +81,7 @@ describe('import extension modify Column Page', function () {
|
||||
|
||||
mockImportModel.object.proseColumns = testProseColumns;
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
modifyColumnsPage = new ModifyColumnsPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, modifyColumnsPage);
|
||||
|
||||
@@ -41,12 +41,12 @@ describe('import extension prose preview tests', function () {
|
||||
it('checking if all components are initialized properly', async function () {
|
||||
|
||||
// Opening the wizard and initializing the page as ProsePreviewPage
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
prosePreviewPage = new ProsePreviewPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, prosePreviewPage);
|
||||
await prosePreviewPage.start();
|
||||
await prosePreviewPage.setupNavigationValidator();
|
||||
prosePreviewPage.setupNavigationValidator();
|
||||
await prosePreviewPage.onPageEnter();
|
||||
resolve();
|
||||
});
|
||||
|
||||
@@ -38,7 +38,7 @@ describe('import extension summary page tests', function () {
|
||||
|
||||
it('checking if all components are initialized properly', async function () {
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
summaryPage = new SummaryPage(mockFlatFileWizard.object, page, mockImportModel.object, view, TypeMoq.It.isAny());
|
||||
pages.set(1, summaryPage);
|
||||
@@ -105,7 +105,7 @@ describe('import extension summary page tests', function () {
|
||||
};
|
||||
mockFlatFileProvider.setup(x => x.sendInsertDataRequest(TypeMoq.It.isAny())).returns(async () => { return testSendInsertDataRequestResponse; });
|
||||
|
||||
await new Promise(function (resolve) {
|
||||
await new Promise<void>(function (resolve) {
|
||||
page.registerContent(async (view) => {
|
||||
summaryPage = new SummaryPage(mockFlatFileWizard.object, page, mockImportModel.object, view, mockFlatFileProvider.object);
|
||||
pages.set(1, summaryPage);
|
||||
|
||||
@@ -144,8 +144,12 @@ export class FileConfigPage extends ImportPage {
|
||||
}).component();
|
||||
|
||||
// Handle server changes
|
||||
this.serverDropdown.onValueChanged(async (params) => {
|
||||
this.model.server = (this.serverDropdown.value as ConnectionDropdownValue).connection;
|
||||
this.serverDropdown.onValueChanged(async () => {
|
||||
const connectionValue = this.serverDropdown.value as ConnectionDropdownValue;
|
||||
if (!connectionValue) {
|
||||
return;
|
||||
}
|
||||
this.model.server = connectionValue.connection;
|
||||
|
||||
await this.populateDatabaseDropdown();
|
||||
await this.populateSchemaDropdown();
|
||||
@@ -165,10 +169,7 @@ export class FileConfigPage extends ImportPage {
|
||||
|
||||
this.model.server = values[0].connection;
|
||||
|
||||
|
||||
this.serverDropdown.updateProperties({
|
||||
values: values
|
||||
});
|
||||
this.serverDropdown.values = values;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -178,9 +179,15 @@ export class FileConfigPage extends ImportPage {
|
||||
}).component();
|
||||
|
||||
// Handle database changes
|
||||
this.databaseDropdown.onValueChanged(async (db) => {
|
||||
this.model.database = (<azdata.CategoryValue>this.databaseDropdown.value).name;
|
||||
//this.populateTableNames();
|
||||
this.databaseDropdown.onValueChanged(async () => {
|
||||
const nameValue = this.databaseDropdown.value as azdata.CategoryValue;
|
||||
if (!nameValue) {
|
||||
return;
|
||||
}
|
||||
this.model.database = nameValue.name;
|
||||
if (!this.model.server) {
|
||||
return;
|
||||
}
|
||||
let connectionProvider = azdata.dataprotocol.getProvider<azdata.ConnectionProvider>(this.model.server.providerName, azdata.DataProviderType.ConnectionProvider);
|
||||
let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
connectionProvider.changeDatabase(connectionUri, this.model.database);
|
||||
@@ -195,8 +202,8 @@ export class FileConfigPage extends ImportPage {
|
||||
|
||||
private async populateDatabaseDropdown(): Promise<boolean> {
|
||||
this.databaseDropdown.loading = true;
|
||||
this.databaseDropdown.updateProperties({ values: [] });
|
||||
this.schemaDropdown.updateProperties({ values: [] });
|
||||
this.databaseDropdown.values = [];
|
||||
this.schemaDropdown.values = [];
|
||||
|
||||
if (!this.model.server) {
|
||||
//TODO handle error case
|
||||
@@ -340,7 +347,11 @@ export class FileConfigPage extends ImportPage {
|
||||
this.schemaLoader = this.view.modelBuilder.loadingComponent().withItem(this.schemaDropdown).component();
|
||||
|
||||
this.schemaDropdown.onValueChanged(() => {
|
||||
this.model.schema = (<azdata.CategoryValue>this.schemaDropdown.value).name;
|
||||
const schemaValue = this.schemaDropdown.value as azdata.CategoryValue;
|
||||
if (!schemaValue) {
|
||||
return;
|
||||
}
|
||||
this.model.schema = schemaValue.name;
|
||||
});
|
||||
|
||||
|
||||
@@ -356,22 +367,22 @@ export class FileConfigPage extends ImportPage {
|
||||
|
||||
let values = await this.getSchemaValues();
|
||||
|
||||
this.model.schema = values[0].name;
|
||||
this.model.schema = values[0]?.name;
|
||||
|
||||
this.schemaDropdown.updateProperties({
|
||||
values: values
|
||||
});
|
||||
this.schemaDropdown.values = values;
|
||||
|
||||
this.schemaLoader.loading = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public async getSchemaValues(): Promise<{ displayName: string, name: string }[]> {
|
||||
if (!this.model.server) {
|
||||
return [];
|
||||
}
|
||||
let connectionUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||
let queryProvider = azdata.dataprotocol.getProvider<azdata.QueryProvider>(this.model.server.providerName, azdata.DataProviderType.QueryProvider);
|
||||
|
||||
let results = await queryProvider.runQueryAndReturn(connectionUri, constants.selectSchemaQuery);
|
||||
|
||||
let idx = -1;
|
||||
let count = -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user