Skip to content

Commit

Permalink
Fix after debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
mrruby committed Jul 18, 2024
1 parent 74ed337 commit bfa9ad6
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 81 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/extension-PR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ jobs:
working-directory: holo-key-manager-extension

- name: Build extension
if: steps.cache-build.outputs.cache-hit != 'true'
run: pnpm build
working-directory: holo-key-manager-extension

- name: Build client
if: steps.cache-build.outputs.cache-hit != 'true'
run: pnpm build
working-directory: holo-key-manager-js-client

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
run: pnpm build
working-directory: holo-key-manager-extension

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

- name: Run e2e tests
Expand Down
2 changes: 0 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"prepare": "husky install",
"test": "concurrently \"pnpm e2e-tests\" \"cd holo-key-manager-extension && pnpm test\" \"cd holo-key-manager-js-client && pnpm test\"",
"e2e-tests": "vitest run"

},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
Expand All @@ -35,7 +34,7 @@
"eslint-plugin-svelte": "^2.42.0",
"express": "^4.19.2",
"globals": "^15.8.0",
"husky": "^9.1.0",
"husky": "^9.1.1",
"jszip": "^3.10.1",
"lint-staged": "^15.2.5",
"prettier": "^3.3.3",
Expand Down
42 changes: 21 additions & 21 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 3 additions & 8 deletions tests/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { vi } from 'vitest';

export const launchBrowserWithExtension = async (extensionPath: string): Promise<Browser> => {
return launch({
dumpio: true,
headless: true,
args: [`--disable-extensions-except=${extensionPath}`, `--load-extension=${extensionPath}`]
});
Expand Down Expand Up @@ -63,13 +62,9 @@ export const findButtonExtensionByText = (context: Page) =>
export const findTextBySelector = (context: Page) => findElementByText(context, '');

export const startServer = (port: number = 3007): Server => {
try {
const app = express();
app.use(express.static(resolve('./holo-key-manager-js-client')));
return app.listen(port);
} catch (error) {
throw new Error(`Failed to start server: ${error}`);
}
const app = express();
app.use(express.static(resolve('./holo-key-manager-js-client')));
return app.listen(port);
};

export const waitForNewPage = (browser: Browser): Promise<Page> =>
Expand Down
2 changes: 1 addition & 1 deletion tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import setupFlowTest from './setupFlow';

dotenv.config();

const EXTENSION_ID = process.env.CHROME_ID || 'eggfhkdnfdhdpmkfpihjjbnncgmhihce';
const EXTENSION_ID = process.env.CHROME_ID;

const downloadPath = resolve('./downloads');

Expand Down
33 changes: 0 additions & 33 deletions tests/needsSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,6 @@ export default async function needsSetupTest(browser: Browser) {
const page = await browser.newPage();
await page.goto('http://localhost:3007/tests/test.html');

// Find the service worker target
const swTarget = await browser.waitForTarget((target) => target.type() === 'service_worker');

// Create a new page for the service worker
const swPage = await swTarget.createCDPSession();

// Enable console logging for the service worker
await swPage.send('Runtime.enable');

// Listen for console messages from the service worker
swPage.on('Runtime.consoleAPICalled', (event) => {
const { type, args } = event;
const formattedArgs = args.map((arg) => arg.value || arg.description).join(', ');
console.log(`Service Worker Console [${type}]: ${formattedArgs}`);
});

await page.evaluate(() => {
window.addEventListener('message', (event) => {
console.log(event.data);
});
});

page.on('console', async (message) => {
const type = message.type();
const text = await message.text();
const args = await Promise.all(message.args().map((arg) => arg.jsonValue()));

const formattedArgs = args.map((arg) => JSON.stringify(arg)).join(', ');
console.log(
`Console message [${type}]: ${text}${formattedArgs ? ` | Args: ${formattedArgs}` : ''}`
);
});

const findTextOnPage = findTextBySelector(page);

const signUpButton = await findTextOnPage('Sign Up');
Expand Down
10 changes: 0 additions & 10 deletions tests/setupFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ export default async function setupFlowTest(browser: Browser, EXTENSION_ID: stri

const page = await openExtensionPage(browser, EXTENSION_ID);

const targets = browser.targets();
console.log(targets);
const serviceWorkerTarget = targets.find((target) => target.type() === 'service_worker');

if (serviceWorkerTarget) {
console.log('Service worker from this extension is working');
} else {
console.log('Service worker from this extension is not detected');
}

const setupButton = await findButtonExtensionByText(page)('Setup');

const setupPageContent = await findTextBySelector(page)('Setup Required');
Expand Down

0 comments on commit bfa9ad6

Please sign in to comment.