(t *testing.T)
| 5814 | } |
| 5815 | |
| 5816 | func 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) |
nothing calls this directly
no test coverage detected