Skip to content

Commit

Permalink
Check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrruby committed Jul 18, 2024
1 parent 23a81d4 commit db39460
Showing 1 changed file with 23 additions and 38 deletions.
61 changes: 23 additions & 38 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { rm } from 'fs/promises';
import { Server } from 'http';
import { resolve } from 'path';
import type { Browser } from 'puppeteer';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { afterAll, beforeAll, describe, it } from 'vitest';

// import clientInteractionTest from './clientInteraction';
import { findTextBySelector, launchBrowserWithExtension, startServer } from './helpers';
// import needsSetupTest from './needsSetup';
// import preventSignatureFromOtherOrigin from './preventSignatureFromOtherOrigin';
// import setupFlowTest from './setupFlow';
import clientInteractionTest from './clientInteraction';
import { launchBrowserWithExtension, startServer } from './helpers';
import needsSetupTest from './needsSetup';
import preventSignatureFromOtherOrigin from './preventSignatureFromOtherOrigin';
import setupFlowTest from './setupFlow';

dotenv.config();

Expand Down Expand Up @@ -37,36 +37,21 @@ afterAll(async () => {

describe('End-to-End Tests for Extension and Client', () => {
it('should not allow the client to interact with the extension before setup', async () => {
const page = await browser.newPage();
await page.goto('http://localhost:3007/tests/test.html');

const findTextOnPage = findTextBySelector(page);

const signUpButton = await findTextOnPage('Sign Up');
expect(signUpButton).toBeTruthy();

await signUpButton.click();

const needsSetupText = await findTextOnPage('NeedsSetup');
expect(needsSetupText).toBeTruthy();
}, 10000);

// it('should not allow the client to interact with the extension before setup', async () => {
// await needsSetupTest(browser);
// }, 10000);

// it('verify setup flow works as expected', async () => {
// if (!EXTENSION_ID) {
// throw new Error('EXTENSION_ID is not set');
// }
// await setupFlowTest(browser, EXTENSION_ID);
// }, 20000);

// it('should allow the client to interact with the extension after setup', async () => {
// await clientInteractionTest(browser);
// }, 20000);

// it('should prevent the malicious page from signing messages', async () => {
// await preventSignatureFromOtherOrigin(browser);
// }, 20000);
await needsSetupTest(browser);
});

it('verify setup flow works as expected', async () => {
if (!EXTENSION_ID) {
throw new Error('EXTENSION_ID is not set');
}
await setupFlowTest(browser, EXTENSION_ID);
});

it('should allow the client to interact with the extension after setup', async () => {
await clientInteractionTest(browser);
});

it('should prevent the malicious page from signing messages', async () => {
await preventSignatureFromOtherOrigin(browser);
});
});

0 comments on commit db39460

Please sign in to comment.