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

Function TestChatDesktopEnabled

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

Source from the content-addressed store, hash-verified

12055}
12056
12057func TestChatDesktopEnabled(t *testing.T) {
12058 t.Parallel()
12059
12060 t.Run("ReturnsFalseWhenUnset", func(t *testing.T) {
12061 t.Parallel()
12062 ctx := testutil.Context(t, testutil.WaitLong)
12063
12064 adminClient := newChatClient(t)
12065 coderdtest.CreateFirstUser(t, adminClient.Client)
12066
12067 resp, err := adminClient.GetChatDesktopEnabled(ctx)
12068 require.NoError(t, err)
12069 require.False(t, resp.EnableDesktop)
12070 })
12071
12072 t.Run("AdminCanSetTrue", func(t *testing.T) {
12073 t.Parallel()
12074 ctx := testutil.Context(t, testutil.WaitLong)
12075
12076 adminClient := newChatClient(t)
12077 coderdtest.CreateFirstUser(t, adminClient.Client)
12078
12079 err := adminClient.UpdateChatDesktopEnabled(ctx, codersdk.UpdateChatDesktopEnabledRequest{
12080 EnableDesktop: true,
12081 })
12082 require.NoError(t, err)
12083
12084 resp, err := adminClient.GetChatDesktopEnabled(ctx)
12085 require.NoError(t, err)
12086 require.True(t, resp.EnableDesktop)
12087 })
12088
12089 t.Run("AdminCanSetFalse", func(t *testing.T) {
12090 t.Parallel()
12091 ctx := testutil.Context(t, testutil.WaitLong)
12092
12093 adminClient := newChatClient(t)
12094 coderdtest.CreateFirstUser(t, adminClient.Client)
12095
12096 // Set true first, then set false.
12097 err := adminClient.UpdateChatDesktopEnabled(ctx, codersdk.UpdateChatDesktopEnabledRequest{
12098 EnableDesktop: true,
12099 })
12100 require.NoError(t, err)
12101
12102 err = adminClient.UpdateChatDesktopEnabled(ctx, codersdk.UpdateChatDesktopEnabledRequest{
12103 EnableDesktop: false,
12104 })
12105 require.NoError(t, err)
12106
12107 resp, err := adminClient.GetChatDesktopEnabled(ctx)
12108 require.NoError(t, err)
12109 require.False(t, resp.EnableDesktop)
12110 })
12111
12112 t.Run("NonAdminCanRead", func(t *testing.T) {
12113 t.Parallel()
12114 ctx := testutil.Context(t, testutil.WaitLong)

Callers

nothing calls this directly

Calls 13

GetChatDesktopEnabledMethod · 0.95
StatusCodeMethod · 0.95
ContextFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
NewExperimentalClientFunction · 0.92
NewFunction · 0.92
requireSDKErrorFunction · 0.85
newChatClientFunction · 0.70
RunMethod · 0.65
GetChatDesktopEnabledMethod · 0.65

Tested by

no test coverage detected