-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: RequestEventAction has missed a type resolveValue
#7378
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
Open
JerryWu1234
wants to merge
26
commits into
QwikDev:main
Choose a base branch
from
JerryWu1234:7377_fix_ts_error
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+230
−43
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c0cd5fa
fix: RequestEventAction has missed a type `resolveValue`
8bbf36d
update ap
cf5b192
Create cold-chairs-juggle.md
JerryWu1234 8fe9b2a
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 8c7e7ca
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 1839dff
add test, add resolve value
ffe6146
fix loader
cb99ba0
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 41e7ba1
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 234ed37
test
3e51a2d
Merge branch '7377_fix_ts_error' of https://github.com/JerryWu1234/qw…
c9a35c8
reset
c174cf5
test
ee5f60c
test
f68a58a
fix error
4c187e4
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 c52798e
Delete .changeset/cold-chairs-juggle.md
JerryWu1234 0397c56
fix change
JerryWu1234 dda7bf3
fix change
JerryWu1234 b1cb828
Update eight-garlics-deliver.md
JerryWu1234 7c68e6c
Merge branch 'main' into 7377_fix_ts_error
JerryWu1234 9ab0484
merge
JerryWu1234 c484ca5
api update
JerryWu1234 b932995
Merge branch 'main' into 7377_fix_ts_error
gioboa e0991b8
fix(qwik-city): add type for `routeAction$`'s `requestEvent.resolveVa…
JerryWu1234 88f268c
docs(changeset): remove '@builder.io/qwik' from patch list
JerryWu1234 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 @@ | ||
--- | ||
'@builder.io/qwik-city': patch | ||
--- | ||
|
||
FIX: add type for `routeAction$`'s `requestEvent.resolveValue` |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
102 changes: 102 additions & 0 deletions
102
starters/apps/qwikcity-test/src/routes/(common)/resolve-value/index.tsx
This file contains hidden or 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,102 @@ | ||
import { component$ } from "@builder.io/qwik"; | ||
import { | ||
routeAction$, | ||
Form, | ||
routeLoader$, | ||
zod$, | ||
z, | ||
globalAction$, | ||
} from "@builder.io/qwik-city"; | ||
|
||
const useUser = routeLoader$(() => { | ||
const user = { | ||
firstName: "", | ||
lastName: "", | ||
test: 11, | ||
}; | ||
|
||
return user; | ||
}); | ||
|
||
const useUserGlobal = routeLoader$(() => { | ||
const user = { | ||
firstName: "", | ||
lastName: "", | ||
test: 11, | ||
}; | ||
|
||
return user; | ||
}); | ||
|
||
export const useAddUser = routeAction$( | ||
async (data, requestEvent) => { | ||
const res = await requestEvent.resolveValue(useUser); | ||
res.firstName = data.firstName; | ||
res.lastName = data.lastName; | ||
return { | ||
success: true, | ||
userID: res, | ||
}; | ||
}, | ||
zod$({ | ||
firstName: z.string(), | ||
lastName: z.string(), | ||
}), | ||
); | ||
|
||
export const globalAction = globalAction$( | ||
async (data, requestEvent) => { | ||
const res = await requestEvent.resolveValue(useUserGlobal); | ||
res.firstName = data.globalfirstName; | ||
res.lastName = data.globallastName; | ||
return { | ||
success: true, | ||
userID: res, | ||
}; | ||
}, | ||
zod$({ | ||
globalfirstName: z.string(), | ||
globallastName: z.string(), | ||
}), | ||
); | ||
|
||
export default component$(() => { | ||
const action = useAddUser(); | ||
const globalstate = globalAction(); | ||
return ( | ||
<> | ||
<div id="action"> | ||
<Form action={action}> | ||
<input name="firstName" /> | ||
<input name="lastName" /> | ||
<button type="submit" id="actionButton"> | ||
Add user | ||
</button> | ||
</Form> | ||
{action.value?.success && ( | ||
<> | ||
<p>User {action.value.userID.firstName} added successfully</p> | ||
<p>User {action.value.userID.lastName} added successfully</p> | ||
<p>User {action.value.userID.test} added successfully</p> | ||
</> | ||
)} | ||
</div> | ||
<div id="global"> | ||
<Form action={globalstate}> | ||
<input name="globalfirstName" /> | ||
<input name="globallastName" /> | ||
<button type="submit" id="globalButton"> | ||
Add user | ||
</button> | ||
</Form> | ||
{globalstate.value?.success && ( | ||
<> | ||
<p>User {globalstate.value.userID.firstName} added successfully</p> | ||
<p>User {globalstate.value.userID.lastName} added successfully</p> | ||
<p>User {globalstate.value.userID.test} added successfully</p> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
); | ||
}); |
This file contains hidden or 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,57 @@ | ||
import { expect, test } from "@playwright/test"; | ||
|
||
test.describe("revolve value", () => { | ||
test.describe("mpa", () => { | ||
test.use({ javaScriptEnabled: false }); | ||
tests(); | ||
}); | ||
|
||
test.describe("spa", () => { | ||
test.use({ javaScriptEnabled: true }); | ||
tests(); | ||
}); | ||
|
||
function tests() { | ||
test("should submit valid form data", async ({ page }) => { | ||
await page.goto("/qwikcity-test/resolve-value"); | ||
|
||
await page.fill('input[name="firstName"]', "NewFirstName"); | ||
await page.fill('input[name="lastName"]', "NewLastName"); | ||
await page.click('button[id="actionButton"]'); | ||
|
||
const successMessage = page.locator( | ||
'p:has-text("User NewFirstName added successfully")', | ||
); | ||
const lastNameSuccess = page.locator( | ||
'p:has-text("User NewLastName added successfully")', | ||
); | ||
const userIdDisplay = page.locator( | ||
'p:has-text("User 11 added successfully")', | ||
); | ||
await expect(successMessage).toBeVisible(); | ||
await expect(lastNameSuccess).toBeVisible(); | ||
await expect(userIdDisplay).toBeVisible(); | ||
}); | ||
|
||
test("should submit global form data", async ({ page }) => { | ||
await page.goto("/qwikcity-test/resolve-value"); | ||
|
||
await page.fill('input[name="globalfirstName"]', "GlobalFirstName"); | ||
await page.fill('input[name="globallastName"]', "GlobalLastName"); | ||
await page.click('button[id="globalButton"]'); | ||
|
||
const globalSuccess = page.locator( | ||
'p:has-text("User GlobalFirstName added successfully")', | ||
); | ||
const globalLastName = page.locator( | ||
'p:has-text("User GlobalLastName added successfully")', | ||
); | ||
const globalUserId = page.locator( | ||
'p:has-text("User 11 added successfully")', | ||
); | ||
await expect(globalSuccess).toBeVisible(); | ||
await expect(globalLastName).toBeVisible(); | ||
await expect(globalUserId).toBeVisible(); | ||
}); | ||
} | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to reset it to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to prevent it from running multiple times.