-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2210 from beekeeper-studio/e2e-tests
World's first Beekeeper Studio UI test
- Loading branch information
Showing
8 changed files
with
495 additions
and
119 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 |
---|---|---|
|
@@ -20,3 +20,4 @@ yarn-error.log | |
.env | ||
.instant/ | ||
cli.zip | ||
apps/studio/test-results |
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,12 @@ | ||
import { test } from "@playwright/test"; | ||
import testWithPlaywright from "./testWithPlaywright"; | ||
|
||
// TODO maybe remove this after we get a faster compiler? | ||
test.setTimeout(180000); | ||
|
||
test("example test", async () => { | ||
const { app, stop } = await testWithPlaywright(); | ||
const page = await app.firstWindow(); | ||
await page.getByLabel("Connection Type").selectOption("SQLite"); | ||
await stop(); | ||
}); |
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,77 @@ | ||
// "forked" from https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/v3/lib/testWithPlaywright.js | ||
// Distributed under MIT license: https://github.com/nklayman/vue-cli-plugin-electron-builder/blob/master/LICENSE | ||
|
||
import { _electron as electron, ElectronApplication } from "@playwright/test"; | ||
import { execa } from "execa"; | ||
|
||
export default function testWithPlaywright(): Promise<{ | ||
stdout: string; | ||
url: string; | ||
app: ElectronApplication; | ||
stop: () => Promise<void>; | ||
}> { | ||
return new Promise((resolve, reject) => { | ||
let log = ""; | ||
let outputDir = ""; | ||
// Launch electron:serve in headless mode | ||
const child = execa( | ||
require.resolve("@vue/cli-service/bin/vue-cli-service"), | ||
["electron:serve", "--headless", "--mode", "production"], | ||
{ | ||
extendEnv: false, | ||
env: { | ||
...process.env, | ||
// Extending NODE_ENV causes warnings with build | ||
NODE_ENV: undefined, | ||
}, | ||
} | ||
); | ||
|
||
// Exit if electron:serve throws an error | ||
child.on("error", (err: any) => { | ||
reject(err); | ||
}); | ||
|
||
child.stdout.on("data", async (data) => { | ||
data = data.toString(); | ||
console.log(data); | ||
log += data; | ||
const urlMatch = data.match( | ||
/\$WEBPACK_DEV_SERVER_URL=https?:\/\/[^/]+\/?/ | ||
); | ||
const outputDirMatch = data.match(/\$outputDir=\b.*\b/); | ||
if (outputDirMatch) { | ||
// Record output dir | ||
outputDir = outputDirMatch[0].split("=")[1]; | ||
} | ||
if (urlMatch) { | ||
// Record url and launch app | ||
const url = urlMatch[0].split("=")[1]; | ||
let app: ElectronApplication; | ||
// Launch app with playwright | ||
app = await electron.launch({ | ||
args: [`${outputDir}`], | ||
env: { | ||
...process.env, | ||
IS_TEST: "true", | ||
WEBPACK_DEV_SERVER_URL: url, | ||
TEST_MODE: "true", | ||
DEBUG: "", | ||
}, | ||
}); | ||
resolve({ | ||
stdout: log, | ||
url, | ||
app, | ||
stop: () => { | ||
// Exit serve process | ||
child.stdin.write("close"); | ||
child.kill("SIGKILL"); | ||
// Close playwright | ||
return app.close(); | ||
}, | ||
}); | ||
} | ||
}); | ||
}); | ||
} |
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
Oops, something went wrong.
3f1c72e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Published on https://docs.beekeeperstudio.io as production
🚀 Deployed on https://664e9e6116ea9a7f36cd0e4c--bks-docs.netlify.app