Skip to content

Commit ab5de20

Browse files
VarixoMichałshairez
authored
Merge commit from fork
* fix: catch error from invalid QRL * added an e2e test for express * updated express test * remove rethrowing an error form qrl and add express integration test to the CI command --------- Co-authored-by: Michał <[email protected]> Co-authored-by: Shai <[email protected]>
1 parent 7276ed6 commit ab5de20

File tree

23 files changed

+556
-9
lines changed

23 files changed

+556
-9
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ jobs:
720720
- name: Playwright E2E Tests
721721
run: pnpm run test.e2e.${{ matrix.settings.browser }} --timeout 60000 --retries 7 --workers 1
722722

723+
- name: Playwright E2E Integration Tests
724+
run: pnpm run test.e2e.integrations --timeout 60000 --retries 7 --workers 1
725+
723726
- name: Validate Create Qwik Cli
724727
if: matrix.settings.host != 'windows-latest'
725728
run: pnpm cli.validate

e2e/adapters-e2e/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
playwright-report
2+
dist
3+
logs
4+
server
5+
tmp
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { nodeServerAdapter } from '@builder.io/qwik-city/adapters/node-server/vite';
2+
import { extendConfig } from '@builder.io/qwik-city/vite';
3+
import baseConfig from '../../vite.config';
4+
5+
export default extendConfig(baseConfig, () => {
6+
return {
7+
build: {
8+
ssr: true,
9+
rollupOptions: {
10+
input: ['src/entry.express.tsx', '@qwik-city-plan'],
11+
},
12+
},
13+
plugins: [nodeServerAdapter({ name: 'express' })],
14+
};
15+
});

e2e/adapters-e2e/package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "qwik-buffering-test-app",
3+
"description": "Qwik buffering test app",
4+
"engines": {
5+
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
6+
},
7+
"private": true,
8+
"type": "module",
9+
"scripts": {
10+
"build": "qwik build",
11+
"build.client": "vite build",
12+
"build.preview": "vite build --ssr src/entry.preview.tsx",
13+
"build.server": "vite build -c adapters/express/vite.config.ts",
14+
"build.types": "tsc --incremental --noEmit",
15+
"deploy": "vercel deploy",
16+
"dev": "vite --mode ssr",
17+
"dev.debug": "node --inspect-brk ./node_modules/vite/bin/vite.js --mode ssr --force",
18+
"fmt": "prettier --write .",
19+
"fmt.check": "prettier --check .",
20+
"lint": "eslint \"src/**/*.ts*\"",
21+
"preview": "qwik build preview && vite preview --open",
22+
"express": "pnpm build && pnpm serve",
23+
"serve": "node server/entry.express",
24+
"start": "vite --open --mode ssr",
25+
"qwik": "qwik",
26+
"test": "playwright test",
27+
"test.ui": "playwright test --ui",
28+
"test.debug": "playwright test --debug"
29+
}
30+
}

e2e/adapters-e2e/playwright.config.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/** See https://playwright.dev/docs/test-configuration. */
4+
export default defineConfig({
5+
testDir: './tests',
6+
fullyParallel: true,
7+
forbidOnly: !!process.env.CI,
8+
retries: process.env.CI ? 2 : 0,
9+
workers: process.env.CI ? 1 : undefined,
10+
reporter: 'line',
11+
12+
use: {
13+
baseURL: 'http://localhost:3000',
14+
// trace: 'on-first-retry',
15+
// screenshot: 'only-on-failure',
16+
17+
// Increase timeouts for service worker operations
18+
actionTimeout: 10000,
19+
navigationTimeout: 10000,
20+
},
21+
22+
// Increase global timeout for service worker tests
23+
timeout: 30000,
24+
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: {
29+
...devices['Desktop Chrome'],
30+
},
31+
},
32+
// {
33+
// name: 'firefox',
34+
// use: { ...devices['Desktop Firefox'] },
35+
// },
36+
// {
37+
// name: 'webkit',
38+
// use: { ...devices['Desktop Safari'] },
39+
// },
40+
],
41+
42+
webServer: {
43+
command: 'npm run express',
44+
port: 3000,
45+
stdout: 'pipe',
46+
reuseExistingServer: !process.env.CI,
47+
},
48+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { component$, useSignal } from '@builder.io/qwik';
2+
3+
// We need to extract the component to see the bug on 1.5.7
4+
export default component$(() => {
5+
const isOpenSig = useSignal(false);
6+
return (
7+
<>
8+
<button
9+
onClick$={() => {
10+
return (isOpenSig.value = !isOpenSig.value);
11+
}}
12+
>
13+
click me
14+
</button>
15+
{isOpenSig.value && <div data-testid="hi">Hi 👋</div>}
16+
</>
17+
);
18+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { useDocumentHead, useLocation } from '@builder.io/qwik-city';
3+
4+
export const RouterHead = component$(() => {
5+
const head = useDocumentHead();
6+
const loc = useLocation();
7+
8+
return (
9+
<>
10+
<title>{head.title}</title>
11+
12+
<link rel="canonical" href={loc.url.href} />
13+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
14+
15+
{head.meta.map((m) => (
16+
<meta key={m.key} {...m} />
17+
))}
18+
19+
{head.links.map((l) => (
20+
<link key={l.key} {...l} />
21+
))}
22+
</>
23+
);
24+
});

e2e/adapters-e2e/src/entry.dev.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* WHAT IS THIS FILE?
3+
*
4+
* Development entry point using only client-side modules:
5+
* - Do not use this mode in production!
6+
* - No SSR
7+
* - No portion of the application is pre-rendered on the server.
8+
* - All of the application is running eagerly in the browser.
9+
* - More code is transferred to the browser than in SSR mode.
10+
* - Optimizer/Serialization/Deserialization code is not exercised!
11+
*/
12+
import { render, type RenderOptions } from '@builder.io/qwik';
13+
import Root from './root';
14+
15+
export default function (opts: RenderOptions) {
16+
return render(document, <Root />, opts);
17+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* WHAT IS THIS FILE?
3+
*
4+
* It's the entry point for the Express HTTP server when building for production.
5+
*
6+
* Learn more about Node.js server integrations here:
7+
* - https://qwik.dev/docs/deployments/node/
8+
*
9+
*/
10+
import { createQwikCity, type PlatformNode } from '@builder.io/qwik-city/middleware/node';
11+
import 'dotenv/config';
12+
import qwikCityPlan from '@qwik-city-plan';
13+
import { manifest } from '@qwik-client-manifest';
14+
import render from './entry.ssr';
15+
import express from 'express';
16+
import { fileURLToPath } from 'node:url';
17+
import { join } from 'node:path';
18+
19+
declare global {
20+
interface QwikCityPlatform extends PlatformNode {}
21+
}
22+
23+
// Directories where the static assets are located
24+
const distDir = join(fileURLToPath(import.meta.url), '..', '..', 'dist');
25+
const buildDir = join(distDir, 'build');
26+
27+
// Allow for dynamic port
28+
const PORT = process.env.PORT ?? 3000;
29+
30+
// Create the Qwik City Node middleware
31+
const { router, notFound } = createQwikCity({
32+
render,
33+
qwikCityPlan,
34+
manifest,
35+
// getOrigin(req) {
36+
// // If deploying under a proxy, you may need to build the origin from the request headers
37+
// // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto
38+
// const protocol = req.headers["x-forwarded-proto"] ?? "http";
39+
// // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host
40+
// const host = req.headers["x-forwarded-host"] ?? req.headers.host;
41+
// return `${protocol}://${host}`;
42+
// }
43+
});
44+
45+
// Create the express server
46+
// https://expressjs.com/
47+
const app = express();
48+
49+
// Enable gzip compression
50+
// app.use(compression());
51+
52+
// Static asset handlers
53+
// https://expressjs.com/en/starter/static-files.html
54+
app.use(`/build`, express.static(buildDir, { immutable: true, maxAge: '1y' }));
55+
app.use(express.static(distDir, { redirect: false }));
56+
57+
// Use Qwik City's page and endpoint request handler
58+
app.use(router);
59+
60+
// Use Qwik City's 404 handler
61+
app.use(notFound);
62+
63+
// Start the express server
64+
app.listen(PORT, () => {
65+
/* eslint-disable */
66+
console.log(`Server started: http://localhost:${PORT}/`);
67+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* WHAT IS THIS FILE?
3+
*
4+
* It's the bundle entry point for `npm run preview`.
5+
* That is, serving your app built in production mode.
6+
*
7+
* Feel free to modify this file, but don't remove it!
8+
*
9+
* Learn more about Vite's preview command:
10+
* - https://vitejs.dev/config/preview-options.html#preview-options
11+
*
12+
*/
13+
import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
14+
import qwikCityPlan from '@qwik-city-plan';
15+
// make sure qwikCityPlan is imported before entry
16+
import render from './entry.ssr';
17+
18+
/** The default export is the QwikCity adapter used by Vite preview. */
19+
export default createQwikCity({ render, qwikCityPlan });

0 commit comments

Comments
 (0)