Skip to content

Commit 58a5da1

Browse files
authored
fix(e2e): Narrow range of fake phone numbers (#6489)
1 parent f318d22 commit 58a5da1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

.changeset/afraid-planets-fly.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

integration/testUtils/usersService.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,24 @@ export type UserService = {
7878
createFakeAPIKey: (userId: string) => Promise<FakeAPIKey>;
7979
};
8080

81+
/**
82+
* Temporary limited range of area codes until FAPI is updated to allow all area codes when used with a test phone number.
83+
*/
84+
function random9xxAreaCode() {
85+
const codes = [
86+
901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 912, 913, 914, 915, 916, 917, 918, 919, 920, 925, 927, 928, 929,
87+
930, 931, 934, 935, 936, 937, 938, 939, 940, 941, 945, 947, 948, 949, 951, 952, 954, 956, 959, 970, 971, 972, 973,
88+
978, 979, 980, 984, 985, 986, 989,
89+
];
90+
return codes[Math.floor(Math.random() * codes.length)];
91+
}
92+
8193
/**
8294
* This generates a random fictional number that can be verified using the 424242 code.
83-
* Allowing 10^5 combinations should be enough entropy for e2e purposes.
8495
* @see https://clerk.com/docs/testing/e2e-testing#phone-numbers
8596
*/
8697
export function fakerPhoneNumber() {
87-
return `+1###55501##`.replace(/#+/g, m => faker.string.numeric(m.length));
98+
return `+1${random9xxAreaCode()}55501${faker.string.numeric(2)}`;
8899
}
89100

90101
export const createUserService = (clerkClient: ClerkClient) => {

0 commit comments

Comments
 (0)