Skip to content
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

assertWizardCurrentStep not working as expected #14887

Open
herrwalter opened this issue Nov 26, 2024 · 0 comments
Open

assertWizardCurrentStep not working as expected #14887

herrwalter opened this issue Nov 26, 2024 · 0 comments
Labels
Milestone

Comments

@herrwalter
Copy link

herrwalter commented Nov 26, 2024

Package

filament/filament

Package Version

3.2.123

Laravel Version

11.31.0

Livewire Version

3.5.12

PHP Version

8.3.13

Problem description

I've got a CreateRecord page of my model
I define the form in the corresponding page with a wizard with multiple steps (4 in my case)

public function form(Form $form): Form
    {
        $form->columns(3);
        $form->schema([
                    Wizard::make([
                            Wizard\Step::make(__('filament.projects.label-singular'))
                                   ->schema(self::getProjectStep()),
                            Wizard\Step::make(__('details'))
                                   ->schema(self::getDetailsStep()),
                            Wizard\Step::make(__('filament.tasks.photo'))
                                   ->schema(self::getPhotoStep()),
                            Wizard\Step::make(__('filament.tasks.floorplan'))
                                   ->schema(self::getFloorPlanStep()),
                 ])
                 ->startOnStep(function (): int {
                    if ($this->projectId > 0) {
                        return 2;
                    }
                    return 1;
                })
                ->submitAction($this->getSubmitFormAction())
        ]);

        return parent::form($form);
    }

Then in my tests i would expect the "assertWizardCurrentStep" to be 2, but, it's 1.

        Livewire::withQueryParams([
            'projectId' => $project->id
        ])->test(CreateTask::class)
            ->assertWizardCurrentStep(2); // fails!
```

I've also tested this by not providing a closure and a hard coded 2, which results in the same false assertion



### Expected behavior

I'm expecting the assertWizardStartingStep to assert to 2 in stead of 1.

I've tried 

### Steps to reproduce

1. Create a CreatePage of any model. 
2. Define a wizard in the form with multiple steps. 
3. Set starting step on 2 (or greater then 1)
4. Create a test and assert using assertWizardCurrentStep that the current step is 2. 
5. Check the view in the browser: it is not.

### Reproduction repository (issue will be closed if this is not valid)

https://github.com/herrwalter/filament-issue-current-step

### Relevant log output

_No response_

<!-- POLAR PLEDGE BADGE START -->
### Donate 💰 to fund this issue

- You can donate funding to this issue. We receive the money once the issue is completed & confirmed by you.
- 100% of the funding will be distributed between the Filament core team to run all aspects of the project.
- Thank you in advance for helping us make maintenance sustainable!

<a href="https://polar.sh/filamentphp/filament/issues/14887">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/filamentphp/filament/issues/14887/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/filamentphp/filament/issues/14887/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->
@github-project-automation github-project-automation bot moved this to Todo in Roadmap Nov 26, 2024
@danharrin danharrin added this to the v3 milestone Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

2 participants