FIX: ChatChannel no longer inherits from RestModel. (#292)

Trying to hydrate using the store will fail. We need to use the model create function instead.
This commit is contained in:
Roman Rizzi 2023-11-13 14:45:20 -03:00 committed by GitHub
parent 244a338558
commit 1588ab99a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 7 deletions

View File

@ -1,13 +1,8 @@
import Component from "@glimmer/component";
import { inject as service } from "@ember/service";
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
export default class ReviewableAiChatMessage extends Component {
@service store;
get chatChannel() {
return this.store.createRecord(
"chat-channel",
this.args.reviewable.chat_channel
);
return ChatChannel.create(this.args.reviewable.chat_channel);
}
}

View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
require_relative "../../support/toxicity_inference_stubs"
RSpec.describe "Toxicity-flagged chat messages", type: :system, js: true do
fab!(:chat_message) { Fabricate(:chat_message) }
fab!(:admin) { Fabricate(:admin) }
before do
sign_in(admin)
SiteSetting.ai_toxicity_enabled = true
SiteSetting.ai_toxicity_flag_automatically = true
ToxicityInferenceStubs.stub_chat_message_classification(chat_message, toxic: true)
DiscourseAi::ChatMessageClassificator.new(
DiscourseAi::Toxicity::ToxicityClassification.new,
).classify!(chat_message)
end
it "displays them in the review queue" do
visit("/review")
expect(page).to have_selector(".reviewable-ai-chat-message .reviewable-actions")
end
end