Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci-examples-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- waspello
- waspleau
- websockets-realtime-voting
- ask-the-documents

steps:
- uses: "actions/checkout@v5"
Expand Down
58 changes: 58 additions & 0 deletions examples/ask-the-documents/e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { defineConfig, devices } from "@playwright/test";

const WASP_RUN_MODE = process.env.WASP_RUN_MODE ?? "dev";
const WASP_CLI_CMD = process.env.WASP_CLI_CMD ?? "wasp-cli";

/**
* 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: process.env.CI ? "dot" : "list",
/* 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: "http://localhost:3000",

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",
},

projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
/* Test against mobile viewports. */
{
name: "Mobile Chrome",
use: { ...devices["Pixel 5"] },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: `run-wasp-app ${WASP_RUN_MODE} --path-to-app=../ --wasp-cli-cmd=${WASP_CLI_CMD} --db-image pgvector/pgvector:pg17`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice


// Wait for the backend to start
url: "http://localhost:3001",
reuseExistingServer: !process.env.CI,
timeout: 180 * 1000,
gracefulShutdown: { signal: "SIGTERM", timeout: 500 },
},
});
11 changes: 11 additions & 0 deletions examples/ask-the-documents/e2e-tests/tests/simple.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, test } from "@playwright/test";

test.describe("loads successfully", () => {
test.describe.configure({ mode: "serial" });

test("shows the search bar", async ({ page }) => {
await page.goto("/");
await page.waitForSelector("input[type='search']");
await expect(page.locator("input[type='search']")).toBeVisible();
});
Comment on lines +6 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would need to happen for us to be able to test:

  • logging in with Google
  • scraping some website
  • search

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need either some framework-level way of mocking external services, or come up with a solution to MitM the HTTP connections.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, it's either mock the whole Google flow or actually log in which might be problematic due to some anti-bot measures. Hm, so MitM sounds the most reliable way of it to me 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's encode this in a existing or a new issue and link back to this file / PR.

I think this is enough for now 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});
6 changes: 0 additions & 6 deletions examples/ask-the-documents/env.server.example

This file was deleted.

127 changes: 127 additions & 0 deletions examples/ask-the-documents/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion examples/ask-the-documents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"type": "module",
"scripts": {
"env:pull": "npx dotenv-vault@latest pull development .env.server",
"env:push": "npx dotenv-vault@latest push development .env.server"
"env:push": "npx dotenv-vault@latest push development .env.server",
"test": "DEBUG=pw:webserver playwright test --config e2e-tests/"
},
"dependencies": {
"@heroui/react": "2.7.5",
Expand All @@ -22,7 +23,9 @@
"wasp": "file:.wasp/out/sdk/wasp"
},
"devDependencies": {
"@playwright/test": "1.51.1",
"@types/react": "^18.0.37",
"@wasp.sh/wasp-app-runner": "^0.0.9",
"prisma": "5.19.1",
"typescript": "5.8.2",
"vite": "^7.0.6"
Expand Down
1 change: 1 addition & 0 deletions waspc/run
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function run_examples_e2e_tests() {
"examples/waspello"
"examples/waspleau"
"examples/websockets-realtime-voting"
"examples/ask-the-documents"
)

for path in "${paths[@]}"; do
Expand Down