Skip to content

Commit

Permalink
fix: ppr reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanmo226 committed Jan 3, 2025
1 parent 9fc50ad commit b8e66df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 2 additions & 0 deletions scripts/config-mock-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ BUILD_PATH=./build/test/mock-builds/port-$2-$(openssl rand -hex 12)
mkdir -p $BUILD_PATH
cp -r ./$1/* $BUILD_PATH
grep "\[TEST_REPLACEABLE_MOCK_PORT\]" $BUILD_PATH -lr | xargs sed -i.bak -e "s/\[TEST_REPLACEABLE_MOCK_PORT\]/$2/g"
# Replace export const MOCK_PORT line with the provided mock port
grep "export const MOCK_PORT = '\[TEST_REPLACEABLE_MOCK_PORT\]';" $BUILD_PATH -lr | xargs sed -i.bak -e "s/export const MOCK_PORT = '\[TEST_REPLACEABLE_MOCK_PORT\]';/export const MOCK_PORT = '$2';/"
echo $BUILD_PATH
9 changes: 2 additions & 7 deletions test/source/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { AvaContext, TestContext, getDebugHtmlAtts, minutes, standaloneTestTimeo
import { Util, getParsedCliParams } from './util';

import { mkdirSync, realpathSync } from 'fs';
import { readFile, writeFile } from 'fs/promises';
import { writeFile } from 'fs/promises';
import { TestUrls } from './browser/test-urls';
import { startAllApisMock } from './mock/all-apis-mock';
import { reportedErrors } from './mock/fes/shared-tenant-fes-endpoints';
import { defineComposeTests } from './tests/compose';
import { defineContentScriptTests } from './tests/content-script';
import { defineDecryptTests } from './tests/decrypt';
Expand All @@ -22,7 +23,6 @@ import { defineSettingsTests } from './tests/settings';
import { defineSetupTests } from './tests/setup';
import { defineUnitBrowserTests } from './tests/unit-browser';
import { defineUnitNodeTests } from './tests/unit-node';
import { reportedErrors } from './mock/fes/shared-tenant-fes-endpoints';

export const { testVariant, testGroup, oneIfNotPooled, buildDir, isMock } = getParsedCliParams();
export const internalTestState = { expectIntentionalErrReport: false }; // updated when a particular test that causes an error is run
Expand Down Expand Up @@ -107,11 +107,6 @@ const startMockApiAndCopyBuild = async (t: AvaContext) => {
const address = mockApi.server.address();
if (typeof address === 'object' && address) {
const result = await asyncExec(`sh ./scripts/config-mock-build.sh ${buildDir} ${address.port}`);
const filepath = `${buildDir}/js/common/core/const.js`;

const fileContent = await readFile(filepath, { encoding: 'utf-8' });
const updatedCode = fileContent.replace(/const (MOCK_PORT) = [^;]+;/g, `const $1 = '${address.port}';`);
await writeFile(filepath, updatedCode);
t.context.extensionDir = result.stdout;
t.context.urls = new TestUrls(await browserPool.getExtensionId(t), address.port);
} else {
Expand Down

0 comments on commit b8e66df

Please sign in to comment.