|
1 | 1 | import { describe, expect, test } from 'bun:test' |
2 | 2 | import { |
3 | 3 | SPONSORED_ACCEPT_EXECUTION_SURFACE_PARAM, |
| 4 | + acceptClientSurfacePairsWithRow, |
4 | 5 | readSponsoredComputePolicy, |
5 | 6 | sponsoredAcceptSurfaceMatchesRow, |
6 | 7 | sponsoredComputeAdmitsCampaign, |
@@ -163,4 +164,34 @@ describe('the funded Accept request pairs the client with the row (COD-642)', () |
163 | 164 | // A client that cannot name its own surface matches nothing recorded. |
164 | 165 | expect(sponsoredAcceptSurfaceMatchesRow(null, 'desktop_macos')).toBe(false) |
165 | 166 | }) |
| 167 | + |
| 168 | + test('the Accept pairing: Windows only ever takes a Windows row, and a Windows row only a Windows client', () => { |
| 169 | + // One rule, applied by the server route and by Desktop before consent. |
| 170 | + expect( |
| 171 | + acceptClientSurfacePairsWithRow('desktop_windows', 'desktop_windows'), |
| 172 | + ).toBe(true) |
| 173 | + // Stricter than the plain match: an unrecorded row is never Windows. |
| 174 | + expect(acceptClientSurfacePairsWithRow('desktop_windows', undefined)).toBe( |
| 175 | + false, |
| 176 | + ) |
| 177 | + expect(acceptClientSurfacePairsWithRow('desktop_windows', null)).toBe(false) |
| 178 | + expect( |
| 179 | + acceptClientSurfacePairsWithRow('desktop_windows', 'desktop_macos'), |
| 180 | + ).toBe(false) |
| 181 | + // A client that sends nothing (older builds, the CLI) keeps its old rows |
| 182 | + // and never reaches a Windows one. |
| 183 | + expect(acceptClientSurfacePairsWithRow(undefined, 'desktop_macos')).toBe( |
| 184 | + true, |
| 185 | + ) |
| 186 | + expect(acceptClientSurfacePairsWithRow(undefined, undefined)).toBe(true) |
| 187 | + expect(acceptClientSurfacePairsWithRow(undefined, 'desktop_windows')).toBe( |
| 188 | + false, |
| 189 | + ) |
| 190 | + expect(acceptClientSurfacePairsWithRow('desktop_macos', undefined)).toBe( |
| 191 | + true, |
| 192 | + ) |
| 193 | + expect( |
| 194 | + acceptClientSurfacePairsWithRow('desktop_macos', 'desktop_windows'), |
| 195 | + ).toBe(false) |
| 196 | + }) |
166 | 197 | }) |
0 commit comments