-
Notifications
You must be signed in to change notification settings - Fork 134
Add Shesha.Testing NuGet package for reusable integration test infrastructure #4520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ihouvet
wants to merge
6
commits into
main
Choose a base branch
from
add-shesha-testing-package
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d5c1fac
Added Claude.md file For more effective use of Claude code.
ihouvet 16bb835
Merge branch 'main' of https://github.com/shesha-io/shesha-framework
ihouvet c81b1d5
Add Shesha.Testing NuGet package and fix interceptor bugs
ihouvet 1b2e50a
Update shesha-core/src/Shesha.Testing/Shesha.Testing.csproj
ihouvet 0ef58f0
Update shesha-core/src/Shesha.Testing/UnitTestHelper.cs
ihouvet 6b7c62e
Update shesha-core/src/Shesha.Testing/Shesha.Testing.csproj
ihouvet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| Shesha is an open-source Low-Code development framework for .NET developers. It combines ASP.NET Core, ABP.io, React, and Next.js with drag-and-drop form building capabilities to reduce code requirements by 80%+ for typical business applications. | ||
|
|
||
| ## Repository Structure | ||
|
|
||
| ``` | ||
| shesha-framework/ | ||
| ├── shesha-core/ # .NET backend framework (main solution) | ||
| ├── shesha-reactjs/ # React/TypeScript component library (@shesha-io/reactjs) | ||
| ├── shesha-starter/ # Starter template for new projects | ||
| ├── shesha-functional-tests/ # Functional test suite | ||
| ``` | ||
|
|
||
| ## Build Commands | ||
|
|
||
| ### Backend (.NET 8.0) | ||
|
|
||
| ```bash | ||
| # Build the framework | ||
| dotnet build shesha-core/Shesha.sln --configuration Release | ||
|
|
||
| # Run backend tests (requires Docker for Testcontainers) | ||
| cd shesha-core/test/Shesha.Tests | ||
| dotnet test Shesha.Tests.csproj --configuration Release | ||
| ``` | ||
|
|
||
| ### Frontend (Node.js 20+, npm 10+) | ||
|
|
||
| ```bash | ||
| # Install dependencies | ||
| cd shesha-reactjs | ||
| npm install | ||
|
|
||
| # Build the library (includes lint check) | ||
| npm run build | ||
|
|
||
| # Run tests | ||
| npm test | ||
|
|
||
| # Run single test file | ||
| npm test -- --testPathPattern="path/to/test" | ||
|
|
||
| # Watch mode for development | ||
| npm run start | ||
|
|
||
| # Lint | ||
| npm run lint | ||
| npm run lint-fix | ||
|
|
||
| # Type check (strict null checks) | ||
| npm run type-check | ||
| ``` | ||
|
|
||
| ### Starter Application | ||
|
|
||
| ```bash | ||
| # Frontend development | ||
| cd shesha-starter/frontend | ||
| npm install | ||
| npm run dev | ||
|
|
||
| # Production build | ||
| npm run build | ||
| npm run start | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Backend Layered Architecture | ||
|
|
||
| 1. **Domain Layer** (`Shesha.Core`) - Domain entities, interfaces, business logic | ||
| 2. **Framework Layer** (`Shesha.Framework`) - Dynamic CRUD, metadata, configuration studio, JSON logic engine | ||
| 3. **Application Layer** (`Shesha.Application`) - Application services, DTOs, CRUD app services | ||
| 4. **Web Layer** (`Shesha.Web.Host`, `Shesha.Web.Core`) - API controllers, authorization, Swagger | ||
|
|
||
| ### ABP Module System | ||
|
|
||
| Modules inherit from `SheshaModule` with lifecycle hooks: | ||
| - `PreInitialize()` - Register services | ||
| - `Initialize()` - Configure services | ||
| - `InitializeConfigurationAsync()` - Async initialization | ||
|
|
||
| Key modules: `Shesha.NHibernate` (ORM), `Shesha.GraphQL`, `Shesha.Scheduler` (HangFire), `Shesha.FluentMigrator` | ||
|
|
||
| ### Frontend Architecture | ||
|
|
||
| **Provider Pattern** - Context providers for state management: | ||
| - `SheshaApplicationProvider` - App-level configuration | ||
| - `FormDesignerProvider` - Form builder context | ||
| - `DataContextProvider` - Data management (appContext, pageContext, formContext) | ||
|
|
||
| **Key Directories** (`shesha-reactjs/src/`): | ||
| - `components/` - 40+ UI components (dataTable, autocomplete, modal, etc.) | ||
| - `designer-components/` - Form builder components | ||
| - `providers/` - Context providers | ||
| - `hooks/` - Custom React hooks (useGet, useMutate, useFormExpression, etc.) | ||
| - `apis/` - API integration layer | ||
|
|
||
| ### Dynamic CRUD Pattern | ||
|
|
||
| Backend automatically generates CRUD APIs from domain entities via `DynamicCrudAppService`. Enable through entity configuration - no boilerplate code needed. | ||
|
|
||
| ### DataContext (v0.44+) | ||
|
|
||
| Replaces GlobalState to prevent unnecessary re-renders: | ||
| - `appContext` - App-wide data | ||
| - `pageContext` - Page-scoped data | ||
| - `formContext` - Form-scoped data | ||
|
|
||
| ## Testing | ||
|
|
||
| ### Backend Tests | ||
| - Framework: xUnit with Testcontainers | ||
| - **Requires Docker daemon running** | ||
| - Tests run against SQL Server/PostgreSQL in containers | ||
|
|
||
| ### Frontend Tests | ||
| - Framework: Jest with React Testing Library | ||
| - Config: `jest.config.js` | ||
| - Test files: `*.test.ts` or `*.spec.tsx` in `src/` | ||
|
|
||
| ## Key Patterns | ||
|
|
||
| ### Form Configuration | ||
| - Default values set via `onAfterDataLoad` scripts (not DefaultValue property) | ||
| - Scripts execute in dependency order | ||
| - Direct write access to `data` and `context` without SetFieldValue | ||
|
|
||
| ### Commits | ||
| Use conventional commits via Commitizen: `npm run commit` | ||
|
|
||
| ## Database Support | ||
|
|
||
| - Primary: SQL Server, PostgreSQL (via NHibernate) | ||
| - Additional: MongoDB (Shesha.MongoRepository), PostGIS for geographic data | ||
| - Migrations: FluentMigrator |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...cyInjection/ServiceCollectionRegistrar.cs → ...cyInjection/ServiceCollectionRegistrar.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Shesha.Tests/Fixtures/IDatabaseFixture.cs → ...esha.Testing/Fixtures/IDatabaseFixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
shesha-core/src/Shesha.Testing/Fixtures/LocalSqlServerCollection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Xunit; | ||
|
|
||
| namespace Shesha.Testing.Fixtures | ||
| { | ||
| /// <summary> | ||
| /// Shared local SQL Server fixture collection. | ||
| /// </summary> | ||
| [CollectionDefinition(Name)] | ||
| public class LocalSqlServerCollection : ICollectionFixture<LocalSqlServerFixture> | ||
| { | ||
| public const string Name = "LocalSqlServer"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
shesha-core/src/Shesha.Testing/Fixtures/PostgreSqlCollection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Xunit; | ||
|
|
||
| namespace Shesha.Testing.Fixtures | ||
| { | ||
| /// <summary> | ||
| /// Shared PostgreSql fixture (Testcontainers). | ||
| /// </summary> | ||
| [CollectionDefinition(Name)] | ||
| public class PostgreSqlCollection : ICollectionFixture<PostgreSqlFixture> | ||
| { | ||
| public const string Name = "SharedPostgreSql"; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
shesha-core/src/Shesha.Testing/Fixtures/SqlServerCollection.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Xunit; | ||
|
|
||
| namespace Shesha.Testing.Fixtures | ||
| { | ||
| /// <summary> | ||
| /// Shared Sql Server fixture (Testcontainers). | ||
| /// </summary> | ||
| [CollectionDefinition(Name)] | ||
| public class SqlServerCollection : ICollectionFixture<SqlServerFixture> | ||
| { | ||
| public const string Name = "SharedSqlServer"; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.