Skip to content

Commit

Permalink
Merge branch 'feat/location-serverStore' of github.com:dac09/redwood …
Browse files Browse the repository at this point in the history
…into feat/location-serverStore

* 'feat/location-serverStore' of github.com:dac09/redwood:
  no need to repeat fullUrl
  Use Replay for smoke tests (redwoodjs#10664)
  chore(testing): Remove unused member in Props interface (redwoodjs#10699)
  fix(cli): Directive generator command was not creating files (redwoodjs#10698)
  Always execute the <Metadata> component on the client (redwoodjs#10271)
  • Loading branch information
dac09 committed May 30, 2024
2 parents 8e631b4 + 7a162f5 commit 5571253
Show file tree
Hide file tree
Showing 11 changed files with 319 additions and 46 deletions.
4 changes: 4 additions & 0 deletions .changesets/10271.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- PR bug: Always evaluate the `<Metadata>` component on the client by @cannikin

One of `<Metadata>`s dependencies (probably Helmet) uses `createContext()`.
This throws an uncaught error in the RSC engine and crashes the server.
19 changes: 19 additions & 0 deletions .changesets/10698.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- fix(cli): Directive generator command was not creating files (#10698) by @dthyresson

Fixes: https://github.com/redwoodjs/redwood/issues/10694

The PR fixes a regression in the directive generator where files were not created.

At some point the method to construct files became async. Thus while the command attempted to construct the directive files and write them to the directive directory, it never did.

With this fix, file are written:

```bash
✔ Generating directive file ...
✔ Successfully wrote file
`./api/src/directives/requireEmailValidation/requireEmailValidation.test.ts`
✔ Successfully wrote file
`./api/src/directives/requireEmailValidation/requireEmailValidation.ts`
✔ Generating TypeScript definitions and GraphQL schemas ...
✔ Next steps...
```
71 changes: 49 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ jobs:
env:
REDWOOD_CI: 1
REDWOOD_VERBOSE_TELEMETRY: 1
BROWSER_INSTALL_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright install --with-deps chromium' || 'npx replayio install' }}
PLAYWRIGHT_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright test --project chromium' || 'npx playwright test --project replay-chromium' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -218,22 +220,24 @@ jobs:
REDWOOD_DISABLE_TELEMETRY: 1
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: 🎭 Install playwright dependencies
run: npx playwright install --with-deps chromium
- name: 🎭 Install Playwright dependencies
run: ${{ env.BROWSER_INSTALL_CMD }}

- name: 🧑‍💻 Run dev smoke tests
working-directory: ./tasks/smoke-tests/dev
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: 🔐 Run auth smoke tests
working-directory: ./tasks/smoke-tests/auth
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: Run `rw build --no-prerender`
run: |
Expand All @@ -247,24 +251,27 @@ jobs:

- name: 🖥️ Run serve smoke tests
working-directory: tasks/smoke-tests/serve
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: 📄 Run prerender smoke tests
working-directory: tasks/smoke-tests/prerender
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: 📕 Run Storybook smoke tests
working-directory: tasks/smoke-tests/storybook
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

smoke-tests-skip:
needs: detect-changes
Expand Down Expand Up @@ -444,6 +451,8 @@ jobs:
env:
REDWOOD_CI: 1
REDWOOD_VERBOSE_TELEMETRY: 1
BROWSER_INSTALL_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright install --with-deps chromium' || 'npx replayio install' }}
PLAYWRIGHT_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright test --project chromium' || 'npx playwright test --project replay-chromium' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -457,15 +466,16 @@ jobs:
REDWOOD_DISABLE_TELEMETRY: 1
YARN_ENABLE_IMMUTABLE_INSTALLS: false

- name: 🎭 Install playwright dependencies
run: npx playwright install --with-deps chromium
- name: 🎭 Install Playwright dependencies
run: ${{ env.BROWSER_INSTALL_CMD }}

- name: 🐘 Run RSC serve smoke tests
working-directory: tasks/smoke-tests/rsc
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-rsc-project.outputs.rsc-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

# TODO (RSC): This workflow times out on Windows. It looks as if the dev
# server starts up ok, but it doesn't seem like the browser is rendering
Expand All @@ -477,10 +487,11 @@ jobs:
- name: 🐘 Run RSC dev smoke tests
if: matrix.os == 'false__ubuntu-latest'
working-directory: tasks/smoke-tests/rsc-dev
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-rsc-project.outputs.rsc-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: 🌲 Set up RSA smoke test
id: set-up-rsa-project
Expand All @@ -491,10 +502,11 @@ jobs:

- name: 🐘 Run RSA smoke tests
working-directory: tasks/smoke-tests/rsa
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-rsa-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: 🌲 Set up RSC Kitchen Sink smoke test
id: set-up-rsc-kitchen-sink-project
Expand All @@ -505,10 +517,11 @@ jobs:

- name: 🐘 Run RSC Kitchen Sink smoke tests
working-directory: tasks/smoke-tests/rsc-kitchen-sink
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-rsc-kitchen-sink-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

rsc-smoke-tests-skip:
needs: detect-changes
Expand Down Expand Up @@ -539,6 +552,9 @@ jobs:
env:
REDWOOD_CI: 1
REDWOOD_VERBOSE_TELEMETRY: 1
# Temp workaround for Replay specific failing tests
BROWSER_INSTALL_CMD: 'npx playwright install --with-deps chromium && npx replayio install'
PLAYWRIGHT_CMD: npx playwright test --project chromium

steps:
- uses: actions/checkout@v4
Expand All @@ -560,15 +576,18 @@ jobs:
env:
REDWOOD_DISABLE_TELEMETRY: 1

- name: 🎭 Install playwright dependencies
run: npx playwright install --with-deps chromium
- name: 🎭 Install Playwright dependencies
run: ${{ env.BROWSER_INSTALL_CMD }}

- name: Run SSR [DEV] smoke tests
working-directory: ./tasks/smoke-tests/streaming-ssr-dev
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1
# Temp workaround for Replay specific failing tests
DISABLE_REPLAY_UPLOAD: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: Build for production
working-directory: ${{ steps.set-up-test-project.outputs.test-project-path }}
Expand All @@ -578,10 +597,13 @@ jobs:

- name: Run SSR [PROD] smoke tests
working-directory: ./tasks/smoke-tests/streaming-ssr-prod
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1
# Temp workaround for Replay specific failing tests
DISABLE_REPLAY_UPLOAD: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

ssr-smoke-tests-skip:
needs: detect-changes
Expand Down Expand Up @@ -611,6 +633,8 @@ jobs:
env:
REDWOOD_CI: 1
REDWOOD_VERBOSE_TELEMETRY: 1
BROWSER_INSTALL_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright install --with-deps chromium' || 'npx replayio install' }}
PLAYWRIGHT_CMD: ${{ matrix.os == 'windows-latest' && 'npx playwright test --project chromium' || 'npx playwright test --project replay-chromium' }}

steps:
- uses: actions/checkout@v4
Expand All @@ -632,15 +656,16 @@ jobs:
env:
REDWOOD_DISABLE_TELEMETRY: 1

- name: 🎭 Install playwright dependencies
run: npx playwright install --with-deps chromium
- name: 🎭 Install Playwright dependencies
run: ${{ env.BROWSER_INSTALL_CMD }}

- name: Run Fragments dev smoke tests
working-directory: ./tasks/smoke-tests/fragments-dev
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: Build for production
working-directory: ${{ steps.set-up-test-project.outputs.test-project-path }}
Expand All @@ -650,10 +675,11 @@ jobs:

- name: Run Fragments serve smoke tests
working-directory: ./tasks/smoke-tests/fragments-serve
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: '${{ steps.set-up-test-project.outputs.test-project-path }}'
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

- name: Enable trusted-documents in Fragments test project
run: npx -y tsx ./tasks/test-project/set-up-trusted-documents ${{ steps.set-up-test-project.outputs.test-project-path }}
Expand All @@ -662,10 +688,11 @@ jobs:

- name: 📄 Run prerender smoke tests against Fragments test project (with trusted-documents enabled)
working-directory: tasks/smoke-tests/prerender
run: npx playwright test
run: ${{ env.PLAYWRIGHT_CMD }}
env:
REDWOOD_TEST_PROJECT_PATH: ${{ steps.set-up-test-project.outputs.test-project-path }}
REDWOOD_DISABLE_TELEMETRY: 1
REPLAY_API_KEY: ${{ secrets.REPLAY_API_KEY }}

fragments-smoke-tests-skip:
needs: detect-changes
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@faker-js/faker": "8.4.1",
"@npmcli/arborist": "7.5.2",
"@playwright/test": "1.44.0",
"@replayio/playwright": "^3.0.1",
"@testing-library/jest-dom": "6.4.5",
"@testing-library/react": "14.3.1",
"@testing-library/user-event": "14.5.2",
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/commands/generate/directive/directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ export const handler = async (args) => {
[
{
title: 'Generating directive file ...',
task: () => {
return writeFilesTask(files({ ...args, type: directiveType }), {
task: async () => {
const f = await files({ ...args, type: directiveType })
return writeFilesTask(f, {
overwriteExisting: args.force,
})
},
Expand Down
10 changes: 1 addition & 9 deletions packages/testing/src/web/MockParamsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,15 @@ import React from 'react'
import { useLocation, ParamsContext, parseSearch } from '@redwoodjs/router'

interface Props {
path?: string
children?: React.ReactNode
}

export const MockParamsProvider: React.FC<Props> = ({ children }) => {
const location = useLocation()

const searchParams = parseSearch(location.search)

return (
<ParamsContext.Provider
value={{
params: {
...searchParams,
},
}}
>
<ParamsContext.Provider value={{ params: { ...searchParams } }}>
{children}
</ParamsContext.Provider>
)
Expand Down
5 changes: 1 addition & 4 deletions packages/vite/src/runFeServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,7 @@ export async function runFeServer() {
const fullUrl = getFullUrl(req)
const headers = convertExpressHeaders(req.headersDistinct)
// Convert express headers to fetch headers
const perReqStore = createPerRequestMap({
headers,
fullUrl: fullUrl,
})
const perReqStore = createPerRequestMap({ headers, fullUrl })

// By wrapping next, we ensure that all of the other handlers will use this same perReqStore
// But note that the serverStorage is RE-initialised for the RSC worker
Expand Down
2 changes: 2 additions & 0 deletions packages/web/src/components/Metadata.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use client'

import React from 'react'

import { Helmet as HelmetHead } from 'react-helmet-async'
Expand Down
13 changes: 12 additions & 1 deletion tasks/smoke-tests/basePlaywright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from 'node:fs'

import type { PlaywrightTestConfig } from '@playwright/test'
import { devices } from '@playwright/test'
import { devices as replayDevices, replayReporter } from '@replayio/playwright'

// See https://playwright.dev/docs/test-configuration#global-configuration
export const basePlaywrightConfig: PlaywrightTestConfig = {
Expand All @@ -22,6 +23,10 @@ export const basePlaywrightConfig: PlaywrightTestConfig = {
use: { ...devices['Desktop Chrome'] },
dependencies: fs.existsSync('./tests/setup.ts') ? ['setup'] : undefined,
},
{
name: 'replay-chromium',
use: { ...replayDevices['Replay Chromium'] },
},

// {
// name: 'firefox',
Expand All @@ -34,5 +39,11 @@ export const basePlaywrightConfig: PlaywrightTestConfig = {
// },
],

reporter: 'list',
reporter: [
replayReporter({
apiKey: process.env.REPLAY_API_KEY,
upload: !!process.env.CI || !!process.env.DISABLE_REPLAY_UPLOAD,
}),
['line'],
],
}
2 changes: 1 addition & 1 deletion tasks/smoke-tests/smoke-tests.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async function parseArgs() {
playwrightOptions: {
description: `Options to forward to ${chalk.cyan('npx playwright test')}`,
type: /** @type {const} */ ('string'),
default: '',
default: '--project=chromium',
},

help: {
Expand Down
Loading

0 comments on commit 5571253

Please sign in to comment.