From db566106964b4876d0780ac2fde2ca8835724cca Mon Sep 17 00:00:00 2001 From: Arsh <69170106+lilnasy@users.noreply.github.com> Date: Tue, 18 Apr 2023 08:39:05 +0000 Subject: [PATCH] hack(inline stylesheets testing): duplicate fixtures Content collections reuses build data across multiple fixture.builds, even though a configuration change may have changed it. Duplicating fixtures avoids usage of the stale cache. https://cdn.discordapp.com/attachments/1039830843440504872/1097795182340092024/Screenshot_87_colored.png --- packages/astro/test/css-inline-stylesheets.js | 12 +-- .../{ => always}/package.json | 0 .../{ => always}/src/components/Button.astro | 0 .../{ => always}/src/content/en/endeavour.md | 0 .../{ => always}/src/imported.css | 0 .../{ => always}/src/layouts/Layout.astro | 0 .../{ => always}/src/pages/index.astro | 0 .../css-inline-stylesheets/auto/package.json | 8 ++ .../auto/src/components/Button.astro | 86 +++++++++++++++++++ .../auto/src/content/en/endeavour.md | 15 ++++ .../auto/src/imported.css | 15 ++++ .../auto/src/layouts/Layout.astro | 35 ++++++++ .../auto/src/pages/index.astro | 17 ++++ .../css-inline-stylesheets/never/package.json | 8 ++ .../never/src/components/Button.astro | 86 +++++++++++++++++++ .../never/src/content/en/endeavour.md | 15 ++++ .../never/src/imported.css | 15 ++++ .../never/src/layouts/Layout.astro | 35 ++++++++ .../never/src/pages/index.astro | 17 ++++ pnpm-lock.yaml | 16 +++- 20 files changed, 372 insertions(+), 8 deletions(-) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/package.json (100%) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/src/components/Button.astro (100%) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/src/content/en/endeavour.md (100%) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/src/imported.css (100%) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/src/layouts/Layout.astro (100%) rename packages/astro/test/fixtures/css-inline-stylesheets/{ => always}/src/pages/index.astro (100%) create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/package.json create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/src/components/Button.astro create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/src/content/en/endeavour.md create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/src/imported.css create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/src/layouts/Layout.astro create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/auto/src/pages/index.astro create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/package.json create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/src/components/Button.astro create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/src/content/en/endeavour.md create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/src/imported.css create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/src/layouts/Layout.astro create mode 100644 packages/astro/test/fixtures/css-inline-stylesheets/never/src/pages/index.astro diff --git a/packages/astro/test/css-inline-stylesheets.js b/packages/astro/test/css-inline-stylesheets.js index 32bcf92af66a..d4009ed85e0f 100644 --- a/packages/astro/test/css-inline-stylesheets.js +++ b/packages/astro/test/css-inline-stylesheets.js @@ -8,7 +8,7 @@ describe('Setting inlineStylesheets to never in static output', () => { before(async () => { fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/never/', output: 'static', experimental: { inlineStylesheets: 'never', @@ -41,7 +41,7 @@ describe('Setting inlineStylesheets to never in server output', () => { before(async () => { const fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/never/', output: 'server', adapter: testAdapter(), experimental: { @@ -77,7 +77,7 @@ describe('Setting inlineStylesheets to auto in static output', () => { before(async () => { fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/auto/', output: 'static', experimental: { inlineStylesheets: 'auto', @@ -117,7 +117,7 @@ describe('Setting inlineStylesheets to auto in server output', () => { before(async () => { const fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/auto/', output: 'server', adapter: testAdapter(), experimental: { @@ -161,7 +161,7 @@ describe('Setting inlineStylesheets to always in static output', () => { before(async () => { fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/always/', output: 'static', experimental: { inlineStylesheets: 'always', @@ -193,7 +193,7 @@ describe('Setting inlineStylesheets to always in server output', () => { before(async () => { const fixture = await loadFixture({ - root: './fixtures/css-inline-stylesheets/', + root: './fixtures/css-inline-stylesheets/always/', output: 'server', adapter: testAdapter(), experimental: { diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/package.json b/packages/astro/test/fixtures/css-inline-stylesheets/always/package.json similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/package.json rename to packages/astro/test/fixtures/css-inline-stylesheets/always/package.json diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/src/components/Button.astro b/packages/astro/test/fixtures/css-inline-stylesheets/always/src/components/Button.astro similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/src/components/Button.astro rename to packages/astro/test/fixtures/css-inline-stylesheets/always/src/components/Button.astro diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/src/content/en/endeavour.md b/packages/astro/test/fixtures/css-inline-stylesheets/always/src/content/en/endeavour.md similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/src/content/en/endeavour.md rename to packages/astro/test/fixtures/css-inline-stylesheets/always/src/content/en/endeavour.md diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/src/imported.css b/packages/astro/test/fixtures/css-inline-stylesheets/always/src/imported.css similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/src/imported.css rename to packages/astro/test/fixtures/css-inline-stylesheets/always/src/imported.css diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/src/layouts/Layout.astro b/packages/astro/test/fixtures/css-inline-stylesheets/always/src/layouts/Layout.astro similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/src/layouts/Layout.astro rename to packages/astro/test/fixtures/css-inline-stylesheets/always/src/layouts/Layout.astro diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/src/pages/index.astro b/packages/astro/test/fixtures/css-inline-stylesheets/always/src/pages/index.astro similarity index 100% rename from packages/astro/test/fixtures/css-inline-stylesheets/src/pages/index.astro rename to packages/astro/test/fixtures/css-inline-stylesheets/always/src/pages/index.astro diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/package.json b/packages/astro/test/fixtures/css-inline-stylesheets/auto/package.json new file mode 100644 index 000000000000..36ae3405054b --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/css-inline-stylesheets", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/components/Button.astro b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/components/Button.astro new file mode 100644 index 000000000000..3f25cbd3e3ae --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/components/Button.astro @@ -0,0 +1,86 @@ +--- +const { class: className = '', style, href } = Astro.props; +const { variant = 'primary' } = Astro.props; +--- + + + + + + + + \ No newline at end of file diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/content/en/endeavour.md b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/content/en/endeavour.md new file mode 100644 index 000000000000..240eeeae3993 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/content/en/endeavour.md @@ -0,0 +1,15 @@ +--- +title: Endeavour +description: 'Learn about the Endeavour NASA space shuttle.' +publishedDate: 'Sun Jul 11 2021 00:00:00 GMT-0400 (Eastern Daylight Time)' +layout: '../../layouts/Layout.astro' +tags: [space, 90s] +--- + +**Source:** [Wikipedia](https://en.wikipedia.org/wiki/Space_Shuttle_Endeavour) + +Space Shuttle Endeavour (Orbiter Vehicle Designation: OV-105) is a retired orbiter from NASA's Space Shuttle program and the fifth and final operational Shuttle built. It embarked on its first mission, STS-49, in May 1992 and its 25th and final mission, STS-134, in May 2011. STS-134 was expected to be the final mission of the Space Shuttle program, but with the authorization of STS-135, Atlantis became the last shuttle to fly. + +The United States Congress approved the construction of Endeavour in 1987 to replace the Space Shuttle Challenger, which was destroyed in 1986. + +NASA chose, on cost grounds, to build much of Endeavour from spare parts rather than refitting the Space Shuttle Enterprise, and used structural spares built during the construction of Discovery and Atlantis in its assembly. \ No newline at end of file diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/imported.css b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/imported.css new file mode 100644 index 000000000000..3959523ff16e --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/imported.css @@ -0,0 +1,15 @@ +.bg-skyblue { + background: skyblue; +} + +.bg-lightcoral { + background: lightcoral; +} + +.red { + color: darkred; +} + +.blue { + color: royalblue; +} diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/layouts/Layout.astro b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/layouts/Layout.astro new file mode 100644 index 000000000000..b78de296ce58 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/layouts/Layout.astro @@ -0,0 +1,35 @@ +--- +import '../imported.css'; +import Button from '../components/Button.astro'; + +export interface Props { + title: string; +} + +const { title } = Astro.props; +--- + + + + + + + + + {title} + + + + + + + diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/pages/index.astro b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/pages/index.astro new file mode 100644 index 000000000000..bfdbeb5f8e85 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/auto/src/pages/index.astro @@ -0,0 +1,17 @@ +--- +import Button from '../components/Button.astro'; +import { getEntryBySlug } from 'astro:content'; + +const entry = await getEntryBySlug('en', 'endeavour'); +const { Content } = await entry.render(); +--- + +
+

Welcome to Astro

+ + +
diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/package.json b/packages/astro/test/fixtures/css-inline-stylesheets/never/package.json new file mode 100644 index 000000000000..36ae3405054b --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/css-inline-stylesheets", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/src/components/Button.astro b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/components/Button.astro new file mode 100644 index 000000000000..3f25cbd3e3ae --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/components/Button.astro @@ -0,0 +1,86 @@ +--- +const { class: className = '', style, href } = Astro.props; +const { variant = 'primary' } = Astro.props; +--- + + + + + + + + \ No newline at end of file diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/src/content/en/endeavour.md b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/content/en/endeavour.md new file mode 100644 index 000000000000..240eeeae3993 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/content/en/endeavour.md @@ -0,0 +1,15 @@ +--- +title: Endeavour +description: 'Learn about the Endeavour NASA space shuttle.' +publishedDate: 'Sun Jul 11 2021 00:00:00 GMT-0400 (Eastern Daylight Time)' +layout: '../../layouts/Layout.astro' +tags: [space, 90s] +--- + +**Source:** [Wikipedia](https://en.wikipedia.org/wiki/Space_Shuttle_Endeavour) + +Space Shuttle Endeavour (Orbiter Vehicle Designation: OV-105) is a retired orbiter from NASA's Space Shuttle program and the fifth and final operational Shuttle built. It embarked on its first mission, STS-49, in May 1992 and its 25th and final mission, STS-134, in May 2011. STS-134 was expected to be the final mission of the Space Shuttle program, but with the authorization of STS-135, Atlantis became the last shuttle to fly. + +The United States Congress approved the construction of Endeavour in 1987 to replace the Space Shuttle Challenger, which was destroyed in 1986. + +NASA chose, on cost grounds, to build much of Endeavour from spare parts rather than refitting the Space Shuttle Enterprise, and used structural spares built during the construction of Discovery and Atlantis in its assembly. \ No newline at end of file diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/src/imported.css b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/imported.css new file mode 100644 index 000000000000..3959523ff16e --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/imported.css @@ -0,0 +1,15 @@ +.bg-skyblue { + background: skyblue; +} + +.bg-lightcoral { + background: lightcoral; +} + +.red { + color: darkred; +} + +.blue { + color: royalblue; +} diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/src/layouts/Layout.astro b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/layouts/Layout.astro new file mode 100644 index 000000000000..b78de296ce58 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/layouts/Layout.astro @@ -0,0 +1,35 @@ +--- +import '../imported.css'; +import Button from '../components/Button.astro'; + +export interface Props { + title: string; +} + +const { title } = Astro.props; +--- + + + + + + + + + {title} + + + + + + + diff --git a/packages/astro/test/fixtures/css-inline-stylesheets/never/src/pages/index.astro b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/pages/index.astro new file mode 100644 index 000000000000..bfdbeb5f8e85 --- /dev/null +++ b/packages/astro/test/fixtures/css-inline-stylesheets/never/src/pages/index.astro @@ -0,0 +1,17 @@ +--- +import Button from '../components/Button.astro'; +import { getEntryBySlug } from 'astro:content'; + +const entry = await getEntryBySlug('en', 'endeavour'); +const { Content } = await entry.render(); +--- + +
+

Welcome to Astro

+ + +
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aedf4e0decb4..e861e6ea58b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2399,11 +2399,23 @@ importers: specifier: workspace:* version: link:../../.. - packages/astro/test/fixtures/css-inline-stylesheets: + packages/astro/test/fixtures/css-inline-stylesheets/always: dependencies: astro: specifier: workspace:* - version: link:../../.. + version: link:../../../.. + + packages/astro/test/fixtures/css-inline-stylesheets/auto: + dependencies: + astro: + specifier: workspace:* + version: link:../../../.. + + packages/astro/test/fixtures/css-inline-stylesheets/never: + dependencies: + astro: + specifier: workspace:* + version: link:../../../.. packages/astro/test/fixtures/css-no-code-split: dependencies: