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[gen1][core] ENG-7515 add query.id when hitting content API for symbols #3752

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/core/src/builder.class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,4 +768,32 @@ describe('flushGetContentQueue', () => {
{ headers: { Authorization: `Bearer ${AUTH_TOKEN}` } }
);
});

test('hits content url with query.id when id is passed in options.query', async () => {
const expectedModel = 'symbol';
const expectedFormat = 'email';
const expectedEntryId = '123';

const result = await builder['flushGetContentQueue'](true, [
{
apiEndpoint: 'content',
model: expectedModel,
format: expectedFormat,
key: expectedModel,
omit: OMIT,
fields: 'data',
limit: 10,
entry: expectedEntryId,
query: {
id: expectedEntryId,
},
},
]);

expect(builder['makeFetchApiCall']).toBeCalledTimes(1);
expect(builder['makeFetchApiCall']).toBeCalledWith(
`https://cdn.builder.io/api/v3/content/${expectedModel}?omit=data.blocks&apiKey=${API_KEY}&fields=data&format=${expectedFormat}&userAttributes=%7B%22urlPath%22%3A%22%2F%22%2C%22host%22%3A%22localhost%22%2C%22device%22%3A%22desktop%22%7D&limit=10&model=%22${expectedModel}%22&entry=%22${expectedEntryId}%22&enrich=true&query.id=${expectedEntryId}`,
{ headers: { Authorization: `Bearer ${AUTH_TOKEN}` } }
);
});
});
3 changes: 3 additions & 0 deletions packages/react/src/blocks/Symbol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ class SymbolComponent extends React.Component<PropsWithChildren<SymbolProps>> {
...(!this.isEditingThisSymbol && {
key: builderComponentKey,
noEditorUpdates: true,
query: {
Copy link
Contributor

Choose a reason for hiding this comment

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

this query param should not be condition in editingThisSymbol. it should always be provided

Copy link
Contributor

Choose a reason for hiding this comment

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

also, this query param should only be added when the entry value exists AND when the apiEndpoint value is "content"

id: entry,
},
}),
}}
codegen={!!content?.data?.blocksJs}
Expand Down
Loading