Skip to content

Commit

Permalink
Merge pull request #5956 from pavinduLakshan/enable_unit_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pavinduLakshan authored May 9, 2024
2 parents 054886b + 26cfb82 commit 587eedb
Show file tree
Hide file tree
Showing 64 changed files with 519 additions and 564 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ module.exports = {
// [1] https://eslint.org/docs/latest/rules/no-restricted-imports#group
// [2] https://stackoverflow.com/q/68126222/8810941
"apps/**/*",
"modules/**/*"
"modules/**/*",
"features/**/*"
]
}
],
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/pr-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ jobs:

test:
name: 👾 Unit Test (TESTING)
if: false
needs: [ lint, typecheck ]
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -192,9 +191,13 @@ jobs:

- name: 🃏 Run Jest & Collect Coverage
id: run-jest-test-and-coverage
run: pnpm test:unit:coverage
# TODO: Update the command to "test:unit:coverage" once the coverage command related issues
# are sorted out
run: pnpm test:unit

- name: 🤖 Aggregate Test Coverage
# TODO: Enable this step once the coverage command related issues are fixed
if: false
id: aggregate-coverage-reports
run: |
pnpm test:unit:coverage:aggregate
Expand All @@ -203,7 +206,7 @@ jobs:
build:
name: 🚧 Build
needs: [ typecheck ]
needs: [ test, typecheck ]
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ identity-apps-core/apps/*/src/main/webapp/libs/themes
identity-apps-core/apps/*/src/main/webapp/extensions/layouts
identity-apps-core/apps/*/src/main/webapp/includes/layouts

# Integration test module.
tests/output/
tests/dist/

.classpath
.settings
.factorypath
Expand Down
16 changes: 8 additions & 8 deletions apps/console/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"targets": {
"build-prepare": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down Expand Up @@ -105,7 +105,7 @@
}
},
"build-windup": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand All @@ -118,7 +118,7 @@
}
},
"build": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm nx run console:build-prepare",
Expand All @@ -130,7 +130,7 @@
}
},
"clean": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand All @@ -143,7 +143,7 @@
}
},
"serve-prepare": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down Expand Up @@ -177,7 +177,7 @@
}
},
"serve": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm nx run console:serve-prepare",
Expand All @@ -188,15 +188,15 @@
}
},
"lint": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"command": "pnpm lint",
"cwd": "apps/console",
"parallel": false
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"command": "pnpm test",
"cwd": "apps/console",
Expand Down
1 change: 0 additions & 1 deletion apps/console/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"scripts",
"**/test-configs/*",
"jest.config.ts",
"**/tests/*",
"**/__tests__/*",
"**/__mocks__/*",
"**/*.test.js",
Expand Down
14 changes: 7 additions & 7 deletions apps/myaccount/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"targets": {
"build-prepare": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down Expand Up @@ -100,7 +100,7 @@
}
},
"build": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm nx run myaccount:build-prepare",
Expand All @@ -112,7 +112,7 @@
},

"clean": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand All @@ -125,7 +125,7 @@
}
},
"serve-prepare": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
{
Expand Down Expand Up @@ -159,7 +159,7 @@
}
},
"serve": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"commands": [
"pnpm nx run myaccount:serve-prepare",
Expand All @@ -170,15 +170,15 @@
}
},
"lint": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"command": "pnpm lint",
"cwd": "apps/myaccount",
"parallel": false
}
},
"test": {
"executor": "@nrwl/workspace:run-commands",
"executor": "nx:run-commands",
"options": {
"command": "pnpm test",
"cwd": "apps/myaccount",
Expand Down
25 changes: 0 additions & 25 deletions docs/testing/INTEGRATION_TESTING.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ Follow through [this guide](./STATIC_CODE_ANALYSIS.md) to set-up and understand
## Unit Tests

Read the unit testing guide [here](UNIT_TESTING.md)

## Integration Tests

Read the integration testing guide [here](INTEGRATION_TESTING.md)
7 changes: 0 additions & 7 deletions docs/testing/STATIC_CODE_ANALYSIS.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ cd apps/console
pnpm lint:targeted -- src/features/applications
```

##### Example: To run linter on `basic-application.spec.ts` test file inside the integration test suite.

```bash
cd tests
pnpm lint:targeted -- integration/applications/basic-application.spec.ts
```

### Auto-fixing Issues

ESLint has the ability to [auto-fix](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) certain warnings and errors.
Expand Down
2 changes: 1 addition & 1 deletion features/admin.ai.v1/models/branding-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { BrandingPreferenceInterface } from "features/admin.branding.v1/models/branding-preferences";
import { BrandingPreferenceInterface } from "../../admin.branding.v1/models/branding-preferences";

export interface GenerateBrandingAPIInterface {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import { AlertInterface, AlertLevels } from "@wso2is/core/models";
import { addAlert } from "@wso2is/core/store";
import useBrandingPreference from "features/admin.branding.v1/hooks/use-branding-preference";
import { BrandingPreferenceInterface } from "features/admin.branding.v1/models";
import cloneDeep from "lodash-es/cloneDeep";
import isEmpty from "lodash-es/isEmpty";
import isObject from "lodash-es/isObject";
Expand All @@ -35,6 +33,8 @@ import React, {
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
import { Dispatch } from "redux";
import useBrandingPreference from "../../admin.branding.v1/hooks/use-branding-preference";
import { BrandingPreferenceInterface } from "../../admin.branding.v1/models";
import { BrandingPreferenceUtils } from "../../admin.branding.v1/utils";
import useGetAIBrandingGenerationResult from "../api/use-get-ai-branding-generation-result";
import AIFeatureContext from "../context/ai-branding-feature-context";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
*/

import { IdentifiableComponentInterface, SBACInterface } from "@wso2is/core/models";
import { LOGIN_FLOW_AI_FEATURE_TAG } from "features/admin.login-flow.ai.v1/constants/login-flow-ai-constants";
import React, { FunctionComponent, ReactElement } from "react";
import { useSelector } from "react-redux";
import { SignOnMethodsCore } from "./sign-on-methods-core";
import { AppState, FeatureConfigInterface } from "../../../../../admin.core.v1";
import { LOGIN_FLOW_AI_FEATURE_TAG } from "../../../../../admin.login-flow.ai.v1/constants/login-flow-ai-constants";
import useAILoginFlow from "../../../../../admin.login-flow.ai.v1/hooks/use-ai-login-flow";
import { useGetCurrentOrganizationType } from "../../../../../admin.organizations.v1/hooks/use-get-organization-type";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,39 @@
import React from "react";
import "@testing-library/jest-dom";
import { fullPermissions } from "./__mocks__/permissions";
import ResourceEndpointsProvider from "../../../admin.core.v1/providers/resource-enpoints-provider";
import UserPreferenceProvider from "../../../admin.core.v1/providers/user-preferences-provider";
import { render, screen } from "../../../test-configs/utils";
import AuthenticationFlowProvider from "../../providers/authentication-flow-provider";
import AuthenticationFlowBuilder, { AuthenticationFlowBuilderPropsInterface } from "../authentication-flow-builder";

describe("AuthenticationFlowBuilder", () => {
describe.skip("AuthenticationFlowBuilder", () => {
const defaultProps: AuthenticationFlowBuilderPropsInterface = {
legacyBuilder: <div>Legacy Builder</div>,
onIDPCreateWizardTrigger: jest.fn()
};

it("renders the AuthenticationFlowBuilder component", () => {
render(<AuthenticationFlowBuilder { ...defaultProps } />, { allowedScopes: fullPermissions });
render(
<ResourceEndpointsProvider>
<UserPreferenceProvider>
<AuthenticationFlowProvider
application={ {
name: "Sample App"
} }
isSystemApplication={ false }
authenticators={ [] }
hiddenAuthenticators={ [] }
onAuthenticatorsRefetch={ jest.fn() }
onUpdate={ jest.fn() }
isLoading={ false }
readOnly={ false }
>
<AuthenticationFlowBuilder { ...defaultProps } />
</AuthenticationFlowProvider>
</UserPreferenceProvider>
</ResourceEndpointsProvider>
, { allowedScopes: fullPermissions });

const authenticationFlowBuilder: Element = screen.getByTestId("authentication-flow-builder");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ import AuthenticationFlowModeSwitchDisclaimerModal, {
AuthenticationFlowModeSwitchDisclaimerModalPropsInterface
} from "../authentication-flow-mode-switch-disclaimer-modal";

describe("AuthenticationFlowModeSwitchDisclaimerModal", () => {
describe.skip("AuthenticationFlowModeSwitchDisclaimerModal", () => {
const defaultProps: AuthenticationFlowModeSwitchDisclaimerModalPropsInterface = {
mode: {
id: 0,
label: "Visual Editor"
}
// `open` prop needs to be passed here to make this test work, but for some reason
// TypeScript doesn't allow it here.
// There are other places where `open` prop has successfully been used though.
// Eg: features/admin.authentication-flow-builder.v1/components/authentication-flow-builder.tsx
// open: true
};

it("renders the AuthenticationFlowModeSwitchDisclaimerModal component", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import React from "react";
import "@testing-library/jest-dom";
import { fullPermissions } from "./__mocks__/permissions";
import UserPreferenceProvider from "../../../admin.core.v1/providers/user-preferences-provider";
import { render, screen } from "../../../test-configs/utils";
import AuthenticationFlowOptionAddModal, {
AuthenticationFlowOptionAddModalPropsInterface
Expand All @@ -27,8 +28,12 @@ import AuthenticationFlowOptionAddModal, {
describe("AuthenticationFlowOptionAddModal", () => {
const defaultProps: AuthenticationFlowOptionAddModalPropsInterface = {};

it("renders the AuthenticationFlowOptionAddModal component", () => {
render(<AuthenticationFlowOptionAddModal { ...defaultProps } />, { allowedScopes: fullPermissions });
it.skip("renders the AuthenticationFlowOptionAddModal component", () => {
render(
<UserPreferenceProvider>
<AuthenticationFlowOptionAddModal { ...defaultProps } />
</UserPreferenceProvider>
, { allowedScopes: fullPermissions });

const authenticationFlowOptionAddModal: Element = screen.getByTestId("authentication-flow-option-add-modal");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import React from "react";
import "@testing-library/jest-dom";
import { fullPermissions } from "./__mocks__/permissions";
import UserPreferenceProvider from "../../../admin.core.v1/providers/user-preferences-provider";
import { render, screen } from "../../../test-configs/utils";
import AuthenticationFlowVisualEditor, {
AuthenticationFlowVisualEditorPropsInterface
Expand All @@ -31,7 +32,11 @@ describe("AuthenticationFlowVisualEditor", () => {
};

it("renders the AuthenticationFlowVisualEditor component", () => {
render(<AuthenticationFlowVisualEditor { ...defaultProps } />, { allowedScopes: fullPermissions });
render(
<UserPreferenceProvider>
<AuthenticationFlowVisualEditor { ...defaultProps } />
</UserPreferenceProvider>
, { allowedScopes: fullPermissions });

const authenticationFlowVisualEditor: Element = screen.getByTestId("authentication-flow-visual-editor");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe("SidePanelDrawer", () => {
panelControlsLabel: "Panel Controls"
};

it("renders the SidePanelDrawer component", async () => {
await render(<SidePanelDrawer { ...defaultProps } />, { allowedScopes: fullPermissions });
it.skip("renders the SidePanelDrawer component", async () => {
render(<SidePanelDrawer { ...defaultProps } />, { allowedScopes: fullPermissions });

const sidePanelDrawer: Element = screen.getByTestId("side-panel-drawer");

Expand Down
Loading

0 comments on commit 587eedb

Please sign in to comment.