-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ci/lockfile
- Loading branch information
Showing
27 changed files
with
213 additions
and
123 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 | ||
--- | ||
|
||
Ensure the before-hydration scripts are built |
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 @@ | ||
--- | ||
'@astrojs/image': patch | ||
--- | ||
|
||
Removes Node's `fileURLToPath` dependency in the production SSR endpoint |
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 | ||
--- | ||
|
||
Adds warnings for legacy markdown behavior |
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 | ||
--- | ||
|
||
Added missing "loading" attribute to IFrameHTMLAttributes |
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
18 changes: 18 additions & 0 deletions
18
packages/astro/e2e/fixtures/lit-component/src/pages/solo.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 MyCounter from '../components/Counter.js'; | ||
const someProps = { | ||
count: 0, | ||
}; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<MyCounter {...someProps} client:idle> | ||
<h1>Hello, client:idle!</h1> | ||
</MyCounter> | ||
</body> | ||
</html> |
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 |
---|---|---|
@@ -1,100 +1,138 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory } from './test-utils.js'; | ||
|
||
const test = testFactory({ root: './fixtures/lit-component/' }); | ||
|
||
let devServer; | ||
|
||
test.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await devServer.stop(); | ||
const test = testFactory({ | ||
root: './fixtures/lit-component/', | ||
}); | ||
|
||
// TODO: configure playwright to handle web component APIs | ||
// https://github.com/microsoft/playwright/issues/14241 | ||
test.describe.skip('Lit components', () => { | ||
test('client:idle', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
test.describe('Lit components', () => { | ||
test.beforeEach(() => { | ||
delete globalThis.window; | ||
}); | ||
|
||
const counter = page.locator('#client-idle'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
test.describe('Development', () => { | ||
let devServer; | ||
const t = test.extend({}); | ||
|
||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
t.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
t.afterEach(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
t('client:idle', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
test('client:load', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
const counter = page.locator('#client-idle'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
await expect(counter).toHaveCount(1); | ||
|
||
const counter = page.locator('#client-load'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
|
||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
|
||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
|
||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
t('client:load', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
test('client:visible', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
const counter = page.locator('#client-load'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
|
||
// Make sure the component is on screen to trigger hydration | ||
const counter = page.locator('#client-visible'); | ||
await counter.scrollIntoViewIfNeeded(); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
|
||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
|
||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
|
||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
t('client:visible', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
// Make sure the component is on screen to trigger hydration | ||
const counter = page.locator('#client-visible'); | ||
await counter.scrollIntoViewIfNeeded(); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
|
||
test('client:media', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/media')); | ||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
|
||
const counter = page.locator('#client-media'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
|
||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
|
||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
t('client:media', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/media')); | ||
|
||
await expect(count, 'component not hydrated yet').toHaveText('Count: 0'); | ||
const counter = page.locator('#client-media'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
|
||
// Reset the viewport to hydrate the component (max-width: 50rem) | ||
await page.setViewportSize({ width: 414, height: 1124 }); | ||
const count = counter.locator('p'); | ||
await expect(count, 'initial count is 0').toHaveText('Count: 0'); | ||
|
||
await inc.click(); | ||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
const inc = counter.locator('button'); | ||
await inc.click(); | ||
|
||
await expect(count, 'component not hydrated yet').toHaveText('Count: 0'); | ||
|
||
// Reset the viewport to hydrate the component (max-width: 50rem) | ||
await page.setViewportSize({ width: 414, height: 1124 }); | ||
|
||
await inc.click(); | ||
await expect(count, 'count incremented by 1').toHaveText('Count: 1'); | ||
}); | ||
|
||
t.skip('HMR', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
|
||
const counter = page.locator('#client-idle'); | ||
const label = counter.locator('h1'); | ||
|
||
await astro.editFile('./src/pages/index.astro', (original) => | ||
original.replace('Hello, client:idle!', 'Hello, updated client:idle!') | ||
); | ||
|
||
await expect(label, 'slot text updated').toHaveText('Hello, updated client:idle!'); | ||
await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); | ||
}); | ||
}); | ||
|
||
test('HMR', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/')); | ||
test.describe('Production', () => { | ||
let previewServer; | ||
const t = test.extend({}); | ||
|
||
t.beforeAll(async ({ astro }) => { | ||
// Playwright's Node version doesn't have these functions, so stub them. | ||
process.stdout.clearLine = () => {}; | ||
process.stdout.cursorTo = () => {}; | ||
await astro.build(); | ||
}); | ||
|
||
t.beforeEach(async ({ astro }) => { | ||
previewServer = await astro.preview(); | ||
}); | ||
|
||
const counter = page.locator('#client-idle'); | ||
const label = counter.locator('h1'); | ||
t.afterEach(async () => { | ||
await previewServer.stop(); | ||
}); | ||
|
||
await astro.editFile('./src/pages/index.astro', (original) => | ||
original.replace('Hello, client:idle!', 'Hello, updated client:idle!') | ||
); | ||
t('Only one component in prod', async ({ page, astro }) => { | ||
await page.goto(astro.resolveUrl('/solo')); | ||
|
||
await expect(label, 'slot text updated').toHaveText('Hello, updated client:idle!'); | ||
await expect(counter, 'component styles persisted').toHaveCSS('display', 'grid'); | ||
const counter = page.locator('my-counter'); | ||
await expect(counter, 'component is visible').toBeVisible(); | ||
await expect(counter, 'there is only one counter').toHaveCount(1); | ||
}); | ||
}); | ||
}); |
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
Oops, something went wrong.