-
Notifications
You must be signed in to change notification settings - Fork 1k
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[ENG-8003]: Changing the entry on a symbol does not update the preview window #3985
base: main
Are you sure you want to change the base?
Conversation
…If not equal than fetchSymbolContent
|
View your CI Pipeline Execution ↗ for commit 0ad71f6.
☁️ Nx Cloud last updated this comment at |
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
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.
you're missing a few things, i created a loom explaining what all changes you need to do so that you can properly mock the fetch calls
https://www.loom.com/share/62e673c3668342949f1df71b72b921f3
let me know if you have any questions
Interestingly, when I run them individually, my fix resolves the issue, but the test case still fails. I’m wondering if I’m missing something. I’ve recorded a Loom https://www.loom.com/share/ac1bd9c4d6c346efa3899250ce9b8220?sid=25f81646-040e-4c42-856b-ed13d938e772 |
test('Symbol should update the data when nested values are updated', async ({ | ||
page, | ||
sdk, | ||
packageName, | ||
basePort | ||
}) => { | ||
test.skip(excludeGen1(sdk)); | ||
test.skip(packageName === 'nextjs-sdk-next-app'); | ||
|
||
let fetchCount = 0; | ||
const symbolRequests: URL[] = []; | ||
const urlMatch = /https:\/\/cdn\.builder\.io\/api\/v3\/content\/symbol/; | ||
|
||
await page.route(urlMatch, route => { | ||
fetchCount++; | ||
const url = new URL(route.request().url()); | ||
symbolRequests.push(url); | ||
return route.fulfill({ | ||
status: 200, | ||
json: { | ||
results: [ | ||
fetchCount === 1 | ||
? GET_CONTENT_SYMBOL_UPDATE_ENTRY_ONE | ||
: GET_CONTENT_SYMBOL_UPDATE_ENTRY__TWO, | ||
], | ||
}, | ||
}); | ||
}); | ||
|
||
await launchEmbedderAndWaitForSdk({ path: '/symbol-update-entries', basePort, page, sdk }); | ||
|
||
const newContent = cloneContent(MAIN_CONTENT); | ||
|
||
await page.frameLocator('iframe').getByText('Green Potato').waitFor(); | ||
|
||
newContent.data.blocks[0].component.options.symbol.entry = 'aa024e6851e94b49b99f41a2294fd423'; | ||
await sendContentUpdateMessage({ page, newContent, model: 'page' }); | ||
|
||
await page.frameLocator('iframe').getByText('Red tomato').waitFor(); | ||
expect(fetchCount).toBe(2); | ||
}); |
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.
This test fails because when in the visual editor, the Symbol API call you're mocking is made twice for each entry instead of once. It's an issue somewhere in our reactivity that we haven't completely fixed yet.
You're checking for the 1st VS 2nd fetch which is why you get the wrong symbol. Instead, check the query.id
param received in the request to decide on the entry and it will work.
test('Symbol should update the data when nested values are updated', async ({ | |
page, | |
sdk, | |
packageName, | |
basePort | |
}) => { | |
test.skip(excludeGen1(sdk)); | |
test.skip(packageName === 'nextjs-sdk-next-app'); | |
let fetchCount = 0; | |
const symbolRequests: URL[] = []; | |
const urlMatch = /https:\/\/cdn\.builder\.io\/api\/v3\/content\/symbol/; | |
await page.route(urlMatch, route => { | |
fetchCount++; | |
const url = new URL(route.request().url()); | |
symbolRequests.push(url); | |
return route.fulfill({ | |
status: 200, | |
json: { | |
results: [ | |
fetchCount === 1 | |
? GET_CONTENT_SYMBOL_UPDATE_ENTRY_ONE | |
: GET_CONTENT_SYMBOL_UPDATE_ENTRY__TWO, | |
], | |
}, | |
}); | |
}); | |
await launchEmbedderAndWaitForSdk({ path: '/symbol-update-entries', basePort, page, sdk }); | |
const newContent = cloneContent(MAIN_CONTENT); | |
await page.frameLocator('iframe').getByText('Green Potato').waitFor(); | |
newContent.data.blocks[0].component.options.symbol.entry = 'aa024e6851e94b49b99f41a2294fd423'; | |
await sendContentUpdateMessage({ page, newContent, model: 'page' }); | |
await page.frameLocator('iframe').getByText('Red tomato').waitFor(); | |
expect(fetchCount).toBe(2); | |
}); | |
test('Symbol should update the data when nested values are updated', async ({ | |
page, | |
sdk, | |
packageName, | |
basePort, | |
}) => { | |
test.skip(excludeGen1(sdk)); | |
test.skip(packageName === 'nextjs-sdk-next-app'); | |
const urlMatch = /https:\/\/cdn\.builder\.io\/api\/v3\/content\/symbol/; | |
await page.route(urlMatch, route => { | |
const url = new URL(route.request().url()); | |
const queryIdParam = url.searchParams.get('query.id'); | |
let symbolToReturn = null; | |
if (queryIdParam === '"e2a166f7d9544ed9ade283abf9491af3"') { | |
symbolToReturn = GET_CONTENT_SYMBOL_UPDATE_ENTRY_ONE; | |
} else if (queryIdParam === '"aa024e6851e94b49b99f41a2294fd423"') { | |
symbolToReturn = GET_CONTENT_SYMBOL_UPDATE_ENTRY__TWO; | |
} else { | |
throw new Error(`Unknown query id: ${queryIdParam}`); | |
} | |
return route.fulfill({ | |
status: 200, | |
json: { | |
results: [symbolToReturn], | |
}, | |
}); | |
}); | |
await launchEmbedderAndWaitForSdk({ path: '/symbol-update-entries', basePort, page, sdk }); | |
const newContent = cloneContent(MAIN_CONTENT); | |
await page.frameLocator('iframe').getByText('Green Potato').waitFor(); | |
newContent.data.blocks[0].component.options.symbol.entry = 'aa024e6851e94b49b99f41a2294fd423'; | |
await sendContentUpdateMessage({ page, newContent, model: 'page' }); | |
await page.frameLocator('iframe').getByText('Red tomato').waitFor(); | |
}) |
Description
This PR fixes an issue where symbol content was not updating correctly. The fix compares the previous symbol entry with the incoming symbol entry—if they are not equal, it triggers
fetchSymbolContent
to ensure the latest content is loaded.Changes Made:
fetchSymbolContent
if the entries differ to update the content.Why This Change Was Made:
To ensure symbol content updates correctly when the symbol entry changes, improving accuracy and consistency in the preview.
Screenshot
Adding loom soon