Skip to content

Conversation

@RGO230
Copy link
Contributor

@RGO230 RGO230 commented Jul 9, 2025

@RGO230 RGO230 self-assigned this Jul 9, 2025
@astorozhevsky astorozhevsky requested a review from Copilot August 28, 2025 09:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds the ability to set custom Nova resource names for the Nova tests generator, addressing issue #140. The changes enable users to specify a custom resource name when generating Nova tests, particularly useful when Nova resources are organized in subdirectories or have non-standard naming conventions.

Key changes:

  • Modified Nova test generation to accept and use custom resource names via --resource-name option
  • Updated test templates and naming conventions to use the resource name instead of the model name
  • Added proper validation and error handling for multiple matching resources

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Generators/NovaTestGenerator.php Core logic to handle custom resource names and resource discovery
src/Commands/MakeEntityCommand.php Added --resource-name command line option
stubs/nova_test.blade.php Updated template to use resource names in generated tests
Multiple test fixtures Updated fixture files to reflect new naming conventions with resource names
ReadMe.md Documentation for the new --resource-name option

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


public static function label(): string
{
return 'WelcomeBonus';
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label() method returns 'WelcomeBonus' but this is a PostResource. This should return 'Post' to match the actual resource.

Suggested change
return 'WelcomeBonus';
return 'Post';

Copilot uses AI. Check for mistakes.
return [
new PublishPostAction,
new UnPublishPostAction,
new UnPublishPostAction,
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a duplicate UnPublishPostAction in the actions array. This creates redundancy and should be removed.

Suggested change
new UnPublishPostAction,

Copilot uses AI. Check for mistakes.
return [
new PublishPostAction,
new UnPublishPostAction,
new UnPublishPostAction,
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a duplicate UnPublishPostAction in the actions array. This creates redundancy and should be removed.

Suggested change
new UnPublishPostAction,

Copilot uses AI. Check for mistakes.
{
use NovaTestTrait;

protected static User $user;
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The User class is not imported. Add 'use App\Models\User;' or the appropriate User class import at the top of the file.

Copilot uses AI. Check for mistakes.
{
return [
[
'action' => PublishPostAction::class,
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PublishPostAction class is not imported. Add the appropriate import statement at the top of the file.

Copilot uses AI. Check for mistakes.
'state' => 'run_publish_post_action_state',
],
[
'action' => UnPublishPostAction::class,
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnPublishPostAction class is not imported. Add the appropriate import statement at the top of the file.

Copilot uses AI. Check for mistakes.
@RGO230 RGO230 assigned AZabolotnikov and unassigned RGO230 Sep 1, 2025
protected function loadNovaFields()
{
return app("\\App\\Nova\\{$this->novaModelName}")->fields(new NovaRequest());
return app("{$this->fullNovaResourcePath}")->fields(new NovaRequest());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return app("{$this->fullNovaResourcePath}")->fields(new NovaRequest());
return app($this->fullNovaResourcePath)->fields(new NovaRequest());

protected function loadNovaFilters()
{
return app("\\App\\Nova\\{$this->novaModelName}")->filters(new NovaRequest());
return app("{$this->fullNovaResourcePath}")->filters(new NovaRequest());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return app("{$this->fullNovaResourcePath}")->filters(new NovaRequest());
return app($this->fullNovaResourcePath)->filters(new NovaRequest());

}

if ($this->classExists('nova', "Nova{$this->model}Test")) {
$this->isNovaResourceExists();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this in another request https://github.com/RonasIT/laravel-entity-generator/pull/163/files#L44

Let's take solution from Pull Request #163

{--only-nova-resource : Set this flag if you want to create only nova resource.}
{--only-nova-tests : Set this flag if you want to create only nova resource tests.}
{--resource-name= : Override the default Nova resource name. Used only with --only-nova-tests.}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pleae this feature implement by in next task, not this #159

@RGO230 RGO230 closed this Sep 5, 2025
@RGO230 RGO230 deleted the 159-ability-to-set-nova-resource-for-nova-tests-generator branch September 5, 2025 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants