From b2052382a871a0f6a814b1c96aa102cd4a0e2df7 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Thu, 1 Oct 2020 16:51:16 -0400 Subject: [PATCH] fix: mock IDs should be deterministic --- ui/core/mirage/factories/scope.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/core/mirage/factories/scope.js b/ui/core/mirage/factories/scope.js index e008c8249..1b3b868b1 100644 --- a/ui/core/mirage/factories/scope.js +++ b/ui/core/mirage/factories/scope.js @@ -6,9 +6,14 @@ export default factory.extend({ type: 'global', - id() { - const id = new Array(10).fill(0).map(() => random.alphaNumeric()).join(''); - return `s_${id}`; + /** + * Generates realistic-ish IDs while still being deterministic. + */ + id(i) { + let id = 'tv6fv3yz8p'; + if (i % 3) id = 'xk1i4dk50v'; + if (i % 2) id = 's9n819zgko'; + return `s_${id}${i}`; }, withChildren: trait({