Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 43a94f1

Browse files
committed
fix specs
1 parent 70acb0b commit 43a94f1

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

assets/javascripts/discourse/components/ai-post-helper-menu.gjs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export default class AiPostHelperMenu extends Component {
4444
@tracked isSavingFootnote = false;
4545
@tracked supportsAddFootnote = this.args.data.supportsFastEdit;
4646
@tracked
47-
channel =
48-
`/discourse-ai/ai-helper/stream_suggestion/${this.args.data.quoteState.postId}`;
47+
channel = `/discourse-ai/ai-helper/stream_suggestion/${this.args.data.quoteState.postId}`;
4948

5049
@tracked
5150
smoothStreamer = new SmoothStreamer(
@@ -79,7 +78,6 @@ export default class AiPostHelperMenu extends Component {
7978
});
8079

8180
@tracked _activeAiRequest = null;
82-
@tracked _lastMessageIds = {};
8381

8482
get footnoteDisabled() {
8583
return this.streaming || !this.supportsAddFootnote;
@@ -155,12 +153,9 @@ export default class AiPostHelperMenu extends Component {
155153
subscribe() {
156154
this.messageBus.subscribe(
157155
this.channel,
158-
(data, id) => {
159-
this._lastMessageIds[this.channel] =
160-
this.args.data.post.discourse_ai_helper_stream_suggestion_last_message_bus_id;
161-
this._updateResult(data, id);
162-
},
163-
this._lastMessageIds[this.channel]
156+
(data, id) => this._updateResult(data, id),
157+
this.args.data.post
158+
.discourse_ai_helper_stream_suggestion_last_message_bus_id
164159
);
165160
}
166161

@@ -171,8 +166,6 @@ export default class AiPostHelperMenu extends Component {
171166

172167
@bind
173168
async _updateResult(result) {
174-
this._lastMessageIds[this.channel] =
175-
this.args.data.post.discourse_ai_helper_stream_suggestion_last_message_bus_id;
176169
this.streaming = !result.done;
177170
await this.smoothStreamer.updateResult(result, "result");
178171
}

spec/system/ai_helper/ai_post_helper_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ def select_post_text(selected_post)
107107

108108
DiscourseAi::Completions::Llm.with_prepared_responses([explain_response]) do
109109
post_ai_helper.select_helper_model(mode)
110-
wait_for { post_ai_helper.has_suggestion_value? }
111-
expect(post_ai_helper.suggestion_value).to eq(explain_response)
110+
expect(post_ai_helper).to have_suggestion_value(explain_response)
112111
end
113112
end
114113
end

spec/system/page_objects/components/ai_post_helper_menu.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ def select_helper_model(mode)
2727
find("#{OPTIONS_SELECTOR} .btn[data-name=\"#{mode}\"]").click
2828
end
2929

30-
def has_suggestion_value?
31-
page.has_css?("#{SUGGESTION_SELECTOR}__text")
30+
def has_suggestion_value?(value)
31+
page.has_css?("#{SUGGESTION_SELECTOR}__text", text: value)
3232
end
3333

3434
def suggestion_value

0 commit comments

Comments
 (0)