Skip to content

Commit

Permalink
chore: fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanrajpac committed Aug 16, 2024
1 parent a688a2c commit 85dc919
Show file tree
Hide file tree
Showing 10 changed files with 408 additions and 242 deletions.
71 changes: 41 additions & 30 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
{
"extends": [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:cypress/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"rules": {
"prettier/prettier": "warn",
"import/no-unresolved": 0,
"@typescript-eslint/ban-ts-comment": "off",
"camelcase": "off"
},
"overrides": [
{
"files": ["*.jsx", "*.js"],
"env": {
"jest": true
},
"rules": {
"@typescript-eslint/explicit-module-boundary-types": ["off"]
}
}
],
"settings": {
"import/resolver": {
"alias": {
"map": [["src", "./src"]]
}
}
"extends": [
"plugin:@wordpress/eslint-plugin/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"rules": {
"prettier/prettier": "warn",
"import/no-unresolved": 0,
"@typescript-eslint/ban-ts-comment": "off",
"camelcase": "off"
},
"overrides": [
{
"files": [
"*.jsx",
"*.js"
],
"env": {
"jest": true
},
"rules": {
"@typescript-eslint/explicit-module-boundary-types": [
"off"
]
}
}
],
"settings": {
"import/resolver": {
"alias": {
"map": [
[
"src",
"./src"
]
]
}
}
}
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
"php:multisite": "wp-env run tests-wordpress --env-cwd=wp-content/plugins/feature-flags composer test:multisite"
},
"dependencies": {
"@testing-library/dom": "^10.4.0",
"@testing-library/user-event": "^14.5.2",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@typescript-eslint/parser": "^8.1.0",
"@wordpress/api-fetch": "^7.5.0",
"@wordpress/components": "^28.5.0",
"@wordpress/data": "^10.5.0",
Expand All @@ -55,10 +58,9 @@
"@wordpress/e2e-test-utils-playwright": "^1.5.0",
"@wordpress/env": "^10.5.0",
"@wordpress/eslint-plugin": "^20.2.0",
"@wordpress/scripts": "^28.5.0",
"eslint": "^9.9.0",
"@wordpress/scripts": "27.0.0",
"eslint": "8.56.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-import": "^2.29.1",
"husky": "^9.1.4",
"jest-environment-jsdom": "^29.7.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports*/
const fs = require('fs');
const path = require('path');
const package = require('../package.json');
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import Header from '../Header';

jest.mock('@wordpress/components', () => ({
...jest.requireActual('@wordpress/components'),
// ...jest.requireActual('@wordpress/components'),
Flex: jest.fn().mockImplementation(({ children }) => <div>{children}</div>),
FlexItem: jest
.fn()
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/__tests__/DeleteModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import DeleteModal from '../DeleteModal';

jest.mock('@wordpress/components', () => ({
...jest.requireActual('@wordpress/components'),
// ...jest.requireActual('@wordpress/components'),
Modal: jest
.fn()
.mockImplementation(({ children }) => <div>{children}</div>),
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ codebFeatureFlags.isEnabled = (flag: string) => {
}
);

if (isFlagExist) return true;
if (isFlagExist) {
return true;
}

return false;
};
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export async function deleteAllFlags(page: Page) {
.count();

if (count > 0) {
for (let i = 0; i < count; ++i) await deleteLastFlag(page);
for (let i = 0; i < count; ++i) {
await deleteLastFlag(page);
}
}
},
{ box: true }
Expand Down
10 changes: 7 additions & 3 deletions tests/performance/cli/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* External dependencies
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
/* eslint-disable @typescript-eslint/no-require-imports*/
const { existsSync, readFileSync, writeFileSync } = require('node:fs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { join, resolve } = require('node:path');
Expand Down Expand Up @@ -31,8 +31,12 @@ if (beforeFile && !existsSync(beforeFile)) {
* @return {string} Formatted value.
*/
function formatTableValue(v) {
if (v === true || v === 'true') return '✅';
if (!v || v === 'false') return '';
if (v === true || v === 'true') {
return '✅';
}
if (!v || v === 'false') {
return '';
}
return v?.toString() || String(v);
}

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable @typescript-eslint/no-require-imports*/
const path = require('path');
const defaultConfig = require('@wordpress/scripts/config/webpack.config');

Expand Down
Loading

0 comments on commit 85dc919

Please sign in to comment.