Calinou / godot-asset-library-laravel

Experimental Godot Asset Library rewrite using the Laravel framework
MIT License
66 stars 16 forks source link

Test form validation in the asset submission process #26

Open Calinou opened 4 years ago

Calinou commented 4 years ago

I added basic form testing in https://github.com/Calinou/godot-asset-library-laravel/commit/42a5d485b7986002622710603cd5b0e3daeeb38a, 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 commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago
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. https://github.com/Calinou/godot-asset-library-laravel/blob/131b47ab21114f62b5fe10668cb516b308ba05d6/tests/Feature/AssetsTest.php#L19-L29

Calinou commented 3 years ago

@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.