From 02f6659ceb9c345628ad5eda0f7e36897bd2aa2a Mon Sep 17 00:00:00 2001 From: tony-tvu Date: Wed, 14 Feb 2024 14:03:43 -0600 Subject: [PATCH] remove non-current user test --- .../UserContactMethodListDest.stories.tsx | 218 ++++++------------ .../app/users/UserContactMethodListDest.tsx | 2 +- 2 files changed, 76 insertions(+), 144 deletions(-) diff --git a/web/src/app/users/UserContactMethodListDest.stories.tsx b/web/src/app/users/UserContactMethodListDest.stories.tsx index b5014cf655..abc4f310df 100644 --- a/web/src/app/users/UserContactMethodListDest.stories.tsx +++ b/web/src/app/users/UserContactMethodListDest.stories.tsx @@ -5,130 +5,6 @@ import { expect, within, userEvent, screen } from '@storybook/test' import { handleDefaultConfig, handleExpFlags } from '../storybook/graphql' import { HttpResponse, graphql } from 'msw' -interface UserCMResponse { - user: { - id: string - contactMethods: { - id: string - name: string - dest: { - type: string - values: { - fieldID: string - value: string - label: string - }[] - } - disabled: boolean - pending: boolean - }[] - } -} - -function getUserCMData(userID: string): UserCMResponse | undefined { - if (userID === '00000000-0000-0000-0000-000000000000') { - return { - user: { - id: '00000000-0000-0000-0000-000000000000', - contactMethods: [ - { - id: '12345', - name: 'Josiah', - dest: { - type: 'single-field', - values: [ - { - fieldID: 'phone-number', - value: '+15555555555', - label: '+1 555-555-5555', - }, - ], - }, - disabled: false, - pending: false, - }, - ], - }, - } - } - if (userID === '00000000-0000-0000-0000-000000000001') { - return { - user: { - id: '00000000-0000-0000-0000-000000000001', - contactMethods: [ - { - id: '12345', - name: 'non_current_user', - dest: { - type: 'single-field', - values: [ - { - fieldID: 'phone-number', - value: '+15555555555', - label: '+1 555-555-5555', - }, - ], - }, - disabled: false, - pending: false, - }, - ], - }, - } - } - if (userID === '00000000-0000-0000-0000-000000000002') { - return { - user: { - id: '00000000-0000-0000-0000-000000000002', - contactMethods: [ - { - id: '67890', - name: 'triple contact method', - dest: { - type: 'triple-field', - values: [ - { - fieldID: 'first-field', - value: '+15555555555', - label: '+1 555-555-5555', - }, - { - fieldID: 'second-field', - value: 'test_user@target.com', - label: 'test_user@target.com', - }, - { - fieldID: 'third-field', - value: 'U03SM0U8TPE', - label: '@TestUser', - }, - ], - }, - disabled: false, - pending: false, - }, - { - id: '1111', - name: 'my_webhook', - dest: { - type: 'webhook-field', - values: [ - { - fieldID: 'webhook-url', - value: 'https://target.com', - label: 'https://target.com', - }, - ], - }, - disabled: false, - pending: false, - }, - ], - }, - } - } -} - const meta = { title: 'users/UserContactMethodListDest', component: UserContactMethodListDest, @@ -140,7 +16,80 @@ const meta = { handleExpFlags('dest-types'), graphql.query('cmList', ({ variables: vars }) => { return HttpResponse.json({ - data: getUserCMData(vars.id), + data: + vars.id === '00000000-0000-0000-0000-000000000000' + ? { + user: { + id: '00000000-0000-0000-0000-000000000000', + contactMethods: [ + { + id: '12345', + name: 'Josiah', + dest: { + type: 'single-field', + values: [ + { + fieldID: 'phone-number', + value: '+15555555555', + label: '+1 555-555-5555', + }, + ], + }, + disabled: false, + pending: false, + }, + ], + }, + } + : { + user: { + id: '00000000-0000-0000-0000-000000000001', + contactMethods: [ + { + id: '67890', + name: 'triple contact method', + dest: { + type: 'triple-field', + values: [ + { + fieldID: 'first-field', + value: '+15555555555', + label: '+1 555-555-5555', + }, + { + fieldID: 'second-field', + value: 'test_user@target.com', + label: 'test_user@target.com', + }, + { + fieldID: 'third-field', + value: 'U03SM0U8TPE', + label: '@TestUser', + }, + ], + }, + disabled: false, + pending: false, + }, + { + id: '1111', + name: 'my_webhook', + dest: { + type: 'webhook-field', + values: [ + { + fieldID: 'webhook-url', + value: 'https://target.com', + label: 'https://target.com', + }, + ], + }, + disabled: false, + pending: false, + }, + ], + }, + }, }) }), ], @@ -190,7 +139,7 @@ export const SingleContactMethod: Story = { export const MultiContactMethods: Story = { args: { - userID: '00000000-0000-0000-0000-000000000002', + userID: '00000000-0000-0000-0000-000000000001', readOnly: false, }, play: async ({ canvasElement }) => { @@ -236,20 +185,3 @@ export const SingleReadOnlyContactMethods: Story = { ).not.toBeInTheDocument() }, } - -export const NonCurrentUser: Story = { - args: { - userID: '00000000-0000-0000-0000-000000000001', - readOnly: false, - }, - play: async ({ canvasElement }) => { - const canvas = within(canvasElement) - - // ensure non-current user cannot send test to user CM - await userEvent.click(await canvas.findByTestId('MoreHorizIcon')) - await expect(await screen.findByText('Send Test')).toHaveAttribute( - 'aria-disabled', - 'true', - ) - }, -} diff --git a/web/src/app/users/UserContactMethodListDest.tsx b/web/src/app/users/UserContactMethodListDest.tsx index 147ca5ab37..4c75880f4c 100644 --- a/web/src/app/users/UserContactMethodListDest.tsx +++ b/web/src/app/users/UserContactMethodListDest.tsx @@ -23,7 +23,7 @@ import { GenericError, ObjectNotFound } from '../error-pages' import SendTestDialog from './SendTestDialog' import AppLink from '../util/AppLink' import { styles as globalStyles } from '../styles/materialStyles' -import { FieldValuePair, UserContactMethod } from '../../schema' +import { UserContactMethod } from '../../schema' import UserContactMethodCreateDialog from './UserContactMethodCreateDialog' import { useSessionInfo } from '../util/RequireConfig'