Skip to content

Commit b91e983

Browse files
feat: rename variable
1 parent 6ef345a commit b91e983

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginActions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('createPluginActions', () => {
218218
expect(postToContainer).toHaveBeenLastCalledWith(
219219
expect.objectContaining({
220220
event: 'promptAI',
221-
promptAI: promptAIPayload,
221+
payload: promptAIPayload,
222222
} satisfies Partial<PluginPromptAIMessage>),
223223
)
224224
})

packages/field-plugin/src/messaging/pluginMessage/pluginToContainerMessage/PromptAIMessage.test.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const stub: PluginPromptAIMessage = {
1111
action: 'prompt-ai',
1212
event: 'promptAI',
1313
uid,
14-
promptAI: {
14+
payload: {
1515
action: 'prompt',
1616
text: 'Some text to prompt',
1717
},
@@ -45,15 +45,15 @@ describe('PromptAIMessage', () => {
4545
expect(
4646
isPluginPromptAIMessage({
4747
...stub,
48-
promptAI: undefined,
48+
payload: undefined,
4949
}),
5050
).toEqual(false)
5151
})
5252
it('has the payload all required fields', () => {
5353
expect(
5454
isPluginPromptAIMessage({
5555
...stub,
56-
promptAI: {
56+
payload: {
5757
action: '',
5858
},
5959
}),
@@ -62,7 +62,7 @@ describe('PromptAIMessage', () => {
6262
expect(
6363
isPluginPromptAIMessage({
6464
...stub,
65-
promptAI: {
65+
payload: {
6666
text: '',
6767
},
6868
}),
@@ -71,7 +71,7 @@ describe('PromptAIMessage', () => {
7171
expect(
7272
isPluginPromptAIMessage({
7373
...stub,
74-
promptAI: {
74+
payload: {
7575
action: 'prompt',
7676
text: 'random text',
7777
},
@@ -81,7 +81,7 @@ describe('PromptAIMessage', () => {
8181
expect(
8282
isPluginPromptAIMessage({
8383
...stub,
84-
promptAI: {
84+
payload: {
8585
action: 'prompt',
8686
text: 123,
8787
},
@@ -91,7 +91,7 @@ describe('PromptAIMessage', () => {
9191
expect(
9292
isPluginPromptAIMessage({
9393
...stub,
94-
promptAI: {
94+
payload: {
9595
action: null,
9696
text: 123,
9797
},
@@ -101,7 +101,7 @@ describe('PromptAIMessage', () => {
101101
expect(
102102
isPluginPromptAIMessage({
103103
...stub,
104-
promptAI: {
104+
payload: {
105105
action: null,
106106
text: null,
107107
},
@@ -112,14 +112,13 @@ describe('PromptAIMessage', () => {
112112
describe('constructor', () => {
113113
it('includes the uid', () => {
114114
expect(
115-
getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }),
115+
getPluginPromptAIMessage(stub.payload, { uid, callbackId }),
116116
).toHaveProperty('uid', uid)
117117
})
118-
console.log(getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }))
119118
it('includes the promptAI data added to the message', () => {
120119
expect(
121-
getPluginPromptAIMessage(stub.promptAI, { uid, callbackId }),
122-
).toHaveProperty('promptAI')
120+
getPluginPromptAIMessage(stub.payload, { uid, callbackId }),
121+
).toHaveProperty('payload')
123122
})
124123
})
125124
})

packages/field-plugin/src/messaging/pluginMessage/pluginToContainerMessage/PromptAIMessage.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ export type PluginPromptAIMessage = Omit<
4747
'action'
4848
> & {
4949
action: 'prompt-ai'
50-
promptAI: PromptAIPayload
50+
payload: PromptAIPayload
5151
}
5252

5353
export const isPluginPromptAIMessage = (
5454
obj: unknown,
5555
): obj is PluginPromptAIMessage =>
5656
isMessageToContainer(obj) &&
57-
obj.event === 'promptAI' &&
58-
hasKey(obj, 'promptAI') &&
59-
isPromptAIPayloadValid(obj.promptAI as PromptAIPayload)
57+
obj.event === 'payload' &&
58+
hasKey(obj, 'payload') &&
59+
isPromptAIPayloadValid(obj.payload as PromptAIPayload)
6060

6161
export const getPluginPromptAIMessage = (
6262
message: PromptAIPayload,
@@ -65,7 +65,7 @@ export const getPluginPromptAIMessage = (
6565
action: 'prompt-ai',
6666
event: 'promptAI',
6767
...options,
68-
promptAI: { ...message },
68+
payload: { ...message },
6969
})
7070

7171
const isPromptAIPayloadValid = (promptAIPayload: PromptAIPayload) =>

0 commit comments

Comments
 (0)