@@ -4,12 +4,18 @@ import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
4
4
import ProjectToolbarSettings from 'sentry/views/settings/project/projectToolbar' ;
5
5
6
6
describe ( 'ProjectToolbarSettings' , function ( ) {
7
- const { routerProps , organization, project} = initializeOrg ( {
7
+ const { organization, project} = initializeOrg ( {
8
8
organization : {
9
9
features : [ 'sentry-toolbar-ui' ] ,
10
10
} ,
11
11
} ) ;
12
- const url = `/projects/${ organization . slug } /${ project . slug } /` ;
12
+ const initialRouterConfig = {
13
+ location : {
14
+ pathname : `/settings/projects/${ project . slug } /toolbar/` ,
15
+ } ,
16
+ route : '/settings/projects/:projectId/toolbar/' ,
17
+ } ;
18
+ const getProjectEndpoint = `/projects/${ organization . slug } /${ project . slug } /` ;
13
19
14
20
beforeEach ( function ( ) {
15
21
MockApiClient . clearMockResponses ( ) ;
@@ -18,27 +24,21 @@ describe('ProjectToolbarSettings', function () {
18
24
it ( 'displays previously saved setting' , function ( ) {
19
25
const initialOptionValue = 'sentry.io' ;
20
26
project . options = { 'sentry:toolbar_allowed_origins' : initialOptionValue } ;
21
- render (
22
- < ProjectToolbarSettings
23
- { ...routerProps }
24
- organization = { organization }
25
- project = { project }
26
- />
27
- ) ;
27
+ render ( < ProjectToolbarSettings project = { project } /> , {
28
+ initialRouterConfig,
29
+ organization,
30
+ } ) ;
28
31
expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( initialOptionValue ) ;
29
32
} ) ;
30
33
31
34
it ( 'can submit new allowed origins' , async function ( ) {
32
- render (
33
- < ProjectToolbarSettings
34
- { ...routerProps }
35
- organization = { organization }
36
- project = { project }
37
- />
38
- ) ;
35
+ render ( < ProjectToolbarSettings project = { project } /> , {
36
+ initialRouterConfig,
37
+ organization,
38
+ } ) ;
39
39
40
40
const mockPut = MockApiClient . addMockResponse ( {
41
- url,
41
+ url : getProjectEndpoint ,
42
42
method : 'PUT' ,
43
43
} ) ;
44
44
@@ -51,7 +51,7 @@ describe('ProjectToolbarSettings', function () {
51
51
await userEvent . tab ( ) ; // unfocus ("blur") the input
52
52
53
53
expect ( mockPut ) . toHaveBeenCalledWith (
54
- url ,
54
+ getProjectEndpoint ,
55
55
expect . objectContaining ( {
56
56
method : 'PUT' ,
57
57
data : {
@@ -63,25 +63,19 @@ describe('ProjectToolbarSettings', function () {
63
63
64
64
it ( 'displays nothing when project options are undefined' , function ( ) {
65
65
project . options = undefined ;
66
- render (
67
- < ProjectToolbarSettings
68
- { ...routerProps }
69
- organization = { organization }
70
- project = { project }
71
- />
72
- ) ;
66
+ render ( < ProjectToolbarSettings project = { project } /> , {
67
+ initialRouterConfig,
68
+ organization,
69
+ } ) ;
73
70
expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( '' ) ;
74
71
} ) ;
75
72
76
73
it ( 'displays nothing when project options are empty' , function ( ) {
77
74
project . options = { } ;
78
- render (
79
- < ProjectToolbarSettings
80
- { ...routerProps }
81
- organization = { organization }
82
- project = { project }
83
- />
84
- ) ;
75
+ render ( < ProjectToolbarSettings project = { project } /> , {
76
+ initialRouterConfig,
77
+ organization,
78
+ } ) ;
85
79
expect ( screen . getByRole ( 'textbox' ) ) . toHaveValue ( '' ) ;
86
80
} ) ;
87
81
} ) ;
0 commit comments