11import { OrganizationFixture } from 'sentry-fixture/organization' ;
22import { ProjectFixture } from 'sentry-fixture/project' ;
33
4- import { render , screen } from 'sentry-test/reactTestingLibrary' ;
4+ import { render , screen , userEvent } from 'sentry-test/reactTestingLibrary' ;
55
66import { OrganizationStore } from 'sentry/stores/organizationStore' ;
77import { ProjectsStore } from 'sentry/stores/projectsStore' ;
@@ -58,7 +58,7 @@ describe('NewCronDetectorForm', () => {
5858
5959 // Form sections should be visible
6060 expect ( await screen . findByText ( / D e t e c t / ) ) . toBeInTheDocument ( ) ;
61- expect ( screen . getByText ( / A s s i g n / ) ) . toBeInTheDocument ( ) ;
61+ expect ( screen . getByText ( / \d \. A s s i g n / ) ) . toBeInTheDocument ( ) ;
6262 expect ( screen . getByText ( / D e s c r i p t i o n / ) ) . toBeInTheDocument ( ) ;
6363
6464 // Create Monitor button should be present and enabled
@@ -80,15 +80,34 @@ describe('NewCronDetectorForm', () => {
8080
8181 // Form sections should be hidden
8282 expect ( screen . queryByText ( / D e t e c t / ) ) . not . toBeInTheDocument ( ) ;
83- expect ( screen . queryByText ( / A s s i g n / ) ) . not . toBeInTheDocument ( ) ;
84- expect ( screen . queryByText ( / D e s c r i p t i o n / ) ) . not . toBeInTheDocument ( ) ;
8583
8684 // Create Monitor button should be present but disabled
8785 const createButton = screen . getByRole ( 'button' , { name : 'Create Monitor' } ) ;
8886 expect ( createButton ) . toBeInTheDocument ( ) ;
8987 expect ( createButton ) . toBeDisabled ( ) ;
9088 } ) ;
9189
90+ it ( 'renders issue preview and updates title when name changes' , async ( ) => {
91+ renderForm ( ) ;
92+
93+ // Issue preview section should render with fallback title
94+ expect ( await screen . findByTestId ( 'issue-preview-section' ) ) . toBeInTheDocument ( ) ;
95+ expect ( screen . getByText ( 'Cron failure: …' ) ) . toBeInTheDocument ( ) ;
96+ expect (
97+ screen . getByText ( 'Your monitor is failing: A missed check-in was detected' )
98+ ) . toBeInTheDocument ( ) ;
99+
100+ // Edit the monitor name
101+ const title = screen . getByText ( 'New Monitor' ) ;
102+ await userEvent . click ( title ) ;
103+ const nameInput = screen . getByRole ( 'textbox' , { name : 'Monitor Name' } ) ;
104+ await userEvent . clear ( nameInput ) ;
105+ await userEvent . type ( nameInput , 'My Cron Job{Enter}' ) ;
106+
107+ // Issue preview updates with the new name
108+ expect ( await screen . findByText ( 'Cron failure: My Cron Job' ) ) . toBeInTheDocument ( ) ;
109+ } ) ;
110+
92111 it ( 'shows form sections and enabled button when guide is set to "manual"' , async ( ) => {
93112 renderForm ( {
94113 location : {
@@ -99,7 +118,7 @@ describe('NewCronDetectorForm', () => {
99118
100119 // Form sections should be visible even with platform set, because guide is "manual"
101120 expect ( await screen . findByText ( / D e t e c t / ) ) . toBeInTheDocument ( ) ;
102- expect ( screen . getByText ( / A s s i g n / ) ) . toBeInTheDocument ( ) ;
121+ expect ( screen . getByText ( / \d \. A s s i g n / ) ) . toBeInTheDocument ( ) ;
103122 expect ( screen . getByText ( / D e s c r i p t i o n / ) ) . toBeInTheDocument ( ) ;
104123
105124 // Create Monitor button should be present and enabled
0 commit comments