mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 05:04:07 -08:00
Bugfixes based on functional tests (#3338)
* Toggles the disabled state of auto_increment_prefix To insert a prefix you had to toggle the checkbox, save the settings and reload. With this script it is immediate. Fixes #1390 * Delete asset image: made checkbox more visible Related to #3153 * Added personal-access-token component * Created basic API testing configuration * First version of /components endpoind cest * On-the-fly bearer token generation * Completed testing of PATCH and PUT methods * Added /components/{id}/assets route with tests * Updated route and dataTable in view * Completed test assertion * Added links to assets in ComponentsAssets view * Linked Company in AssetView page * Bugfixes based on functional tests * Removed unused function * Marked tests as incomplete * Added check for existence in groups/edit.blade.php
This commit is contained in:
parent
ad9470b6f8
commit
e7f7d739ed
|
@ -173,7 +173,7 @@ class CategoriesController extends Controller
|
|||
|
||||
$category->delete();
|
||||
// Redirect to the locations management page
|
||||
return redirect()->to('admin/settings/categories')->with('success', trans('admin/categories/message.delete.success'));
|
||||
return redirect()->to(route('categories.index'))->with('success', trans('admin/categories/message.delete.success'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class GroupsController extends Controller
|
|||
if ($group->save()) {
|
||||
return redirect()->route("groups.index")->with('success', trans('admin/groups/message.success.create'));
|
||||
}
|
||||
return redirect()->back()->withInput()->withErrors($group->getErrors());
|
||||
return redirect(route('groups.create'))->withInput()->withErrors($group->getErrors());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -208,21 +208,21 @@ class LocationsController extends Controller
|
|||
// Check if the location exists
|
||||
if (is_null($location = Location::find($locationId))) {
|
||||
// Redirect to the blogs management page
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.not_found'));
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.not_found'));
|
||||
}
|
||||
|
||||
|
||||
if ($location->users->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_users'));
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_users'));
|
||||
} elseif ($location->childLocations->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_child_loc'));
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_child_loc'));
|
||||
} elseif ($location->assets->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
} elseif ($location->assignedassets->count() > 0) {
|
||||
return redirect()->to('admin/settings/locations')->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
return redirect()->to(route('locations.index'))->with('error', trans('admin/locations/message.assoc_assets'));
|
||||
} else {
|
||||
$location->delete();
|
||||
return redirect()->to('admin/settings/locations')->with('success', trans('admin/locations/message.delete.success'));
|
||||
return redirect()->to(route('locations.index'))->with('success', trans('admin/locations/message.delete.success'));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
'helpTitle' => trans('admin/groups/general.about_groups_title'),
|
||||
'helpText' => trans('admin/groups/general.about_groups_text'),
|
||||
'item' => $group,
|
||||
'formAction' => ($group) ? route('groups.update', ['accessory' => $group->id]) : route('groups.store'),
|
||||
'formAction' => ($group !== null && $group->id !== null) ? route('groups.update', ['accessory' => $group->id]) : route('groups.store'),
|
||||
|
||||
])
|
||||
@section('content')
|
||||
|
|
|
@ -9,14 +9,16 @@ class AccessoriesCest
|
|||
$I->fillField('username', 'snipeit');
|
||||
$I->fillField('password', 'snipeit');
|
||||
$I->click('Login');
|
||||
$I->seeAuthentication();
|
||||
}
|
||||
|
||||
// tests
|
||||
public function tryToTest(FunctionalTester $I)
|
||||
public function loadsFormWithoutErrors(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('ensure that the create accessories form loads without errors');
|
||||
$I->lookForwardTo('seeing it load without errors');
|
||||
$I->amOnPage('/accessories/create');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->dontSee('Create Accessory', '.page-header');
|
||||
$I->see('Create Accessory', 'h1.pull-left');
|
||||
}
|
||||
|
@ -25,6 +27,7 @@ class AccessoriesCest
|
|||
{
|
||||
$I->wantTo("Test Validation Fails with blank elements");
|
||||
$I->amOnPage('/accessories/create');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->click('Save');
|
||||
$I->seeElement('.alert-danger');
|
||||
$I->see('The name field is required.', '.alert-msg');
|
||||
|
@ -36,6 +39,7 @@ class AccessoriesCest
|
|||
{
|
||||
$I->wantTo("Test Validation Fails with short name");
|
||||
$I->amOnPage('/accessories/create');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->fillField('name', 't2');
|
||||
$I->fillField('qty', '-15');
|
||||
$I->fillField('min_amt', '-15');
|
||||
|
@ -65,6 +69,7 @@ class AccessoriesCest
|
|||
|
||||
$I->wantTo("Test Validation Succeeds");
|
||||
$I->amOnPage('/accessories/create');
|
||||
$I->seeResponseCodeIs(200);
|
||||
|
||||
$I->submitForm('form#create-form', $values);
|
||||
$I->seeRecord('accessories', $values);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
|
||||
class CategoryCest
|
||||
class CategoriesCest
|
||||
{
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ class CategoryCest
|
|||
|
||||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$category = factory(App\Models\Category::class, 'asset-category')->make();
|
||||
$category = factory(App\Models\Category::class, 'category')->make();
|
||||
$values = [
|
||||
'name' => $category->name,
|
||||
'category_type' => $category->category_type,
|
||||
|
@ -55,7 +55,7 @@ class CategoryCest
|
|||
public function allowsDelete(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('Ensure I can delete a category');
|
||||
$category = factory(App\Models\Category::class, 'asset-category')->create();
|
||||
$category = factory(App\Models\Category::class, 'category')->create();
|
||||
$I->sendDelete(route('categories.destroy', $category->id), ['_token' => csrf_token()]);
|
||||
$I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
|
|
@ -14,11 +14,12 @@ class GroupsCest
|
|||
}
|
||||
|
||||
// tests
|
||||
public function tryToTest(FunctionalTester $I)
|
||||
public function loadsFormWithoutErrors(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo('ensure that the create groups form loads without errors');
|
||||
$I->lookForwardTo('seeing it load without errors');
|
||||
$I->amOnPage(route('create/group'));
|
||||
$I->amOnPage(route('groups.create'));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->dontSee('Create New Group', '.page-header');
|
||||
$I->see('Create New Group', 'h1.pull-left');
|
||||
}
|
||||
|
@ -26,7 +27,8 @@ class GroupsCest
|
|||
public function failsEmptyValidation(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo("Test Validation Fails with blank elements");
|
||||
$I->amOnPage(route('create/group'));
|
||||
$I->amOnPage(route('groups.create'));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->click('Save');
|
||||
$I->seeElement('.alert-danger');
|
||||
$I->see('The name field is required.', '.alert-msg');
|
||||
|
@ -35,7 +37,8 @@ class GroupsCest
|
|||
public function failsShortValidation(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo("Test Validation Fails with short name");
|
||||
$I->amOnPage(route('create/group'));
|
||||
$I->amOnPage(route('groups.create'));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->fillField('name', 't2');
|
||||
$I->click('Save');
|
||||
$I->seeElement('.alert-danger');
|
||||
|
@ -45,19 +48,37 @@ class GroupsCest
|
|||
public function passesCorrectValidation(FunctionalTester $I)
|
||||
{
|
||||
$I->wantTo("Test Validation Succeeds");
|
||||
$I->amOnPage(route('create/group'));
|
||||
$I->amOnPage(route('groups.create'));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->fillField('name', 'TestGroup');
|
||||
$I->click('Save');
|
||||
$I->dontSee('<span class="');
|
||||
$I->seeElement('.alert-success');
|
||||
}
|
||||
|
||||
public function allowsDelete(FunctionalTester $I)
|
||||
public function allowsDelete(FunctionalTester $I, $scenario)
|
||||
{
|
||||
$I->wantTo("Fix this test to generate a group for deletes");
|
||||
$scenario->incomplete('Fix this test to generate a group for deletes');
|
||||
$I->wantTo('Ensure I can delete a group');
|
||||
// $I->amOnPage(route('delete/group', Group::doesntHave('users')->first()->id));
|
||||
// $I->seeElement('.alert-success');
|
||||
|
||||
// create a group
|
||||
$I->amOnPage(route('groups.create'));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->fillField('name', 'TestGroup');
|
||||
$I->click('Save');
|
||||
$I->dontSee('<span class="');
|
||||
$I->seeElement('.alert-success');
|
||||
|
||||
// delete it
|
||||
$I->amOnPage(route('groups.delete', Group::doesntHave('users')->first()->id));
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->seeElement('.alert-success');
|
||||
// $I->seeResponseCodeIs(200);
|
||||
}
|
||||
|
||||
public function allowsEditing(FunctionalTester $I, $scenario)
|
||||
{
|
||||
$scenario->incomplete('Fix this test to generate a group for editing');
|
||||
$I->wantTo('Ensure i can edit a group');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use App\Models\License;
|
||||
|
||||
class licensesCest
|
||||
class LicensesCest
|
||||
{
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,2 @@
|
|||
<?php
|
||||
// Here you can initialize variables that will be available to your tests
|
||||
function _beforeSuite(FunctionalTester $I)
|
||||
{
|
||||
echo "Hello";
|
||||
}
|
Loading…
Reference in a new issue