-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Error recovery test and more (#3388)
* Add test to verify errors are recovered from * Fix nested style components not be added in dev on initial load * Adds a changeset
- Loading branch information
Showing
14 changed files
with
275 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes nested style bug causing initial styles to be off |
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,8 @@ | ||
{ | ||
"name": "@test/nested-style-bug-e22e", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"astro": "workspace:*" | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
packages/astro/e2e/fixtures/nested-styles/src/components/Card.astro
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,75 @@ | ||
--- | ||
export interface Props { | ||
title: string, | ||
body: string, | ||
href: string, | ||
} | ||
const {href, title, body} = Astro.props; | ||
--- | ||
<li class="link-card"> | ||
<a href={href}> | ||
<h2> | ||
{title} | ||
<span>→</span> | ||
</h2> | ||
<p> | ||
{body} | ||
<slot name="icon" /> | ||
</p> | ||
</a> | ||
</li> | ||
<style> | ||
|
||
:root { | ||
--link-gradient: linear-gradient(45deg, #4F39FA, #DA62C4 30%, var(--color-border) 60%); | ||
} | ||
|
||
.link-card { | ||
list-style: none; | ||
display: flex; | ||
padding: 0.15rem; | ||
background-image: var(--link-gradient); | ||
background-size: 400%; | ||
border-radius: 0.5rem; | ||
background-position: 100%; | ||
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1); | ||
} | ||
|
||
.link-card > a { | ||
width: 100%; | ||
text-decoration: none; | ||
line-height: 1.4; | ||
padding: 1em 1.3em; | ||
border-radius: 0.35rem; | ||
color: var(--text-color); | ||
background-color: white; | ||
opacity: 0.8; | ||
} | ||
|
||
h2 { | ||
margin: 0; | ||
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1); | ||
} | ||
|
||
p { | ||
margin-top: 0.75rem; | ||
margin-bottom: 0; | ||
} | ||
|
||
h2 span { | ||
display: inline-block; | ||
transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); | ||
} | ||
|
||
.link-card:is(:hover, :focus-within) { | ||
background-position: 0; | ||
} | ||
|
||
.link-card:is(:hover, :focus-within) h2 { | ||
color: #4F39FA; | ||
} | ||
|
||
.link-card:is(:hover, :focus-within) h2 span { | ||
transform: translateX(2px); | ||
} | ||
</style> |
24 changes: 24 additions & 0 deletions
24
packages/astro/e2e/fixtures/nested-styles/src/components/partials/Header/index.astro
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,24 @@ | ||
<style> | ||
header { | ||
display: flex; | ||
position: relative; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 20px; | ||
background: darkblue; | ||
color: white; | ||
} | ||
|
||
.title { | ||
display: block; | ||
width: 180px; | ||
} | ||
</style> | ||
|
||
|
||
<header> | ||
<a class="title" href="/"> | ||
<span>My Website</span> | ||
</a> | ||
</header> | ||
|
18 changes: 18 additions & 0 deletions
18
packages/astro/e2e/fixtures/nested-styles/src/components/partials/Layout/index.astro
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,18 @@ | ||
--- | ||
import Header from '../Header/index.astro' | ||
import '../../../styles/global.css' | ||
--- | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="x-ua-compatible" content="ie=edge" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no" /> | ||
</head> | ||
<body> | ||
<Header /> | ||
<main> | ||
<slot /> | ||
</main> | ||
</body> | ||
</html> |
13 changes: 13 additions & 0 deletions
13
packages/astro/e2e/fixtures/nested-styles/src/pages/index.astro
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,13 @@ | ||
--- | ||
import Layout from '../components/partials/Layout/index.astro'; | ||
const content = { | ||
title: 'My Website' | ||
} | ||
--- | ||
|
||
<Layout content={content}> | ||
<h1 class="title">My Website</h1> | ||
<p>This is my website</p> | ||
</Layout> |
19 changes: 19 additions & 0 deletions
19
packages/astro/e2e/fixtures/nested-styles/src/styles/global.css
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,19 @@ | ||
body { | ||
font-family: sans-serif; | ||
font-size: 16px; | ||
font-weight: 300; | ||
line-height: 1.12; | ||
} | ||
|
||
a { | ||
color: inherit; | ||
text-decoration: underline; | ||
} | ||
|
||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5 { | ||
font-weight: 700; | ||
} |
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,32 @@ | ||
import { test as base, expect } from '@playwright/test'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
const test = base.extend({ | ||
astro: async ({}, use) => { | ||
const fixture = await loadFixture({ root: './fixtures/nested-styles/' }); | ||
await use(fixture); | ||
}, | ||
}); | ||
|
||
let devServer; | ||
|
||
test.beforeAll(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterAll(async ({ astro }) => { | ||
await devServer.stop(); | ||
}); | ||
|
||
test('Loading styles that are nested', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
await test.step('header', async () => { | ||
const header = page.locator('header'); | ||
|
||
await expect(header, 'should have background color').toHaveCSS( | ||
'background-color', | ||
'rgb(0, 0, 139)' // darkblue | ||
); | ||
}); | ||
}); |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.