-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e): using stackblitzSDK to open templates (#663)
- Loading branch information
Showing
11 changed files
with
840 additions
and
691 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,28 @@ | ||
name: Stackblitz templates | ||
run-name: Playwright stackblitz templates 🚀 | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '59 23 * * *' | ||
jobs: | ||
run-code_examples-tests: | ||
runs-on: ubuntu-latest | ||
name: Playwright testing stackblitz templates | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
- name: Install dependencies | ||
run: npm ci | ||
- name: Install playwright browsers | ||
run: npx playwright install --with-deps | ||
- name: Run tests | ||
run: npx playwright test checkStackblitzTemplates.spec.ts --project=chromium | ||
- name: try zip the test result folder | ||
if: failure() | ||
run: zip -r playwright-report.zip playwright-report/ | ||
- uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: playwright-report zip | ||
path: playwright-report.zip | ||
retention-days: 7 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
interface Window { | ||
StackBlitzSDK: typeof import("@stackblitz/sdk").default; | ||
} | ||
|
||
type StackBlitzSDK = typeof import("@stackblitz/sdk").default; |
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,23 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>@stackblitz/sdk</title> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<script type="module" crossorigin src="./index.js"></script> | ||
<style> | ||
html { | ||
font-family: system-ui, sans-serif; | ||
color: black; | ||
background-color: white; | ||
} | ||
body { | ||
margin: 1rem; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="embed"></div> | ||
</body> | ||
</html> |
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,3 @@ | ||
import StackBlitzSDK from "https://unpkg.com/@stackblitz/sdk@1/bundles/sdk.m.js"; | ||
|
||
window.StackBlitzSDK = StackBlitzSDK; |
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,26 +1,35 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { HomePage } from "../page-objects/HomePage"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
test("Verify stackblitz template", async ({ page }) => { | ||
test.setTimeout(200000); | ||
let homePage: HomePage; | ||
const response = await page.goto(""); | ||
homePage = new HomePage(page); | ||
await page.waitForLoadState(); | ||
await page.waitForSelector("text=Open in New Tab"); | ||
await page.waitForLoadState("domcontentloaded"); | ||
await homePage.wait(10000); | ||
const directoryPath = path.join(__dirname, "../../../templates/"); | ||
|
||
const consoleLogs = []; | ||
page.on("console", (msg) => { | ||
if (msg.type() == "error") { | ||
console.log(msg.text()); | ||
consoleLogs.push(msg.text()); | ||
} | ||
expect(msg.type()).not.toBe("error"); | ||
}); | ||
fs.readdirSync(directoryPath).forEach((template) => { | ||
test(`Open ${template}`, async ({ page }) => { | ||
test.setTimeout(90000); | ||
await page.goto("/pages/blank.html"); | ||
await Promise.all([ | ||
page.waitForLoadState("load"), | ||
page.evaluate((template) => { | ||
window.StackBlitzSDK.openGithubProject( | ||
`shopware/frontends/tree/main/templates/${template}`, | ||
{ | ||
clickToLoad: false, | ||
newWindow: false, | ||
origin: "https://stackblitz.com/", | ||
}, | ||
); | ||
}, template), | ||
]); | ||
await page.waitForRequest( | ||
"https://demo-frontends.shopware.store/store-api/context", | ||
), | ||
await expect(page).toHaveURL( | ||
`https://stackblitz.com/github/shopware/frontends/tree/main/templates/${template}?file=README.md`, | ||
); | ||
|
||
page.on("response", (response) => { | ||
expect(response.status()).toBe(200); | ||
page.on("response", (response) => { | ||
expect(response.status()).not.toBe(500); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.