From ff02fee6a5558b42d363e2e27542913d0611e7fb Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Mon, 7 Apr 2025 22:23:23 +0100 Subject: [PATCH] Random case vaultId --- frontend/test-client/jest.config.js | 3 ++ frontend/test-client/package.json | 44 +++++++++---------- frontend/test-client/src/cli.ts | 5 ++- .../src/utils/random-casing.test.ts | 11 +++++ .../test-client/src/utils/random-casing.ts | 10 +++++ 5 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 frontend/test-client/jest.config.js create mode 100644 frontend/test-client/src/utils/random-casing.test.ts create mode 100644 frontend/test-client/src/utils/random-casing.ts diff --git a/frontend/test-client/jest.config.js b/frontend/test-client/jest.config.js new file mode 100644 index 00000000..8c1027ee --- /dev/null +++ b/frontend/test-client/jest.config.js @@ -0,0 +1,3 @@ +module.exports = { + preset: "ts-jest/presets/js-with-babel-esm" +}; diff --git a/frontend/test-client/package.json b/frontend/test-client/package.json index 278910a6..4d5e18c0 100644 --- a/frontend/test-client/package.json +++ b/frontend/test-client/package.json @@ -1,24 +1,24 @@ { - "name": "test-client", - "version": "0.3.8", - "private": true, - "bin": { - "test-client": "./dist/cli.js" - }, - "scripts": { - "dev": "webpack watch --mode development", - "build": "webpack --mode production", - "test": "jest --passWithNoTests" - }, - "devDependencies": { - "@types/node": "^22.14.0", - "sync-client": "file:../sync-client", - "ts-loader": "^9.5.2", - "tslib": "2.8.1", - "typescript": "5.8.2", - "uuid": "^11.1.0", - "webpack": "^5.98.0", - "webpack-cli": "^6.0.1", - "bufferutil": "^4.0.9" - } + "name": "test-client", + "version": "0.3.8", + "private": true, + "bin": { + "test-client": "./dist/cli.js" + }, + "scripts": { + "dev": "webpack watch --mode development", + "build": "webpack --mode production", + "test": "jest" + }, + "devDependencies": { + "@types/node": "^22.14.0", + "sync-client": "file:../sync-client", + "ts-loader": "^9.5.2", + "tslib": "2.8.1", + "typescript": "5.8.2", + "uuid": "^11.1.0", + "webpack": "^5.98.0", + "webpack-cli": "^6.0.1", + "bufferutil": "^4.0.9" + } } diff --git a/frontend/test-client/src/cli.ts b/frontend/test-client/src/cli.ts index 98dff41c..9093c697 100644 --- a/frontend/test-client/src/cli.ts +++ b/frontend/test-client/src/cli.ts @@ -2,6 +2,7 @@ import type { SyncSettings } from "sync-client"; import { MockAgent } from "./agent/mock-agent"; import { sleep } from "./utils/sleep"; import { v4 as uuidv4 } from "uuid"; +import { randomCasing } from "./utils/random-casing"; let slowFileEvents = false; @@ -29,8 +30,8 @@ async function runTest({ console.info(`Using vault name: ${vaultName}`); const initialSettings: Partial = { isSyncEnabled: true, - token: "test-token-change-me", // same as in backend/config-e2e.yml - vaultName, + token: " test-token-change-me ", // same as in backend/config-e2e.yml with spaces + vaultName: randomCasing(vaultName) + (Math.random() > 0.5 ? " " : ""), // extra spaces shouldn't matter syncConcurrency: concurrency, remoteUri: "http://localhost:3000" }; diff --git a/frontend/test-client/src/utils/random-casing.test.ts b/frontend/test-client/src/utils/random-casing.test.ts new file mode 100644 index 00000000..c6f1aafa --- /dev/null +++ b/frontend/test-client/src/utils/random-casing.test.ts @@ -0,0 +1,11 @@ +import { randomCasing } from "./random-casing"; + +describe("randomCasing", () => { + it("simple test", () => { + const input = + "hello, this is a really long string with a lot of characters"; + const result = randomCasing(input); + expect(result.toLowerCase()).toBe(input.toLowerCase()); + expect(result).not.toBe(input); + }); +}); diff --git a/frontend/test-client/src/utils/random-casing.ts b/frontend/test-client/src/utils/random-casing.ts new file mode 100644 index 00000000..bf9f99dc --- /dev/null +++ b/frontend/test-client/src/utils/random-casing.ts @@ -0,0 +1,10 @@ +export function randomCasing(str: string): string { + const chars = str.split(""); + const randomCasedChars = chars.map((char) => { + if (Math.random() < 0.5) { + return char.toUpperCase(); + } + return char.toLowerCase(); + }); + return randomCasedChars.join(""); +}