Forward cli serve settings and make it easier to provide platform config to fullstack (#2521)

* assert that launch never returns for better compiler errors

* fix static generation launch function

* fix web renderer

* pass context providers into server functions

* add an example for FromContext

* clean up DioxusRouterExt

* fix server function context

* fix fullstack desktop example

* forward CLI serve settings to fullstack

* re-export serve config at the root of fullstack

* forward env directly instead of using a guard

* just set the port in the CLI for fullstack playwright tests

* fix fullstack dioxus-cli-config feature

* fix launch server merge conflicts

* fix fullstack launch context

* run web playwright tests on 9999 to avoid port conflicts with other local servers

* fix playwright tests
This commit is contained in:
Evan Almloff authored and GitHub committed 2024-06-28 14:40:41 -07:00
1 parent 9dd4427cb5
commit ffa36a67c3
18 files changed
+403 -244

No files matched your search

@@ -8,11 +8,7 @@
use dioxus::prelude::*;
fn main() {
LaunchBuilder::fullstack()
.with_cfg(ssr! {
dioxus::fullstack::Config::default().addr(std::net::SocketAddr::from(([127, 0, 0, 1], 3333)))
})
.launch(app);
LaunchBuilder::fullstack().launch(app);
}
fn app() -> Element {
@@ -82,15 +82,17 @@ module.exports = defineConfig({
},
{
cwd: path.join(process.cwd(), "web"),
command: "cargo run --package dioxus-cli --release -- serve",
port: 8080,
command:
'cargo run --package dioxus-cli --release -- serve --addr "127.0.0.1" --port 9999',
port: 9999,
timeout: 20 * 60 * 1000,
reuseExistingServer: !process.env.CI,
stdout: "pipe",
},
{
cwd: path.join(process.cwd(), 'fullstack'),
command: 'cargo run --package dioxus-cli --release -- serve --platform fullstack',
cwd: path.join(process.cwd(), "fullstack"),
command:
'cargo run --package dioxus-cli --release -- serve --platform fullstack --addr "127.0.0.1" --port 3333',
port: 3333,
timeout: 20 * 60 * 1000,
reuseExistingServer: !process.env.CI,
+45 -46
View File
@@ -1,94 +1,93 @@
// @ts-check
const { test, expect, defineConfig } = require('@playwright/test');
const { test, expect, defineConfig } = require("@playwright/test");
test('button click', async ({ page }) => {
await page.goto('http://localhost:8080');
test("button click", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the counter text.
const main = page.locator('#main');
await expect(main).toContainText('hello axum! 0');
const main = page.locator("#main");
await expect(main).toContainText("hello axum! 0");
// Click the increment button.
let button = page.locator('button.increment-button');
let button = page.locator("button.increment-button");
await button.click();
// Expect the page to contain the updated counter text.
await expect(main).toContainText('hello axum! 1');
await expect(main).toContainText("hello axum! 1");
});
test('svg', async ({ page }) => {
await page.goto('http://localhost:8080');
test("svg", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the svg.
const svg = page.locator('svg');
const svg = page.locator("svg");
// Expect the svg to contain the circle.
const circle = svg.locator('circle');
await expect(circle).toHaveAttribute('cx', '50');
await expect(circle).toHaveAttribute('cy', '50');
await expect(circle).toHaveAttribute('r', '40');
await expect(circle).toHaveAttribute('stroke', 'green');
await expect(circle).toHaveAttribute('fill', 'yellow');
const circle = svg.locator("circle");
await expect(circle).toHaveAttribute("cx", "50");
await expect(circle).toHaveAttribute("cy", "50");
await expect(circle).toHaveAttribute("r", "40");
await expect(circle).toHaveAttribute("stroke", "green");
await expect(circle).toHaveAttribute("fill", "yellow");
});
test('raw attribute', async ({ page }) => {
await page.goto('http://localhost:8080');
test("raw attribute", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the div with the raw attribute.
const div = page.locator('div.raw-attribute-div');
await expect(div).toHaveAttribute('raw-attribute', 'raw-attribute-value');
const div = page.locator("div.raw-attribute-div");
await expect(div).toHaveAttribute("raw-attribute", "raw-attribute-value");
});
test('hidden attribute', async ({ page }) => {
await page.goto('http://localhost:8080');
test("hidden attribute", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the div with the hidden attribute.
const div = page.locator('div.hidden-attribute-div');
await expect(div).toHaveAttribute('hidden', 'true');
const div = page.locator("div.hidden-attribute-div");
await expect(div).toHaveAttribute("hidden", "true");
});
test('dangerous inner html', async ({ page }) => {
await page.goto('http://localhost:8080');
test("dangerous inner html", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the div with the dangerous inner html.
const div = page.locator('div.dangerous-inner-html-div');
await expect(div).toContainText('hello dangerous inner html');
const div = page.locator("div.dangerous-inner-html-div");
await expect(div).toContainText("hello dangerous inner html");
});
test('input value', async ({ page }) => {
await page.goto('http://localhost:8080');
test("input value", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the input with the value.
const input = page.locator('input');
await expect(input).toHaveValue('hello input');
const input = page.locator("input");
await expect(input).toHaveValue("hello input");
});
test('style', async ({ page }) => {
await page.goto('http://localhost:8080');
test("style", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the div with the style.
const div = page.locator('div.style-div');
await expect(div).toHaveText('colored text');
await expect(div).toHaveCSS('color', 'rgb(255, 0, 0)');
const div = page.locator("div.style-div");
await expect(div).toHaveText("colored text");
await expect(div).toHaveCSS("color", "rgb(255, 0, 0)");
});
test('eval', async ({ page }) => {
await page.goto('http://localhost:8080');
test("eval", async ({ page }) => {
await page.goto("http://localhost:9999");
// Expect the page to contain the div with the eval and have no text.
const div = page.locator('div.eval-result');
await expect(div).toHaveText('');
const div = page.locator("div.eval-result");
await expect(div).toHaveText("");
// Click the button to run the eval.
let button = page.locator('button.eval-button');
let button = page.locator("button.eval-button");
await button.click();
// Check that the title changed.
await expect(page).toHaveTitle('Hello from Dioxus Eval!');
await expect(page).toHaveTitle("Hello from Dioxus Eval!");
// Check that the div has the eval value.
await expect(div).toHaveText('returned eval value');
await expect(div).toHaveText("returned eval value");
});
// Shutdown the li
// Shutdown the li