Skip to content

Commit

Permalink
node+mongo script
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalin committed Sep 15, 2022
1 parent 85fe765 commit 709b0d3
Show file tree
Hide file tree
Showing 7 changed files with 994 additions and 59 deletions.
20 changes: 14 additions & 6 deletions lib/AppServiceScmPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ import { DocsPageBase } from "./DocsPageBase";
if(!this.rootUrl) {
throw new Error ('Expected rootUrl to be set');
}
this.page.goto(this.rootUrl);
await this.page.goto(this.rootUrl);

if(options?.screenshotAfter){
await this.page.locator('ul.nav.navbar-nav.navbar-right li.dropdown a[href="#"]')
.evaluate( el => (el as HTMLElement).innerText = '[email protected]');

if(options?.screenshotBefore){
// DEBUG: no need to blur
await this.screenshot({
highlightobjects: [
Expand All @@ -92,13 +95,14 @@ import { DocsPageBase } from "./DocsPageBase";
});
}

this.page.locator('a[href="api/deployments"]').click();
await this.page.locator('a[href="api/deployments"]').click();
await this.page.waitForLoadState();

if(options?.screenshotAfter){
// DEBUG: no need to blur
await this.screenshot({
height: 600,
name: options?.screenshotBefore
name: options?.screenshotAfter
});
}

Expand All @@ -112,7 +116,10 @@ import { DocsPageBase } from "./DocsPageBase";
if(!this.rootUrl) {
throw new Error ('Expected rootUrl to be set');
}
this.page.goto(this.rootUrl);
await this.page.goto(this.rootUrl);

await this.page.locator('ul.nav.navbar-nav.navbar-right li.dropdown a[href="#"]')
.evaluate( el => (el as HTMLElement).innerText = '[email protected]' );

if(options?.screenshotBefore){
// DEBUG: no need to blur
Expand All @@ -125,7 +132,8 @@ import { DocsPageBase } from "./DocsPageBase";
});
}

this.page.locator('a[href="wwwroot"]').click();
await this.page.locator('a[href="wwwroot"]').click();
await this.page.waitForLoadState();

if(options?.screenshotAfter){
// DEBUG: no need to blur
Expand Down
9 changes: 5 additions & 4 deletions lib/DocsPageBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ import sharp from 'sharp';
} else {
await root.screenshot({path: pathandname + '.png'});
}

await sharp(pathandname + '.png')
.resize({width: 240})
.toFile(pathandname + '-240px.png');

// Seems lightbox widget doesn't need this
// await sharp(pathandname + '.png')
// .resize({width: 240})
// .toFile(pathandname + '-240px.png');
}
}
27 changes: 21 additions & 6 deletions lib/appServiceLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ declare module './AzurePortalPage' {
region: string,
appName: string,
stack: string,
screenshotName?: string
options?: {
screenshotName?: string
sku?: "Basic" | "Standard"
}
): Promise<void>;

goToAppServicePageByMenu (
Expand Down Expand Up @@ -275,8 +278,11 @@ AzurePortalPage.prototype.runAppDbCreateWizard = async function(
resourceGroupName: string,
region: string,
appName: string,
stack: string,
screenshotName?: string | undefined
stack: string,
options?: {
screenshotName?: string
sku?: "Basic" | "Standard"
}
): Promise<void> {

await this.page.locator('[aria-label="Subscription selector"]').click();
Expand All @@ -292,9 +298,12 @@ AzurePortalPage.prototype.runAppDbCreateWizard = async function(
await this.page.locator('[placeholder="Web App name\\."]').fill(appName);
await this.page.locator('text=Select a runtime stack').click();
await this.page.locator(`div[role="treeitem"]:has(:text-is("${stack}"))`).click();
if(options?.sku == "Basic") {
await this.page.locator(`ul[aria-label="Web Database hosting plan"] input[value="basic"] + .azc-radio-circle`).click();
}
await expect(this.page.locator('.fxc-validation')).toHaveCount(0, {timeout: 10000}); // wait for validation warnings to disappear

if(screenshotName){
if(options?.screenshotName){
var highlighted = [
this.page.locator('.azc-formElementContainer', {has: this.page.locator('[aria-label="Subscription selector"]')}),
this.page.locator('.azc-formElementContainer', {has: this.page.locator('[aria-label="Create new or use existing Resource group selector"]')}),
Expand All @@ -304,16 +313,19 @@ AzurePortalPage.prototype.runAppDbCreateWizard = async function(
this.page.locator('.azc-formElementContainer', {has: this.page.locator('[aria-label="Location selector"]')}),
this.page.locator('[aria-label="Review and create"]')
];
if(options?.sku == "Basic") {
highlighted.push(this.page.locator(`ul[aria-label="Web Database hosting plan"] input[value="basic"] + .azc-radio-circle`));
}

// DEBUG: manually blur
// await this.page.locator('.fxs-blade-title-titleText').last().click();
await this.page.mouse.click(this.page.viewportSize()?.width / 2, 0);

await this.screenshot({
locator: this.page.locator('.fxs-journey-layout'),
height: 900,
height: 1100,
highlightobjects: highlighted,
name: screenshotName
name: options.screenshotName
});
}

Expand Down Expand Up @@ -466,6 +478,9 @@ AzurePortalPage.prototype.openAppServiceKudu = async function (options?: {

let temp = new AppServiceScmPage(popup);
temp.screenshotDir = this.screenshotDir; // TODO: not pretty. should fix
await temp.page.waitForLoadState();
await expect(temp.page.url()).toMatch(/https:\/\/.*\.scm\.azurewebsites\.net/);
temp.rootUrl = temp.page.url();
return temp;
}

Expand Down
Loading

0 comments on commit 709b0d3

Please sign in to comment.