@@ -160,69 +160,20 @@ describe('Action Input operations for fetching all inputs, triggering validation
160160
161161 it ( 'Returns true if rerun was triggered by the GitHub App' , async ( ) => {
162162 const actionInput = new ActionInput ( ) ;
163- sinon . stub ( actionInput , 'identifyRunFromBStack' ) . returns ( Promise . resolve ( ' validatedAppName') ) ;
163+ process . env . GITHUB_TRIGGERING_ACTOR = ' validatedAppName';
164164 const result = await actionInput . checkIfBStackReRun ( ) ;
165165 // eslint-disable-next-line no-unused-expressions
166166 expect ( result ) . to . be . true ;
167+ delete process . env . GITHUB_TRIGGERING_ACTOR ;
167168 } ) ;
168169
169170 it ( 'Returns false if rerun was not triggered by the GitHub App' , async ( ) => {
170171 const actionInput = new ActionInput ( ) ;
171- sinon . stub ( actionInput , 'identifyRunFromBStack' ) . returns ( Promise . resolve ( ' otherActor') ) ;
172+ process . env . GITHUB_TRIGGERING_ACTOR = ' otherActor';
172173 const result = await actionInput . checkIfBStackReRun ( ) ;
173174 // eslint-disable-next-line no-unused-expressions
174175 expect ( result ) . to . be . false ;
175- } ) ;
176- } ) ;
177-
178- context ( 'Identify Run From BrowserStack' , ( ) => {
179- let axiosGetStub ;
180- let stubbedInput ;
181-
182- beforeEach ( ( ) => {
183- stubbedInput = sinon . stub ( core , 'getInput' ) ;
184- sinon . stub ( InputValidator , 'updateUsername' ) . returns ( 'validatedUsername' ) ;
185- sinon . stub ( InputValidator , 'validateBuildName' ) . returns ( 'validatedBuildName' ) ;
186- sinon . stub ( InputValidator , 'validateProjectName' ) . returns ( 'validatedProjectName' ) ;
187- sinon . stub ( InputValidator , 'validateGithubAppName' ) . returns ( 'validatedAppName' ) ;
188- sinon . stub ( InputValidator , 'validateGithubToken' ) . returns ( 'validatedToken' ) ;
189-
190- // Provide required inputs
191- stubbedInput . withArgs ( INPUT . USERNAME , { required : true } ) . returns ( 'someUsername' ) ;
192- stubbedInput . withArgs ( INPUT . ACCESS_KEY , { required : true } ) . returns ( 'someAccessKey' ) ;
193-
194- process . env . GITHUB_REPOSITORY = 'browserstack/github-actions' ;
195- process . env . GITHUB_RUN_ID = '12345' ;
196- process . env . GITHUB_RUN_ATTEMPT = '2' ;
197-
198- // Stub the axios.get method
199- axiosGetStub = sinon . stub ( axios , 'get' ) ;
200- // Stub core.info to prevent it from throwing an error
201- sinon . stub ( core , 'info' ) ;
202- } ) ;
203-
204- afterEach ( ( ) => {
205- sinon . restore ( ) ;
206- } ) ;
207-
208- it ( 'Returns the triggering actor from the GitHub API' , async ( ) => {
209- const actionInput = new ActionInput ( ) ;
210- axiosGetStub . resolves ( {
211- data : {
212- triggering_actor : { login : 'someActor' } ,
213- } ,
214- } ) ;
215- const result = await actionInput . identifyRunFromBStack ( ) ;
216- expect ( result ) . to . eq ( 'someActor' ) ;
217- } ) ;
218-
219- it ( 'Handles errors and returns undefined when GitHub API fails' , async ( ) => {
220- const actionInput = new ActionInput ( ) ;
221- axiosGetStub . rejects ( new Error ( 'API failed' ) ) ;
222- const result = await actionInput . identifyRunFromBStack ( ) ;
223- // eslint-disable-next-line no-unused-expressions
224- expect ( result ) . to . be . undefined ;
225- sinon . assert . calledOnce ( core . info ) ;
176+ delete process . env . GITHUB_TRIGGERING_ACTOR ;
226177 } ) ;
227178 } ) ;
228179
0 commit comments