Skip to content
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

fix(nuxt): change the name of the RouteProvider componet when keepalive #28203

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jilx951102
Copy link

🔗 Linked issue

keepalive include Bug

📚 Description

now, I can not dynamic control keepalive by change include config

Copy link

stackblitz bot commented Jul 18, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks good to me. But would you have a look at the failing tests, and add a test to cover these changes, perhaps?

nuxt/test/basic.test.ts

Lines 2511 to 2592 in eb31abe

describe('keepalive', () => {
it('should not keepalive by default', async () => {
const { page, consoleLogs } = await renderPage('/keepalive')
const pageName = 'not-keepalive'
await page.click(`#${pageName}`)
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/keepalive/${pageName}`)
expect(consoleLogs.map(l => l.text).filter(t => t.includes('keepalive'))).toEqual([`${pageName}: onMounted`])
await page.close()
})
it('should not keepalive when included in app config but config in nuxt-page is not undefined', async () => {
const { page, consoleLogs } = await renderPage('/keepalive')
const pageName = 'keepalive-in-config'
await page.click(`#${pageName}`)
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/keepalive/${pageName}`)
expect(consoleLogs.map(l => l.text).filter(t => t.includes('keepalive'))).toEqual([`${pageName}: onMounted`])
await page.close()
})
it('should not keepalive when included in app config but exclueded in nuxt-page', async () => {
const { page, consoleLogs } = await renderPage('/keepalive')
const pageName = 'not-keepalive-in-nuxtpage'
await page.click(`#${pageName}`)
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/keepalive/${pageName}`)
expect(consoleLogs.map(l => l.text).filter(t => t.includes('keepalive'))).toEqual([`${pageName}: onMounted`])
await page.close()
})
it('should keepalive when included in nuxt-page', async () => {
const { page, consoleLogs } = await renderPage('/keepalive')
const pageName = 'keepalive-in-nuxtpage'
await page.click(`#${pageName}`)
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/keepalive/${pageName}`)
expect(consoleLogs.map(l => l.text).filter(t => t.includes('keepalive'))).toEqual([`${pageName}: onMounted`, `${pageName}: onActivated`])
await page.close()
})
it('should preserve keepalive config when navigate routes in nuxt-page', async () => {
const { page, consoleLogs } = await renderPage('/keepalive')
const slugs = [
'keepalive-in-nuxtpage',
'keepalive-in-nuxtpage-2',
'keepalive-in-nuxtpage',
'not-keepalive',
'keepalive-in-nuxtpage-2',
]
for (const slug of slugs) {
await page.click(`#${slug}`)
await page.waitForFunction(path => window.useNuxtApp?.()._route.fullPath === path, `/keepalive/${slug}`)
}
expect(consoleLogs.map(l => l.text).filter(t => t.includes('keepalive'))).toEqual([
'keepalive-in-nuxtpage: onMounted',
'keepalive-in-nuxtpage: onActivated',
'keepalive-in-nuxtpage: onDeactivated',
'keepalive-in-nuxtpage-2: onMounted',
'keepalive-in-nuxtpage-2: onActivated',
'keepalive-in-nuxtpage: onActivated',
'keepalive-in-nuxtpage-2: onDeactivated',
'keepalive-in-nuxtpage: onDeactivated',
'not-keepalive: onMounted',
'keepalive-in-nuxtpage-2: onActivated',
'not-keepalive: onUnmounted',
])
await page.close()
})
})

@jilx951102
Copy link
Author

jilx951102 commented Jul 19, 2024

@danielroe thanks for the quick reply.

when I run pnpm test, always report an error 'Error: browserType.launch: Executable doesn't exist'
image
would you like to tell me your node version?

@danielroe
Copy link
Member

Try running:

pnpm playwright-core install chromium

@jilx951102
Copy link
Author

jilx951102 commented Jul 22, 2024

@danielroe thanks! it works.
I know what casue the issue 27777.
All providerVNodes created by same type RouteProvider, so when change the providerVNode.type.name will cause all providerVNode.type.name change.
image
And I try to fix it like below
image
But it report another error
image

I have no idea how to fix it. Could you give me some ideas?

@danielroe
Copy link
Member

I'd have a better idea of how to fix if you could provide a reproduction of the issue.

@danielroe danielroe marked this pull request as draft August 21, 2024 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants