hunk.code_window:         return null;
       }
       getEarliestPost(id) {
           if (this.postsInfo.hasOwnProperty(id)) {
               const postList = this.postsInfo[id].postList;
               for (let i = postList.order.length - 1; i >= 0; i--) {
                   const postId = postList.order[i];
                   if (postList.posts[postId].state !== Constants.POST_DELETED) {
                       return postList.posts[postId];
                   }
               }
           }
           return null;
       }
       getLatestPost(id) {
  
hunk.labels: keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep
hunk.after_edit:     getEarliestPostFromPage(id) {
           return this.earliestPostFromPage[id];
  
hunk.file_path: webapp/stores/post_store.jsx
hunk.type: replace
file: package route53
  
  import (
  	"fmt"
  	"net/http"
  	"net/http/httptest"
  	"testing"
  	"time"
  
  	"github.com/stretchr/testify/require"
  )
  
  // MockResponse represents a predefined response used by a mock server
  type MockResponse struct {
  	StatusCode int
  	Body       string
  }
  
  // MockResponseMap maps request paths to responses
  type MockResponseMap map[string]MockResponse
  
  func newMockServer(t *testing.T, responses MockResponseMap) *httptest.Server {
  	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
  		path := r.URL.Path
  		resp, ok := responses[path]
  		if !ok {
  			msg := fmt.Sprintf("Requested path not found in response map: %s", path)
  			require.FailNow(t, msg)
  		}
  
  		w.Header().Set("Content-Type", "application/xml")
  		w.WriteHeader(resp.StatusCode)
  		w.Write([]byte(resp.Body))
  	}))
  
  	time.Sleep(100 * time.Millisecond)
  	return ts
  }
  