@@ -61,13 +61,12 @@ describe('JenkinsSetup Component', () => {
6161 jest . spyOn ( fetchGlobalPageUrlModule , 'fetchGlobalPageUrl' ) . mockResolvedValueOnce ( 'https://somesite.atlassian.net/blah' ) ;
6262 jest . spyOn ( getAllJenkinsServersModule , 'getAllJenkinsServers' ) . mockResolvedValueOnce ( [ ] ) ;
6363
64- const { getByText, queryByText } = render ( < JenkinsSetup /> ) ;
64+ const { getByText } = render ( < JenkinsSetup /> ) ;
6565 expect ( screen . getByTestId ( 'loading-spinner' ) ) . toBeInTheDocument ( ) ;
6666 expect ( getByText ( 'Connect Jenkins to Jira' ) ) . toBeInTheDocument ( ) ;
67- expect ( queryByText ( 'Server name:' ) ) . toBeNull ( ) ;
6867 } ) ;
6968
70- it ( 'should display the server name' , async ( ) => {
69+ it ( 'should have the server name in the Setup Content ' , async ( ) => {
7170 ( fetchGlobalPageUrlModule . fetchSiteName as jest . Mock ) . mockResolvedValueOnce ( 'https://mocked-site-name.com' ) ;
7271
7372 ( getJenkinsServerWithSecretModule . getJenkinsServerWithSecret as jest . Mock ) . mockResolvedValueOnce ( {
@@ -89,11 +88,11 @@ describe('JenkinsSetup Component', () => {
8988 render ( < JenkinsSetup /> ) ;
9089 } ) ;
9190
92- expect ( screen . getByText ( / S e r v e r n a m e : / i) ) . toBeInTheDocument ( ) ;
93- expect ( screen . getByText ( / S e r v e r n a m e : / i) ) . toHaveTextContent ( 'Mocked Server' ) ;
91+ expect ( screen . getByText ( / T o c o m p l e t e t h e c o n n e c t i o n f o r / i) ) . toBeInTheDocument ( ) ;
92+ expect ( screen . getByText ( / T o c o m p l e t e t h e c o n n e c t i o n f o r / i) ) . toHaveTextContent ( 'Mocked Server' ) ;
9493 } ) ;
9594
96- it ( 'toggles between "A Jenkins admin is helping me " and "I am the Jenkins admin" views' , async ( ) => {
95+ it ( 'toggles between "A Jenkins admin on my team " and "I am a Jenkins admin" views' , async ( ) => {
9796 ( fetchGlobalPageUrlModule . fetchSiteName as jest . Mock ) . mockResolvedValueOnce ( 'https://mocked-site-name.com' ) ;
9897
9998 ( getJenkinsServerWithSecretModule . getJenkinsServerWithSecret as jest . Mock ) . mockResolvedValueOnce ( {
@@ -118,13 +117,13 @@ describe('JenkinsSetup Component', () => {
118117 const { getByText, queryByText } = screen ;
119118
120119 await waitFor ( ( ) => {
121- fireEvent . click ( getByText ( 'A Jenkins admin is helping me ' ) ) ;
120+ fireEvent . click ( getByText ( 'A Jenkins admin on my team ' ) ) ;
122121 expect ( getByText ( 'Copy the items below and give them to your Jenkins admin' ) ) . toBeInTheDocument ( ) ;
123122 expect ( queryByText ( 'Log in to Jenkins in another window and use the items below to set up your server.' ) ) . not . toBeInTheDocument ( ) ;
124123 } ) ;
125124
126125 await waitFor ( ( ) => {
127- fireEvent . click ( getByText ( 'I\'m logging into Jenkins myself ' ) ) ;
126+ fireEvent . click ( getByText ( 'I am a Jenkins admin ' ) ) ;
128127 expect ( queryByText ( 'Copy the items below and give them to your Jenkins admin' ) ) . not . toBeInTheDocument ( ) ;
129128 expect ( getByText ( 'Log in to Jenkins in another window and use the items below to set up your server.' ) ) . toBeInTheDocument ( ) ;
130129 } ) ;
@@ -155,7 +154,7 @@ describe('JenkinsSetup Component', () => {
155154 const { getByText, getByTestId } = screen ;
156155
157156 await waitFor ( ( ) => {
158- fireEvent . click ( getByText ( 'A Jenkins admin is helping me ' ) ) ;
157+ fireEvent . click ( getByText ( 'A Jenkins admin on my team ' ) ) ;
159158 } ) ;
160159
161160 await act ( async ( ) => {
@@ -173,6 +172,12 @@ describe('JenkinsSetup Component', () => {
173172 fireEvent . click ( getByTestId ( 'i-am-the-jenkins-admin' ) ) ;
174173 } ) ;
175174
175+ await act ( async ( ) => {
176+ fireEvent . click ( getByTestId ( 'site-name-copy-button' ) ) ;
177+ } ) ;
178+
179+ expect ( document . execCommand ) . toHaveBeenCalledWith ( 'copy' ) ;
180+
176181 await act ( async ( ) => {
177182 fireEvent . click ( getByTestId ( 'copy-webhook-url' ) ) ;
178183 } ) ;
@@ -186,7 +191,7 @@ describe('JenkinsSetup Component', () => {
186191 expect ( document . execCommand ) . toHaveBeenCalledWith ( 'copy' ) ;
187192 } ) ;
188193
189- it ( 'displays "Next " button when either "A Jenkins admin is helping me " or "I\'m logging into Jenkins myself " is selected' , async ( ) => {
194+ it ( 'displays "Finish " button when either "A Jenkins admin on my team " or "I am a Jenkins admin " is selected' , async ( ) => {
190195 ( fetchGlobalPageUrlModule . fetchSiteName as jest . Mock ) . mockResolvedValueOnce ( 'https://mocked-site-name.com' ) ;
191196
192197 ( getJenkinsServerWithSecretModule . getJenkinsServerWithSecret as jest . Mock ) . mockResolvedValueOnce ( {
@@ -211,13 +216,13 @@ describe('JenkinsSetup Component', () => {
211216 const { getByText } = screen ;
212217
213218 await waitFor ( ( ) => {
214- fireEvent . click ( getByText ( 'A Jenkins admin is helping me ' ) ) ;
215- expect ( getByText ( 'Next ' ) ) . toBeInTheDocument ( ) ;
219+ fireEvent . click ( getByText ( 'A Jenkins admin on my team ' ) ) ;
220+ expect ( getByText ( 'Finish ' ) ) . toBeInTheDocument ( ) ;
216221 } ) ;
217222
218223 await waitFor ( ( ) => {
219- fireEvent . click ( getByText ( 'I\'m logging into Jenkins myself ' ) ) ;
220- expect ( getByText ( 'Next ' ) ) . toBeInTheDocument ( ) ;
224+ fireEvent . click ( getByText ( 'I am a Jenkins admin ' ) ) ;
225+ expect ( getByText ( 'Finish ' ) ) . toBeInTheDocument ( ) ;
221226 } ) ;
222227 } ) ;
223228} ) ;
0 commit comments