Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Test form validation in the asset submission process #26

Open
Calinou opened this issue Oct 27, 2019 · 4 comments · May be fixed by #262
Open

Test form validation in the asset submission process #26

Calinou opened this issue Oct 27, 2019 · 4 comments · May be fixed by #262

Comments

@Calinou
Copy link
Owner

Calinou commented Oct 27, 2019

I added basic form testing in 42a5d48, but this doesn't actually check whether the asset is actually present in the database (or whether the form is even valid).

I tried doing this, but it seems Laravel kept resetting the database even if I did the assertions in the same method.

I also don't know how to check for the form validation in an HTTP test, as both valid and invalid forms result in a redirection to the same URL when testing.

@wardy484
Copy link

I think you can assert errors are in the session (error bag): docs.

Alternatively, we could use ->assertSee("some error message") to validate that the error content has been displayed on the view. I'm not familiar enough with the project yet to say which would be the better solution.

@Demetriex Demetriex linked a pull request Feb 26, 2021 that will close this issue
@Demetriex
Copy link

@Calinou sorry for the ping, but do you also have problems with fields that uses SuccessRespondingUrl rule

I have entered correct url pattern, it just has RequestError cURL error 60: SSL certificate problem: unable to get local issuer certificate this is fixed with adding 'verify' => CaBundle::getSystemCaRootBundlePath() in the request options

@Demetriex
Copy link

array:4 [
  "_token" => "4lA4QarzhUmVfeygN6WdCKJSD5JGspG5vOnQUjk7"
  "_old_input" => array:9 [
    "title" => "My Own Asset"
    "blurb" => "One-line description of the asset"
    "description" => "A long description…"
    "tags" => "platformer, 2d, pixel-art, gdnative"
    "category" => 0
    "license" => "MIT"
    "versions[0][version_string]" => "1.0.0"
    "versions[0][godot_version]" => "3.2"
    "browse_url" => "https://github.com/user/asset"
  ]
  "_flash" => array:2 [
    "new" => []
    "old" => array:2 [
      0 => "_old_input"
      1 => "errors"
    ]
  ]
  "errors" => Illuminate\Support\ViewErrorBag {#2658
    #bags: array:1 [
      "default" => Illuminate\Support\MessageBag {#2642
        #messages: array:4 [
          "category_id" => array:1 [
            0 => "The category id field is required."
          ]
          "cost" => array:1 [
            0 => "The cost field is required."
          ]
          "browse_url" => array:1 [
            0 => "The repository URL doesn't seem to point to a valid page or resource."
          ]
          "versions" => array:1 [
            0 => "The versions field is required."
          ]
        ]
        #format: ":message"
      }
    ]
  }
]

looks like there are fields that are required that is missing.

public const ASSET_DATA = [
'title' => 'My Own Asset',
'blurb' => 'One-line description of the asset',
'description' => 'A long description…',
'tags' => 'platformer, 2d, pixel-art, gdnative',
'category' => Asset::CATEGORY_2D_TOOLS,
'license' => 'MIT',
'versions[0][version_string]' => '1.0.0',
'versions[0][godot_version]' => '3.2',
'browse_url' => 'https://github.com/user/asset',
];

@Calinou
Copy link
Owner Author

Calinou commented Mar 5, 2021

@Demetriex I can't look at fixing unit tests right now. I'm looking at finally adding a Docker setup for development and production, which is more important currently.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants