MCPcopy Index your code
hub / github.com/coder/coder / TestUnarchiveChat

Function TestUnarchiveChat

coderd/exp_chats_test.go:5816–6088  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

5814}
5815
5816func TestUnarchiveChat(t *testing.T) {
5817 t.Parallel()
5818
5819 t.Run("Success", func(t *testing.T) {
5820 t.Parallel()
5821
5822 ctx := testutil.Context(t, testutil.WaitLong)
5823 client := newChatClient(t)
5824 firstUser := coderdtest.CreateFirstUser(t, client.Client)
5825 _ = createChatModelConfig(t, client)
5826
5827 chat, err := client.CreateChat(ctx, codersdk.CreateChatRequest{
5828 OrganizationID: firstUser.OrganizationID,
5829 Content: []codersdk.ChatInputPart{
5830 {
5831 Type: codersdk.ChatInputPartTypeText,
5832 Text: "archive then unarchive me",
5833 },
5834 },
5835 })
5836 require.NoError(t, err)
5837
5838 // Archive the chat first.
5839 err = client.UpdateChat(ctx, chat.ID, codersdk.UpdateChatRequest{Archived: ptr.Ref(true)})
5840 require.NoError(t, err)
5841
5842 // Verify it's archived.
5843 archivedChats, err := client.ListChats(ctx, &codersdk.ListChatsOptions{
5844 Query: "archived:true",
5845 })
5846 require.NoError(t, err)
5847 require.Len(t, archivedChats, 1)
5848 require.True(t, archivedChats[0].Archived)
5849 // Unarchive the chat.
5850 err = client.UpdateChat(ctx, chat.ID, codersdk.UpdateChatRequest{Archived: ptr.Ref(false)})
5851 require.NoError(t, err)
5852
5853 // Verify it's no longer archived.
5854 activeChats, err := client.ListChats(ctx, &codersdk.ListChatsOptions{
5855 Query: "archived:false",
5856 })
5857 require.NoError(t, err)
5858 require.Len(t, activeChats, 1)
5859 require.Equal(t, chat.ID, activeChats[0].ID)
5860 require.False(t, activeChats[0].Archived)
5861
5862 // No archived chats remain.
5863 archivedChats, err = client.ListChats(ctx, &codersdk.ListChatsOptions{
5864 Query: "archived:true",
5865 })
5866 require.NoError(t, err)
5867 require.Empty(t, archivedChats)
5868 })
5869
5870 t.Run("UnarchivesChildren", func(t *testing.T) {
5871 t.Parallel()
5872
5873 ctx := testutil.Context(t, testutil.WaitLong)

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
CreateFirstUserFunction · 0.92
RefFunction · 0.92
ChatFunction · 0.92
AsSystemRestrictedFunction · 0.92
requireSDKErrorFunction · 0.85
ListChatsMethod · 0.80
newChatClientFunction · 0.70
createChatModelConfigFunction · 0.70
RunMethod · 0.65
CreateChatMethod · 0.65

Tested by

no test coverage detected