Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add component hydration in .md E2E tests, refactor #3610

Merged
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
5 changes: 5 additions & 0 deletions .changeset/hungry-ravens-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Add component hydration in Markdown E2E tests
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h } from 'preact';

export default function({ id }) {
return <div id={id}>Preact client:only component</div>
return <div id={id}>Framework client:only component</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const someProps = {
---

<html>
<head>
<!-- Head Stuff -->
</head>
<body>
<head>
<!-- Head Stuff -->
</head>
<body>
<Counter id="server-only" {...someProps}>
<h1>Hello, server!</h1>
</Counter>
Expand All @@ -24,14 +24,14 @@ const someProps = {
<h1>Hello, client:load!</h1>
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
<Counter id="client-visible" {...someProps} client:visible>
<h1>Hello, client:visible!</h1>
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
<h1>Hello, client:media!</h1>
</Counter>

<PreactComponent id="client-only" client:only="preact" />
</body>
</body>
</html>
31 changes: 31 additions & 0 deletions packages/astro/e2e/fixtures/preact-component/src/pages/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
setup: |
import Counter from '../components/Counter.jsx';
import PreactComponent from '../components/JSXComponent.jsx';

const someProps = {
count: 0,
};
---

<Counter id="server-only" {...someProps}>
# Hello, server!
</Counter>

<Counter id="client-idle" {...someProps} client:idle>
# Hello, client:idle!
</Counter>

<Counter id="client-load" {...someProps} client:load>
# Hello, client:load!
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
# Hello, client:visible!
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
# Hello, client:media!
</Counter>

<PreactComponent id="client-only" client:only="preact" />
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';

export default function({ id }) {
return <div id={id}>React client:only component</div>
return <div id={id}>Framework client:only component</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ const someProps = {
---

<html>
<head>
<!-- Head Stuff -->
</head>
<body>
<head>
<!-- Head Stuff -->
</head>
<body>
<Counter id="server-only" {...someProps}>
<h1>Hello, server!</h1>
</Counter>
Expand All @@ -24,7 +24,7 @@ const someProps = {
<h1>Hello, client:load!</h1>
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
<Counter id="client-visible" {...someProps} client:visible>
<h1>Hello, client:visible!</h1>
</Counter>

Expand All @@ -33,5 +33,5 @@ const someProps = {
</Counter>

<ReactComponent id="client-only" client:only="react" />
</body>
</body>
</html>
31 changes: 31 additions & 0 deletions packages/astro/e2e/fixtures/react-component/src/pages/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
setup: |
import Counter from '../components/Counter.jsx';
import ReactComponent from '../components/JSXComponent.jsx';

const someProps = {
count: 0,
};
---

<Counter id="server-only" {...someProps}>
# Hello, server!
</Counter>

<Counter id="client-idle" {...someProps} client:idle>
# Hello, client:idle!
</Counter>

<Counter id="client-load" {...someProps} client:load>
# Hello, client:load!
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
# Hello, client:visible!
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
# Hello, client:media!
</Counter>

<ReactComponent id="client-only" client:only="react" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default function SolidComponent({ id }) {
return (
<div id={id}>Framework client:only component</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
---
import Counter from '../components/Counter.jsx';
import SolidComponent from '../components/SolidComponent.jsx';

const someProps = {
count: 0,
};
---

<html>
<head>
<!-- Head Stuff -->
</head>
<body>
<head>
<!-- Head Stuff -->
</head>
<body>
<Counter id="server-only" {...someProps}>
<h1>Hello, server!</h1>
</Counter>
Expand All @@ -23,12 +24,14 @@ const someProps = {
<h1>Hello, client:load!</h1>
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
<Counter id="client-visible" {...someProps} client:visible>
<h1>Hello, client:visible!</h1>
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
<h1>Hello, client:media!</h1>
</Counter>
</body>

<SolidComponent id="client-only" client:only="solid" />
</body>
</html>
31 changes: 31 additions & 0 deletions packages/astro/e2e/fixtures/solid-component/src/pages/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
setup: |
import Counter from '../components/Counter.jsx';
import SolidComponent from '../components/SolidComponent.jsx';

const someProps = {
count: 0,
};
---

<Counter id="server-only" {...someProps}>
# Hello, server!
</Counter>

<Counter id="client-idle" {...someProps} client:idle>
# Hello, client:idle!
</Counter>

<Counter id="client-load" {...someProps} client:load>
# Hello, client:load!
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
# Hello, client:visible!
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
# Hello, client:media!
</Counter>

<SolidComponent id="client-only" client:only="solid" />
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
export let id: string;

let count = 0;
export let count: number = 0;

function add() {
count += 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script lang="ts">
export let id: string;
</script>

<div {id}>Framework client:only component</div>
23 changes: 13 additions & 10 deletions packages/astro/e2e/fixtures/svelte-component/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
---
import Counter from '../components/Counter.svelte';
import SvelteComponent from '../components/SvelteComponent.svelte';

const someProps = {
count: 0,
};
---

<html>
<head>
<!-- Head Stuff -->
</head>
<body>
<Counter id="server-only">
<head>
<!-- Head Stuff -->
</head>
<body>
<Counter id="server-only" {...someProps}>
<h1>Hello, server!</h1>
</Counter>

<Counter id="client-idle" client:idle>
<Counter id="client-idle" {...someProps} client:idle>
<h1>Hello, client:idle!</h1>
</Counter>

<Counter id="client-load" client:load>
<Counter id="client-load" {...someProps} client:load>
<h1>Hello, client:load!</h1>
</Counter>

<Counter id="client-visible" client:visible>
<Counter id="client-visible" {...someProps} client:visible>
<h1>Hello, client:visible!</h1>
</Counter>

<Counter id="client-media" client:media="(max-width: 50rem)">
<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
<h1>Hello, client:media!</h1>
</Counter>
</body>

<SvelteComponent id="client-only" client:only="svelte" />
</body>
</html>
31 changes: 31 additions & 0 deletions packages/astro/e2e/fixtures/svelte-component/src/pages/markdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
setup: |
import Counter from '../components/Counter.svelte';
import SvelteComponent from '../components/SvelteComponent.svelte';

const someProps = {
count: 0,
};
---

<Counter id="server-only" {...someProps}>
# Hello, server!
</Counter>

<Counter id="client-idle" {...someProps} client:idle>
# Hello, client:idle!
</Counter>

<Counter id="client-load" {...someProps} client:load>
# Hello, client:load!
</Counter>

<Counter id="client-visible" {...someProps} client:visible>
# Hello, client:visible!
</Counter>

<Counter id="client-media" {...someProps} client:media="(max-width: 50em)">
# Hello, client:media!
</Counter>

<SvelteComponent id="client-only" client:only="svelte" />
Loading