-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add run e2e test on pipeline * Create mock server per each test * Create server and close server move to utils * Add api list tests * Change workflow command Co-authored-by: Farhad Alizada <falizada@microsoft.com>
- Loading branch information
Showing
33 changed files
with
3,410 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
param ($HostName = $(throw "HostName parameter is required.")) | ||
$Counter = 0 | ||
while ($Counter -ne 2 ){ | ||
Start-Sleep -Seconds 4 | ||
$Response = Invoke-WebRequest -Uri $HostName | ||
if ($Response.StatusCode -eq 200){ | ||
Write-Host "server returned 200" | ||
exit 0 | ||
} | ||
$Counter++ | ||
} | ||
|
||
Write-Error "Server didn't return 200 status" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
const staticDataEnvironment = "staticData"; | ||
|
||
const mockStaticDataEnvironment = "mockStaticData"; | ||
module.exports = { | ||
staticDataEnvironment | ||
staticDataEnvironment, | ||
mockStaticDataEnvironment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,12 @@ | ||
{ | ||
"environment": "validation", | ||
"root": "http://localhost:8080", | ||
"urls": { | ||
"home": "https://contoso.com", | ||
"signin": "https://contoso.com/signin", | ||
"signup": "https://contoso.com/signup" | ||
}, | ||
"signin": { | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"credentials": { | ||
"basic": { | ||
"email": "johndoe@contoso.com", | ||
"password": "< password >" | ||
}, | ||
"aadB2C": { | ||
"email": "johndoe@contoso.com", | ||
"password": "< password >" | ||
} | ||
} | ||
}, | ||
"signup": { | ||
"firstName": "John", | ||
"lastName": "Doe", | ||
"credentials": { | ||
"basic": { | ||
"email": "johndoe@contoso.com", | ||
"password": "< password >" | ||
} | ||
} | ||
"home": "/", | ||
"signin": "/signin", | ||
"signup": "/signup", | ||
"profile": "/profile", | ||
"products": "/products", | ||
"apis": "/apis" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"environment": "publishing", | ||
"managementApiUrl": "http://localhost:8181/subscriptions/sid/resourceGroups/rgid/providers/Microsoft.ApiManagement/service/sid", | ||
"managementApiAccessToken": "SharedAccessSignature...", | ||
"useHipCaptcha": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"environment": "runtime", | ||
"managementApiUrl": "http://localhost:8181/subscriptions/sid/resourceGroups/rgid/providers/Microsoft.ApiManagement/service/sid", | ||
"backendUrl": "http://localhost:8080/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { LaunchOptions, BrowserLaunchArgumentOptions, BrowserConnectOptions } from "puppeteer"; | ||
|
||
export const BrowserLaunchOptions: LaunchOptions & BrowserLaunchArgumentOptions & BrowserConnectOptions = { | ||
headless: false, | ||
headless: true, | ||
ignoreHTTPSErrors: true, | ||
product: "chrome" | ||
product: "chrome", | ||
devtools: true, | ||
userDataDir: "/puppeteer-data-dir", // necessary for persistent user preferences | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Page } from "puppeteer"; | ||
|
||
export class ApisWidget { | ||
constructor(private readonly page: Page) { } | ||
|
||
public async apis(): Promise<void> { | ||
await this.page.waitForSelector("api-list.block"); | ||
await this.page.waitForSelector("api-list div.table div.table-body div.table-row"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Page } from "puppeteer"; | ||
|
||
export class ProductseWidget { | ||
constructor(private readonly page: Page) { } | ||
|
||
public async products(): Promise<void> { | ||
await this.page.waitForSelector("product-list-runtime.block"); | ||
await this.page.waitForSelector("product-list-runtime div.table div.table-body div.table-row"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Page } from "puppeteer"; | ||
|
||
export class ProfileWidget { | ||
constructor(private readonly page: Page) { } | ||
|
||
public async profile(): Promise<void> { | ||
await this.page.waitForSelector("profile-runtime .row"); | ||
await this.page.waitForSelector("subscriptions-runtime .table-row"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as puppeteer from "puppeteer"; | ||
import { expect } from "chai"; | ||
import { Utils } from "../../utils"; | ||
import { BrowserLaunchOptions } from "../../constants"; | ||
import { Server } from "http"; | ||
import { Apis } from "../../mocks/collection/apis"; | ||
import { Api } from "../../mocks/collection/api"; | ||
import { ApisWidget } from "../maps/apis"; | ||
|
||
describe("Apis page", async () => { | ||
let config; | ||
let browser: puppeteer.Browser; | ||
let server: Server; | ||
|
||
before(async () => { | ||
config = await Utils.getConfig(); | ||
browser = await puppeteer.launch(BrowserLaunchOptions); | ||
}); | ||
after(async () => { | ||
browser.close(); | ||
Utils.closeServer(server); | ||
}); | ||
|
||
it("User can see apis on the page", async () => { | ||
var apis = new Apis(); | ||
apis.addApi(Api.getEchoApi()); | ||
server = await Utils.createMockServer([apis.getApisListResponse()]); | ||
|
||
const page = await browser.newPage(); | ||
await page.goto(config.urls.apis); | ||
|
||
const apiWidget = new ApisWidget(page); | ||
await apiWidget.apis(); | ||
|
||
expect(await page.evaluate(() => | ||
document.querySelector("api-list div.table div.table-body div.table-row")?.parentElement?.childElementCount | ||
)).to.equal(apis.apiList.length); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as puppeteer from "puppeteer"; | ||
import { expect } from "chai"; | ||
import { Utils } from "../../utils"; | ||
import { BrowserLaunchOptions } from "../../constants"; | ||
import { Server } from "http"; | ||
import { Products } from "../../mocks/collection/products"; | ||
import { Product } from "../../mocks/collection/product"; | ||
import { ProductseWidget } from "../maps/products"; | ||
|
||
describe("Products page", async () => { | ||
let config; | ||
let browser: puppeteer.Browser; | ||
let server: Server; | ||
|
||
before(async () => { | ||
config = await Utils.getConfig(); | ||
browser = await puppeteer.launch(BrowserLaunchOptions); | ||
}); | ||
after(async () => { | ||
browser.close(); | ||
Utils.closeServer(server); | ||
}); | ||
|
||
it("User can see producst on the page", async () => { | ||
var products = new Products(); | ||
products.addProduct(Product.getStartedProduct()); | ||
products.addProduct(Product.getUnlimitedProduct()); | ||
|
||
server = await Utils.createMockServer([products.getProductListResponse()]); | ||
|
||
const page = await browser.newPage(); | ||
await page.goto(config.urls.products); | ||
|
||
const productWidget = new ProductseWidget(page); | ||
await productWidget.products(); | ||
|
||
expect(await page.evaluate(() => | ||
document.querySelector("product-list-runtime div.table div.table-body div.table-row")?.parentElement?.childElementCount | ||
)).to.equal(products.productList.length); | ||
}); | ||
}); |
Oops, something went wrong.