Chore: fix some more types (#76535)

* clean up some e2e/runtime types

* fix some stories

* some more fixes

* fix route props

* update unit tests

* update more unit tests

* don't throw here
This commit is contained in:
Ashley Harrison
2023-10-24 11:53:22 +01:00
committed by GitHub
parent 272a901e5e
commit ced065c7e9
24 changed files with 90 additions and 125 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ interface CompareScreenshotsConfig {
declare namespace Cypress {
interface Chainable {
compareScreenshots(config: CompareScreenshotsConfig | string): Chainable;
logToConsole(message: string, optional?: any): void;
logToConsole(message: string, optional?: unknown): void;
readProvisions(filePaths: string[]): Chainable;
getJSONFilesFromDir(dirPath: string): Chainable;
startBenchmarking(testName: string): void;
+1 -3
View File
@@ -2,8 +2,6 @@ import { v4 as uuidv4 } from 'uuid';
import { e2e } from '../index';
import { DeleteDataSourceConfig } from './deleteDataSource';
export interface AddDataSourceConfig {
basicAuth: boolean;
basicAuthPassword: string;
@@ -96,7 +94,7 @@ export const addDataSource = (config?: Partial<AddDataSourceConfig>) => {
return cy.url().then(() => {
e2e.getScenarioContext().then(({ addedDataSources }) => {
e2e.setScenarioContext({
addedDataSources: [...addedDataSources, { name } as DeleteDataSourceConfig],
addedDataSources: [...addedDataSources, { name, id: '' }],
});
});
+1 -4
View File
@@ -9,7 +9,6 @@ export interface ScenarioContext {
lastAddedDataSource: string; // @todo rename to `lastAddedDataSourceName`
lastAddedDataSourceId: string;
hasChangedUserPreferences: boolean;
[key: string]: any;
}
const scenarioContext: ScenarioContext = {
@@ -50,9 +49,7 @@ export const setScenarioContext = (newContext: Partial<ScenarioContext>): Cypres
.wrap(
{
setScenarioContext: () => {
Object.entries(newContext).forEach(([key, value]) => {
scenarioContext[key] = value;
});
Object.assign(scenarioContext, newContext);
},
},
{ log: false }
+4 -4
View File
@@ -17,7 +17,7 @@ export type TypeSelectors<S> = S extends StringSelector
? E2EFunction
: S extends UrlSelector
? E2EVisit & Omit<E2EFunctions<S>, 'url'>
: S extends Record<any, any>
: S extends Record<string, string | FunctionSelector | CssSelector | UrlSelector | Selectors>
? E2EFunctions<S>
: S;
@@ -32,7 +32,7 @@ export type E2EFactoryArgs<S extends Selectors> = { selectors: S };
export type CypressOptions = Partial<Cypress.Loggable & Cypress.Timeoutable & Cypress.Withinable & Cypress.Shadow>;
const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, selectors: S): E2EFunctions<S> => {
const logOutput = (data: any) => cy.logToConsole('Retrieving Selector:', data);
const logOutput = (data: unknown) => cy.logToConsole('Retrieving Selector:', data);
const keys = Object.keys(selectors);
for (let index = 0; index < keys.length; index++) {
const key = keys[index];
@@ -80,7 +80,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
e2eObjects[key] = function (textOrOptions?: string | CypressOptions, options?: CypressOptions) {
// the input can only be ()
if (arguments.length === 0) {
const selector = value(undefined as unknown as string);
const selector = value('');
logOutput(selector);
return cy.get(selector);
@@ -97,7 +97,7 @@ const processSelectors = <S extends Selectors>(e2eObjects: E2EFunctions<S>, sele
logOutput(selector);
return cy.get(selector);
}
const selector = value(undefined as unknown as string);
const selector = value('');
logOutput(selector);
return cy.get(selector, textOrOptions);