mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Add DacFx summary page tests (#11519)
* remove generate script operation * add tests for summary page * add a couple more checks
This commit is contained in:
85
extensions/dacpac/src/test/dacFxSummaryPage.test.ts
Normal file
85
extensions/dacpac/src/test/dacFxSummaryPage.test.ts
Normal file
@@ -0,0 +1,85 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import 'mocha';
|
||||
import * as should from 'should';
|
||||
import { DataTierApplicationWizard, PageName, Operation } from '../wizard/dataTierApplicationWizard';
|
||||
import { DacFxDataModel } from '../wizard/api/models';
|
||||
import { TestContext, createContext } from './testContext';
|
||||
import { TestDacFxSummaryPage } from './testDacFxConfigPages';
|
||||
|
||||
let wizard: DataTierApplicationWizard;
|
||||
let testContext: TestContext;
|
||||
|
||||
describe('DacFx Summary Page Tests', function (): void {
|
||||
beforeEach(async function (): Promise<void> {
|
||||
wizard = new DataTierApplicationWizard();
|
||||
wizard.model = <DacFxDataModel>{};
|
||||
wizard.model.server = undefined;
|
||||
wizard.setPages();
|
||||
wizard.configureButtons();
|
||||
testContext = createContext();
|
||||
});
|
||||
|
||||
it('DacFx Summary Page should start correctly for deploying to an existing database', async () => {
|
||||
wizard.selectedOperation = Operation.deploy;
|
||||
wizard.model.upgradeExisting = true;
|
||||
|
||||
const summaryPage = await validatePageCreation();
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(false, 'Generate script button should not be hidden when the operation is deploy and upgrade existing is true');
|
||||
await validateOnPageLeave(summaryPage);
|
||||
});
|
||||
|
||||
it('DacFx Summary Page should start correctly for deploying to a new database', async () => {
|
||||
wizard.selectedOperation = Operation.deploy;
|
||||
wizard.model.upgradeExisting = false;
|
||||
|
||||
const summaryPage = await validatePageCreation();
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(true, 'Generate script button should be hidden when deploying to a new database');
|
||||
await validateOnPageLeave(summaryPage);
|
||||
});
|
||||
|
||||
it('DacFx Summary Page should start correctly for extract', async () => {
|
||||
wizard.selectedOperation = Operation.extract;
|
||||
|
||||
const summaryPage = await validatePageCreation();
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(true, 'Generate script button should be hidden when extracting');
|
||||
await validateOnPageLeave(summaryPage);
|
||||
});
|
||||
|
||||
it('DacFx Summary Page should start correctly for import', async () => {
|
||||
wizard.selectedOperation = Operation.import;
|
||||
|
||||
const summaryPage = await validatePageCreation();
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(true, 'Generate script button should be hidden when importing');
|
||||
await validateOnPageLeave(summaryPage);
|
||||
});
|
||||
|
||||
it('DacFx Summary Page should start correctly for exporting', async () => {
|
||||
wizard.selectedOperation = Operation.export;
|
||||
|
||||
const summaryPage = await validatePageCreation();
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(true, 'Generate script button should be hidden when exporting');
|
||||
await validateOnPageLeave(summaryPage);
|
||||
});
|
||||
|
||||
async function validatePageCreation(): Promise<TestDacFxSummaryPage> {
|
||||
const summaryPage: TestDacFxSummaryPage = new TestDacFxSummaryPage(wizard, wizard.pages.get(PageName.selectOperation).wizardPage, wizard.model, testContext.viewContext.view);
|
||||
const onPageStart = await summaryPage.start();
|
||||
const onPageEnter = await summaryPage.onPageEnter();
|
||||
should(onPageStart).equal(true);
|
||||
should(onPageEnter).equal(true);
|
||||
should(summaryPage.data).not.equal(undefined);
|
||||
should(summaryPage.data.length).equal(summaryPage.WizardState.selectedOperation === Operation.extract ? 4 : 3);
|
||||
|
||||
return summaryPage;
|
||||
}
|
||||
|
||||
async function validateOnPageLeave(summaryPage: TestDacFxSummaryPage): Promise<void> {
|
||||
const onPageLeave = await summaryPage.onPageLeave();
|
||||
should(onPageLeave).equal(true);
|
||||
should(summaryPage.WizardState.wizard.generateScriptButton.hidden).equal(true, 'Generate Script button should be hidden when leaving the summary page');
|
||||
}
|
||||
});
|
||||
@@ -10,6 +10,7 @@ import { ExtractConfigPage } from '../wizard/pages/extractConfigPage';
|
||||
import { DataTierApplicationWizard } from '../wizard/dataTierApplicationWizard';
|
||||
import { SelectOperationPage } from '../wizard/pages/selectOperationpage';
|
||||
import { ImportConfigPage } from '../wizard/pages/importConfigPage';
|
||||
import { DacFxSummaryPage } from '../wizard/pages/dacFxSummaryPage';
|
||||
|
||||
export class TestDeployConfigPage extends DeployConfigPage {
|
||||
constructor(instance: DataTierApplicationWizard, wizardPage: azdata.window.WizardPage, model: DacFxDataModel, view: azdata.ModelView) {
|
||||
@@ -58,3 +59,13 @@ export class TestImportConfigPage extends ImportConfigPage {
|
||||
return this.model;
|
||||
}
|
||||
}
|
||||
|
||||
export class TestDacFxSummaryPage extends DacFxSummaryPage {
|
||||
constructor(instance: DataTierApplicationWizard, wizardPage: azdata.window.WizardPage, model: DacFxDataModel, view: azdata.ModelView) {
|
||||
super(instance, wizardPage, model, view);
|
||||
}
|
||||
|
||||
get WizardState(): DataTierApplicationWizard {
|
||||
return this.instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +74,6 @@ describe('Dacfx wizard', function (): void {
|
||||
wizard.model.upgradeExisting = true;
|
||||
should.equal(wizard.isSummaryPage(3), true);
|
||||
|
||||
// summary page should be 3 for generate deploy script
|
||||
wizard.selectedOperation = Operation.generateDeployScript;
|
||||
should.equal(wizard.isSummaryPage(3), true);
|
||||
|
||||
// summary page should be 2 for import
|
||||
wizard.selectedOperation = Operation.import;
|
||||
should.equal(wizard.isSummaryPage(2), true);
|
||||
@@ -95,9 +91,6 @@ describe('Dacfx wizard', function (): void {
|
||||
wizard.setDoneButton(Operation.deploy);
|
||||
should.equal(wizard.selectedOperation, Operation.deploy);
|
||||
|
||||
wizard.setDoneButton(Operation.generateDeployScript);
|
||||
should.equal(wizard.selectedOperation, Operation.generateDeployScript);
|
||||
|
||||
wizard.setDoneButton(Operation.extract);
|
||||
should.equal(wizard.selectedOperation, Operation.extract);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user