provide required accountId prop

flag=none

test plan:
  - specs pass

qa risk: low

Change-Id: Ia5b6ae2252216c707cd6ea6497b6b4438cb2d1ae
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274434
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
QA-Review: Rob Orton <rob@instructure.com>
Product-Review: Rob Orton <rob@instructure.com>
This commit is contained in:
Davis Hyer 2021-09-24 15:32:52 -06:00
parent 32c2233c65
commit f2ad23a82a
3 changed files with 80 additions and 162 deletions

View File

@ -77,7 +77,6 @@ const ignoredErrors = [
/Render methods should be a pure function of props and state/,
/The 'screenReaderOnly' prop must be used in conjunction with 'liveRegion'/,
/The above error occurred in the <.*> component/,
/The prop `accountId` is marked as required in `(SecurityPanel|Whitelist)`/,
/The prop `activeMailbox` is marked as required in `MailboxSelectionDropdown`/,
/The prop `allSubmissions\[0\]._id` is marked as required in `Header`/,
/The prop `app.courses\[0\].id` is marked as required in `K5AppLink`/,

View File

@ -21,6 +21,14 @@ import {fireEvent} from '@testing-library/react'
import {ConnectedSecurityPanel} from '../SecurityPanel'
import {renderWithRedux} from './utils'
const defaultProps = {
context: 'account',
accountId: '1',
contextId: '1',
maxDomains: 50,
liveRegion: []
}
describe('ConnectedSecurityPanel', () => {
beforeEach(() => {
window.ENV = {
@ -29,9 +37,7 @@ describe('ConnectedSecurityPanel', () => {
})
it('updates CSP enabled status when the checkbox is clicked', () => {
const {getByLabelText} = renderWithRedux(
<ConnectedSecurityPanel context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText} = renderWithRedux(<ConnectedSecurityPanel {...defaultProps} />)
const checkbox = getByLabelText('Enable Content Security Policy')
fireEvent.click(checkbox)
@ -41,13 +47,7 @@ describe('ConnectedSecurityPanel', () => {
describe('isSubAccount prop', () => {
it('updates CSP inherited status when the inherit checkbox is clicked', () => {
const {getByLabelText} = renderWithRedux(
<ConnectedSecurityPanel
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
isSubAccount
/>
<ConnectedSecurityPanel {...defaultProps} isSubAccount />
)
const checkbox = getByLabelText('Inherit Content Security Policy')
@ -57,13 +57,7 @@ describe('ConnectedSecurityPanel', () => {
it('disables the enable checkbox when the inherit option is set to true', () => {
const {getByLabelText} = renderWithRedux(
<ConnectedSecurityPanel
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
isSubAccount
/>
<ConnectedSecurityPanel {...defaultProps} isSubAccount />
)
const checkbox = getByLabelText('Inherit Content Security Policy')

View File

@ -21,6 +21,14 @@ import {fireEvent} from '@testing-library/react'
import {ConnectedWhitelist} from '../Whitelist'
import {renderWithRedux} from './utils'
const defaultProps = {
context: 'account',
accountId: '1',
contextId: '1',
maxDomains: 50,
liveRegion: []
}
describe('ConnectedWhitelist', () => {
beforeEach(() => {
window.ENV = {
@ -29,9 +37,7 @@ describe('ConnectedWhitelist', () => {
})
it('renders items on the allowed domain list after they are added', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const domainInput = getByLabelText('Domain Name')
fireEvent.input(domainInput, {target: {value: 'instructure.com'}})
@ -44,9 +50,7 @@ describe('ConnectedWhitelist', () => {
})
it('handles adding wildcard entries to the allowed domain list', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const domainInput = getByLabelText('Domain Name')
fireEvent.input(domainInput, {target: {value: '*.instructure.com'}})
@ -59,42 +63,35 @@ describe('ConnectedWhitelist', () => {
})
it('renders the empty state when there are no domains', () => {
const {getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const emptyState = getByText('No allowed domains')
expect(emptyState).toBeInTheDocument()
})
it('renders the tools domain list when present', () => {
const {getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: ['instructure.com'],
tools: {
'eduappcenter.com': [
{
id: '1',
name: 'Cool Tool 1',
account_id: '1'
}
]
}
const {getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: ['instructure.com'],
tools: {
'eduappcenter.com': [
{
id: '1',
name: 'Cool Tool 1',
account_id: '1'
}
]
}
}
}
)
})
const toolDomain = getByText('eduappcenter.com')
expect(toolDomain).toBeInTheDocument()
})
it('shows an error message when an invalid domain is entered', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const domainInput = getByLabelText('Domain Name')
fireEvent.input(domainInput, {target: {value: 'fake'}})
@ -107,9 +104,7 @@ describe('ConnectedWhitelist', () => {
})
it('shows the correct count for the domain list', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const domainInput = getByLabelText('Domain Name')
fireEvent.input(domainInput, {target: {value: 'instructure.com'}})
@ -122,9 +117,7 @@ describe('ConnectedWhitelist', () => {
})
it('clears the input box after a successful submisssion', () => {
const {getByLabelText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />
)
const {getByLabelText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />)
const domainInput = getByLabelText('Domain Name')
fireEvent.input(domainInput, {target: {value: 'instructure.com'}})
@ -136,16 +129,13 @@ describe('ConnectedWhitelist', () => {
})
it('removes items when clicking the delete icon', () => {
const {getByText, queryByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
const {getByText, queryByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
}
)
})
const TEXT = 'Remove instructure.com as an allowed domain'
@ -155,16 +145,13 @@ describe('ConnectedWhitelist', () => {
})
it('sets focus to the previous domain delete icon when deleting', () => {
const {getByText, getByTestId} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
const {getByText, getByTestId} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
}
)
})
const button = getByText('Remove canvaslms.com as an allowed domain')
fireEvent.click(button)
@ -174,16 +161,13 @@ describe('ConnectedWhitelist', () => {
})
it('sets focus to the the add domain button when removing the first positioned domain from the allowed domain list', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: ['instructure.com', 'canvaslms.com']
}
}
)
})
const deleteButton = getByText('Remove instructure.com as an allowed domain')
fireEvent.click(deleteButton)
@ -192,16 +176,13 @@ describe('ConnectedWhitelist', () => {
})
it('sets focus to the add domain button when removing the last remaining domain from the allowed domain list', () => {
const {getByLabelText, getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: ['instructure.com']
}
const {getByLabelText, getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: ['instructure.com']
}
}
)
})
const deleteButton = getByText('Remove instructure.com as an allowed domain')
fireEvent.click(deleteButton)
@ -215,16 +196,13 @@ describe('ConnectedWhitelist', () => {
for (let i = 0; i < 50; i++) {
exampleDomains.push(`domain-${i}.com`)
}
const {getByLabelText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: exampleDomains
}
const {getByLabelText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: exampleDomains
}
}
)
})
const addDomainButton = getByLabelText('Add Domain')
expect(addDomainButton).toBeDisabled()
@ -235,16 +213,13 @@ describe('ConnectedWhitelist', () => {
for (let i = 0; i < 50; i++) {
exampleDomains.push(`domain-${i}.com`)
}
const {getByText} = renderWithRedux(
<ConnectedWhitelist context="account" contextId="1" maxDomains={50} liveRegion={[]} />,
{
initialState: {
whitelistedDomains: {
account: exampleDomains
}
const {getByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} />, {
initialState: {
whitelistedDomains: {
account: exampleDomains
}
}
)
})
const domainMessage = getByText(/You have reached the domain limit/)
expect(domainMessage).toBeInTheDocument()
@ -256,23 +231,14 @@ describe('ConnectedWhitelist', () => {
for (let i = 0; i < 50; i++) {
exampleDomains.push(`domain-${i}.com`)
}
const {queryByText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
/>,
{
initialState: {
whitelistedDomains: {
account: [],
inherited: exampleDomains
}
const {queryByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} inherited />, {
initialState: {
whitelistedDomains: {
account: [],
inherited: exampleDomains
}
}
)
})
const domainMessage = queryByText(/You have reached the domain limit/)
expect(domainMessage).toBeNull()
@ -280,14 +246,7 @@ describe('ConnectedWhitelist', () => {
it('shows an information message indicating that switching to custom will allow changes', () => {
const {getByText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
isSubAccount
/>,
<ConnectedWhitelist {...defaultProps} inherited isSubAccount />,
{
initialState: {
whitelistedDomains: {
@ -306,13 +265,7 @@ describe('ConnectedWhitelist', () => {
it('shows the allowed domain list from the inherited account', () => {
const {getByText, queryByText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
/>,
<ConnectedWhitelist {...defaultProps} inherited />,
{
initialState: {
whitelistedDomains: {
@ -332,13 +285,7 @@ describe('ConnectedWhitelist', () => {
it('does not show the count for the allowed domain list', () => {
const {queryByText, getByText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
/>
<ConnectedWhitelist {...defaultProps} inherited />
)
const wrongString = queryByText('Domains (0/50)')
@ -350,14 +297,7 @@ describe('ConnectedWhitelist', () => {
it('does not allow adding items to the list', () => {
const {getByLabelText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
isSubAccount
/>,
<ConnectedWhitelist {...defaultProps} inherited isSubAccount />,
{
initialState: {
whitelistedDomains: {
@ -374,14 +314,7 @@ describe('ConnectedWhitelist', () => {
it('does not allow removing items from the list', () => {
const {getByRole} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
inherited
isSubAccount
/>,
<ConnectedWhitelist {...defaultProps} inherited isSubAccount />,
{
initialState: {
whitelistedDomains: {
@ -399,15 +332,7 @@ describe('ConnectedWhitelist', () => {
describe('isSubAccount', () => {
it('does not show the option to view a violation log', () => {
const {queryByText} = renderWithRedux(
<ConnectedWhitelist
context="account"
contextId="1"
maxDomains={50}
liveRegion={[]}
isSubAccount
/>
)
const {queryByText} = renderWithRedux(<ConnectedWhitelist {...defaultProps} isSubAccount />)
const violationLogBtn = queryByText('View Violation Log')
expect(violationLogBtn).toBeNull()
})