Skip to content

Commit

Permalink
Add e2e tests and bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrruby committed Jul 17, 2024
1 parent dcdd72b commit 157dc97
Show file tree
Hide file tree
Showing 16 changed files with 1,709 additions and 842 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/extension-PR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
run: pnpm build
working-directory: holo-key-manager-extension

- name: Build and pack client
run: pnpm buildPack
working-directory: holo-key-manager-js-client

- name: Run e2e tests
run: pnpm e2e-tests
env:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ jobs:
run: pnpm build
working-directory: holo-key-manager-extension

- name: Build and pack client
run: pnpm buildPack
working-directory: holo-key-manager-js-client

- name: Run e2e tests
run: pnpm e2e-tests
env:
Expand Down
2 changes: 1 addition & 1 deletion holo-key-manager-extension/static/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Holo key manager",
"description": "A browser extension to manage holo keys",
"version": "0.0.74",
"version": "0.0.75",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiAtKvbHNTN3O2BLRZH7RkLczaMLenSeZu+YP+KomPQPZ18nt4DY9boIN/+GWts7gCzEeQq59l8edGdF2P7xAbsRxYR88+zFEbxMtIyfyqJZIlzXwnvPJkwGu/S6arNtX48K7q1+xnJEE7VyeYSj6/i2LR+LmPigCzY9JCP7+SmWVeYbdm3kZmReK0ecfh15RXSNjZpXJUgrbea/RVxweggYKnmhhOUBmuJSCLoWTXIuJPBMwGQK1O2GKBqHOq94bPVSF7j+4WzSpPan70ZZJX/reFsOFE/idfFN6wbizjR1Ne50Po03kudEmfQgoqUhVpd0wP8A3YbqE7ODdZcCPPwIDAQAB",
"manifest_version": 3,
"action": {
Expand Down
2 changes: 1 addition & 1 deletion holo-key-manager-js-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@holo-host/holo-key-manager-js-client",
"version": "0.0.6",
"version": "0.0.7",
"description": "A JavaScript client API for managing Holo keys",
"main": "lib/index.js",
"types": "lib/holo-key-manager-js-client/src/index.d.ts",
Expand Down
8 changes: 4 additions & 4 deletions holo-key-manager-js-client/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ vi.mock('../src/helpers', async (importOriginal) => {
const actual = await importOriginal();
return {
...(typeof actual === 'object' && actual !== null ? actual : {}),
sendMessage: vi.fn(),
parseMessagePayload: vi.fn(),
sendMessage: vi.fn<typeof sendMessage>(),
parseMessagePayload: vi.fn<typeof parseMessagePayload>(),
checkContentScriptAndBrowser: vi.fn()
};
});

describe('createHoloKeyManager', () => {
let holoKeyManager: ReturnType<typeof createHoloKeyManager>;
let sendMessageMock: Mock;
let parseMessagePayloadMock: Mock;
let sendMessageMock: Mock<typeof sendMessage>;
let parseMessagePayloadMock: Mock<typeof parseMessagePayload>;

beforeEach(() => {
holoKeyManager = createHoloKeyManager(config);
Expand Down
68 changes: 68 additions & 0 deletions holo-key-manager-js-client/tests/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Library Test</title>
<script type="module">
import createHoloKeyManager from '../lib/index.js';

const holoKeyManagerConfig = {
happId: 'your-happId',
happName: 'your-happName',
happLogo: 'https://example.com/happLogo.png',
happUiUrl: 'https://example.com/ui',
requireRegistrationCode: false,
requireEmail: true
};

const holoKeyManager = createHoloKeyManager(holoKeyManagerConfig);

const handleButtonClick = (buttonId, action) => {
document.getElementById(buttonId).addEventListener('click', async () => {
const resultElement = document.getElementById(`${buttonId}Result`);
try {
const result = await action();
resultElement.textContent = `${buttonId} successful: ${JSON.stringify(result)}`;
} catch (error) {
resultElement.textContent = `Error: ${error.message}`;
}
});
};

handleButtonClick('signUpBtn', async () => {
const { email, registrationCode, pubKey } = await holoKeyManager.signUp();
return { email, registrationCode, pubKey };
});

handleButtonClick('signInBtn', async () => {
const { pubKey } = await holoKeyManager.signIn();
return { pubKey };
});

handleButtonClick('signMessageBtn', async () => {
const messageInput = document.getElementById('messageInput').value;
const message = new Uint8Array(JSON.parse(messageInput));
const signedMessage = await holoKeyManager.signMessage(message);
return { signedMessage };
});

handleButtonClick('signOutBtn', async () => {
await holoKeyManager.signOut();
return {};
});
</script>
</head>
<body>
<div id="app">
<button id="signUpBtn">Sign Up</button>
<p id="signUpBtnResult"></p>
<button id="signInBtn">Sign In</button>
<p id="signInBtnResult"></p>
<input id="messageInput" type="text" placeholder="Enter message as [1,2,3]" />
<button id="signMessageBtn">Sign Message</button>
<p id="signMessageBtnResult"></p>
<button id="signOutBtn">Sign Out</button>
<p id="signOutBtnResult"></p>
</div>
</body>
</html>
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,29 @@
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chrome": "^0.0.268",
"@typescript-eslint/parser": "^7.13.0",
"@types/express": "^4.17.21",
"@typescript-eslint/parser": "^7.16.1",
"concurrently": "^8.2.2",
"dotenv": "^16.4.5",
"eslint": "^9.4.0",
"eslint": "^9.7.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-svelte": "^2.39.3",
"globals": "^15.4.0",
"husky": "^9.0.11",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-svelte": "^2.42.0",
"express": "^4.19.2",
"globals": "^15.8.0",
"husky": "^9.1.0",
"jszip": "^3.10.1",
"lint-staged": "^15.2.5",
"prettier": "^3.3.2",
"puppeteer": "^22.12.0",
"rollup": "^4.18.0",
"prettier": "^3.3.3",
"puppeteer": "^22.13.1",
"rollup": "^4.18.1",
"rollup-plugin-tsc-alias": "^1.1.2",
"rollup-plugin-typescript2": "^0.36.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.13.0",
"vitest": "^1.6.0"
"tweetnacl": "^1.0.3",
"typescript": "^5.5.3",
"typescript-eslint": "^7.16.1",
"vitest": "^2.0.3"
},
"dependencies": {
"zod": "^3.23.8"
Expand Down
Loading

0 comments on commit 157dc97

Please sign in to comment.