Fisher's exact test is about comparing the probability parameters of two independent Binomials, and the test statistic is obtained by conditioning the random variable giving the proportion of successes in one sample (S1) on the random variable capturing the total number of successes across the two samples (S=S1+S2). S1 is neither the sample mean, nor the test statistic. The test statistic, call it T, is derived as P(T=t) = P(S1=s1 | S=s), using the simple definition of conditional probability and doing some simple algebra to show it follows a Hypergeometric distribution with known parameters. In no way does it follow from this example that the sample mean can be a test statistic.

Good lord. Yes, S1 is a test statistic there. That's why C&B literally refer to it as a "test statistic." No one claimed S1 is a sample mean. This example was pointed to because it illustrates a general principle that test statistics can be compared to distributions that are conditioned on observed statistics, which numerous posters claimed was not allowed. The specific example where the sample mean is used as a test statistic comes later, but uses the same principle. This has been explained roughly 8,000 times at this point, but they'll never, ever get it.