Skip to content

Commit

Permalink
FI-943 fix: mapping of headers with array values in CDP mode
Browse files Browse the repository at this point in the history
feat: add `pathToTsConfigOfProjectFromRoot` option to pack config
  • Loading branch information
uid11 committed Jan 22, 2024
1 parent 9558d27 commit e679992
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions autotests/packs/allTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const pack: Pack = {
pageRequestTimeout: 30_000,
pageStabilizationInterval: 500,
pathToScreenshotsDirectoryForReport: './screenshots',
pathToTsConfigOfProjectFromRoot: './tsconfig.json',
port1: 1337,
port2: 1338,
reportFileName: 'report.html',
Expand Down
7 changes: 7 additions & 0 deletions src/types/config/ownE2edConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ export type OwnE2edConfig<
*/
pathToScreenshotsDirectoryForReport: string | null;

/**
* Path to TypeScript config file of the project from the root directory of the project.
* The project should have one common TypeScript config for both
* the application code and the autotest code.
*/
pathToTsConfigOfProjectFromRoot: string;

/**
* The name of the file under which, after running the tests,
* the HTML report will be saved in the `autotests/reports` directory, for example, `report.html`.
Expand Down
11 changes: 11 additions & 0 deletions src/utils/pack/compilePack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
flattenDiagnosticMessageText,
getLineAndCharacterOfPosition,
getPreEmitDiagnostics,
JsxEmit,
ModuleKind,
ScriptTarget,
} from 'typescript';
Expand All @@ -16,10 +17,13 @@ import {
import {getPathToPack} from '../environment';
import {generalLog} from '../generalLog';

// jsx, lib, paths, target, types

const compilerOptions: CompilerOptions = {
allowSyntheticDefaultImports: true,
declaration: false,
esModuleInterop: true,
jsx: JsxEmit.React,
module: ModuleKind.CommonJS,
outDir: COMPILED_USERLAND_CONFIG_DIRECTORY,
paths: {
Expand All @@ -33,6 +37,8 @@ const compilerOptions: CompilerOptions = {
types: ['node'],
};

const unusedTsExceptErrorMessage = "Unused '@ts-expect-error' directive.";

/**
* Compiles pack file before running tests (or tasks).
* @internal
Expand All @@ -47,6 +53,11 @@ export const compilePack = (): void => {

allDiagnostics.forEach((diagnostic) => {
const message = flattenDiagnosticMessageText(diagnostic.messageText, '\n');

if (message === unusedTsExceptErrorMessage) {
return;
}

const logData: {file?: string; message: string} = {message};

if (diagnostic.file) {
Expand Down
10 changes: 8 additions & 2 deletions src/utils/requestHooks/applyHeadersMapperByModifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ export const applyHeadersMapperByModifiers = (
const newHeaders = mapper(copyOfHeaders);

for (const [name, value] of Object.entries(newHeaders)) {
const lowerCaseName = name.toLowerCase();

if (value === undefined) {
removeHeader(name.toLowerCase());
removeHeader(lowerCaseName);
} else {
setHeader(name.toLowerCase(), String(value));
const values = Array.isArray(value) ? value : [value];

for (const singleValue of values) {
setHeader(lowerCaseName, singleValue);
}
}
}
};

0 comments on commit e679992

Please sign in to comment.