@@ -98,6 +98,23 @@ describe("pages deployment tail", () => {
9898 await api . closeHelper ( ) ;
9999 } ) ;
100100
101+ it ( "only uses deployments with status=success and name=deploy" , async ( ) => {
102+ setIsTTY ( true ) ;
103+
104+ api = mockTailAPIs ( "mock-deployment-id" ) ;
105+ expect ( api . requests . creation . length ) . toStrictEqual ( 0 ) ;
106+
107+ await runWrangler ( "pages deployment tail --project-name mock-project" ) ;
108+
109+ await expect ( api . ws . connected ) . resolves . toBeTruthy ( ) ;
110+ expect ( api . requests . creation . length ) . toStrictEqual ( 1 ) ;
111+ expect ( api . requests . deletion . count ) . toStrictEqual ( 0 ) ;
112+
113+ await api . closeHelper ( ) ;
114+ expect ( api . requests . deletion . count ) . toStrictEqual ( 1 ) ;
115+ await api . closeHelper ( ) ;
116+ } ) ;
117+
101118 it ( "creates and then deletes tails by deployment URL" , async ( ) => {
102119 api = mockTailAPIs ( ) ;
103120 expect ( api . requests . creation . length ) . toStrictEqual ( 0 ) ;
@@ -887,6 +904,24 @@ function mockListDeployments(): RequestLogger {
887904 errors : [ ] ,
888905 messages : [ ] ,
889906 result : [
907+ {
908+ id : "mock-deployment-id-skipped" ,
909+ url : "https://abc123.mock.pages.dev" ,
910+ environment : "production" ,
911+ created_on : "2020-01-17T14:52:26.133835Z" ,
912+ latest_stage : {
913+ ended_on : "2020-01-17T14:52:26.133835Z" ,
914+ status : "skipped" ,
915+ name : "deploy" ,
916+ } ,
917+ deployment_trigger : {
918+ metadata : {
919+ branch : "main" ,
920+ commit_hash : "11122334c4cb32ad4f65b530b9424e8be5bec9d6" ,
921+ } ,
922+ } ,
923+ project_name : "mock-project" ,
924+ } ,
890925 {
891926 id : "mock-deployment-id" ,
892927 url : "https://87bbc8fe.mock.pages.dev" ,
@@ -895,6 +930,7 @@ function mockListDeployments(): RequestLogger {
895930 latest_stage : {
896931 ended_on : "2021-11-17T14:52:26.133835Z" ,
897932 status : "success" ,
933+ name : "deploy" ,
898934 } ,
899935 deployment_trigger : {
900936 metadata : {
@@ -921,11 +957,13 @@ function mockListDeployments(): RequestLogger {
921957 *
922958 * @returns a `RequestCounter` for counting how many times the API is hit
923959 */
924- function mockCreateTailRequest ( ) : RequestInit [ ] {
960+ function mockCreateTailRequest (
961+ deploymentId : string = ":deploymentId"
962+ ) : RequestInit [ ] {
925963 const requests : RequestInit [ ] = [ ] ;
926964 msw . use (
927965 http . post (
928- `*/accounts/:accountId/pages/projects/:projectName/deployments/: deploymentId/tails` ,
966+ `*/accounts/:accountId/pages/projects/:projectName/deployments/${ deploymentId } /tails` ,
929967 async ( { request } ) => {
930968 requests . push ( ( await request . json ( ) ) as RequestInit ) ;
931969 return HttpResponse . json (
@@ -1022,7 +1060,9 @@ const websocketURL = "ws://localhost:1234";
10221060 * @param websocketURL a fake websocket URL for wrangler to connect to
10231061 * @returns a mocked-out version of the API
10241062 */
1025- function mockTailAPIs ( ) : MockAPI {
1063+ function mockTailAPIs (
1064+ expectedCreateDeploymentId : string = ":deploymentId"
1065+ ) : MockAPI {
10261066 const api : MockAPI = {
10271067 requests : {
10281068 deletion : { count : 0 } ,
@@ -1054,7 +1094,7 @@ function mockTailAPIs(): MockAPI {
10541094 api . ws = new MockWebSocketServer ( websocketURL ) ;
10551095 mockWebSockets . push ( api . ws ) ;
10561096
1057- api . requests . creation = mockCreateTailRequest ( ) ;
1097+ api . requests . creation = mockCreateTailRequest ( expectedCreateDeploymentId ) ;
10581098 api . requests . deletion = mockDeleteTailRequest ( ) ;
10591099 api . requests . deployments = mockListDeployments ( ) ;
10601100
0 commit comments