forked from illacloud/illa-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
156 additions
and
120 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
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 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
/test-results/ | ||
/playwright-report/ | ||
/playwright/.cache/ | ||
.env.local | ||
.env.*.local | ||
/.auth |
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,24 @@ | ||
{ | ||
"name": "playwright", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "playwright test", | ||
"test:development": "cross-env ILLA_APP_ENV=development playwright test", | ||
"codegen": "playwright codegen https://localhost:3000/bbbbb/dashboard/apps --load-storage=.auth/user.json --ignore-https-errors", | ||
"test:auth": "cross-env ILLA_APP_ENV=development playwright test auth.setup.ts" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@illa-public/illa-net": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.38.1", | ||
"@types/node": "^18.14.4", | ||
"cross-env": "^7.0.3", | ||
"dotenv": "^16.3.1" | ||
} | ||
} |
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,60 @@ | ||
import { defineConfig, devices } from "@playwright/test" | ||
import dotenv from "dotenv" | ||
|
||
const modeExt = process.env.ILLA_APP_ENV || "development" | ||
dotenv.config({ path: `.env.${modeExt}.local`, override: true }) | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./tests", | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: "html", | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: process.env.ILLA_BUILDER_URL, | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: "setup", | ||
testMatch: /.*\.setup\.ts/, | ||
use: { | ||
contextOptions: { | ||
ignoreHTTPSErrors: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "chromium", | ||
use: { | ||
...devices["Desktop Chrome"], | ||
storageState: ".auth/user.json", | ||
contextOptions: { | ||
ignoreHTTPSErrors: true, | ||
}, | ||
}, | ||
dependencies: ["setup"], | ||
}, | ||
], | ||
}) |
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,18 @@ | ||
import { notNeedAuthCloudRequest } from "@illa-public/illa-net" | ||
import { test as setup } from "@playwright/test" | ||
|
||
const authFile = ".auth/user.json" | ||
|
||
setup("authenticate", async ({ page }) => { | ||
const result = await notNeedAuthCloudRequest({ | ||
method: "POST", | ||
url: "/auth/signin", | ||
data: { | ||
email: process.env.USER_EMAIL, | ||
password: process.env.USER_PASSWORD, | ||
}, | ||
}) | ||
const token = result.headers["illa-token"] | ||
await page.goto(`/${process.env.TEAM_IDENTITY}/dashboard/apps?token=${token}`) | ||
await page.context().storageState({ path: authFile }) | ||
}) |
Oops, something went wrong.