-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #482 from portabilis/dusk-enderecamento
Testes de browser para módulo de endereçamento
- Loading branch information
Showing
36 changed files
with
1,522 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class City extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'state_id', | ||
'name', | ||
'ibge' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Country extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'name', 'ibge' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class District extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'city_id', 'name', 'ibge' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Neighborhood extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'district_id', | ||
'name', | ||
'zone', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace App; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class State extends Model | ||
{ | ||
/** | ||
* The attributes that are mass assignable. | ||
* | ||
* @var array | ||
*/ | ||
protected $fillable = [ | ||
'country_id', 'name', 'abbreviation', 'ibge' | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use App\State; | ||
use Faker\Generator as Faker; | ||
|
||
$factory->define(App\City::class, function (Faker $faker) { | ||
return [ | ||
'state_id' => function () { | ||
|
||
$state = State::query()->inRandomOrder()->first(); | ||
|
||
if (empty($state)) { | ||
$state = factory(State::class)->create(); | ||
} | ||
|
||
return $state->getKey(); | ||
}, | ||
'name' => $faker->city, | ||
'ibge' => $faker->randomNumber(6), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
use Faker\Generator as Faker; | ||
|
||
$factory->define(App\Country::class, function (Faker $faker) { | ||
return [ | ||
'name' => $faker->country, | ||
'ibge' => $faker->randomNumber(6), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use App\City; | ||
use Faker\Generator as Faker; | ||
|
||
$factory->define(App\District::class, function (Faker $faker) { | ||
return [ | ||
'city_id' => function () { | ||
|
||
$city = City::query()->inRandomOrder()->first(); | ||
|
||
if (empty($city)) { | ||
$city = factory(City::class)->create(); | ||
} | ||
|
||
return $city->getKey(); | ||
}, | ||
'name' => $faker->name, | ||
'ibge' => $faker->randomNumber(6), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use App\District; | ||
use Faker\Generator as Faker; | ||
|
||
$factory->define(App\Neighborhood::class, function (Faker $faker) { | ||
return [ | ||
'district_id' => function () { | ||
|
||
$district = District::query()->inRandomOrder()->first(); | ||
|
||
if (empty($district)) { | ||
$district = factory(District::class)->create(); | ||
} | ||
|
||
return $district->getKey(); | ||
}, | ||
'name' => $faker->name, | ||
'zone' => $faker->randomElement([1, 2]), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use App\Country; | ||
use Faker\Generator as Faker; | ||
|
||
$factory->define(App\State::class, function (Faker $faker) { | ||
return [ | ||
'country_id' => function () use ($faker) { | ||
|
||
$country = Country::query()->inRandomOrder()->first(); | ||
|
||
if (empty($country) || $faker->boolean()) { | ||
$country = factory(Country::class)->create(); | ||
} | ||
|
||
return $country->getKey(); | ||
}, | ||
'name' => $faker->colorName . ' State', | ||
'abbreviation' => function () use ($faker) { | ||
return $faker->unique()->randomElement([ | ||
'AA', 'BB', 'CC', 'DD', 'EE', 'FF', 'GG', 'HH', 'II', 'JJ', 'KK', | ||
'LL', 'MM', 'NN', 'OO', 'PP', 'QQ', 'RR', 'SS', 'TT', 'UU', 'VV', | ||
'WW', 'XX', 'YY', 'ZZ' | ||
]); | ||
}, | ||
'ibge' => $faker->randomNumber(6), | ||
]; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Tests\Browser; | ||
|
||
use Illuminate\Foundation\Testing\WithFaker; | ||
use Tests\Browser\Pages\City\CreatePage; | ||
use Tests\Browser\Pages\City\DetailPage; | ||
use Tests\Browser\Pages\City\ListingPage; | ||
use Tests\Browser\Pages\City\UpdatePage; | ||
use Tests\DuskTestCase; | ||
use Laravel\Dusk\Browser; | ||
|
||
class CityTest extends DuskTestCase | ||
{ | ||
use WithFaker; | ||
|
||
/** | ||
* Test city flow. | ||
* | ||
* @return void | ||
* | ||
* @throws \Throwable | ||
*/ | ||
public function testFlowForCityPages() | ||
{ | ||
$this->browse(function (Browser $browser) { | ||
$country = 45; // Brasil | ||
$state = 'SC'; // Santa Catarina | ||
$cityName = $this->faker->city; | ||
$cityNameAfterUpdate = $this->faker->city; | ||
|
||
$browser->loginLegacy(); | ||
|
||
$browser->visit(new ListingPage()) | ||
->press(' Novo '); | ||
|
||
$browser->on(new CreatePage()) | ||
->select('@select-country', $country) | ||
->waitUsing(10, 1000, function () use ($browser) { | ||
return $browser->resolver->findOrFail('[name=sigla_uf]')->isEnabled(); | ||
}) | ||
->select('@select-state', $state) | ||
->type('@input-name', $cityName) | ||
->press('@button-save'); | ||
|
||
$browser->on(new ListingPage()) | ||
->type('@input-name', $cityName) | ||
->press('Buscar'); | ||
|
||
$browser->on(new ListingPage()); | ||
|
||
$cityId = $browser->resolver->findByText($cityName, 'a')->getAttribute('data-id'); | ||
|
||
$browser->clickLink($cityName); | ||
|
||
$browser->on(new DetailPage($cityId)) | ||
->press(' Editar '); | ||
|
||
$browser->on(new UpdatePage($cityId)) | ||
->type('@input-name', $cityNameAfterUpdate) | ||
->press('@button-save'); | ||
|
||
$browser->on(new ListingPage()) | ||
->type('@input-name', $cityNameAfterUpdate) | ||
->press('Buscar') | ||
->clickLink($cityNameAfterUpdate); | ||
|
||
$browser->on(new DetailPage($cityId)); | ||
}); | ||
} | ||
|
||
/** | ||
* Test city listing. | ||
* | ||
* @return void | ||
* | ||
* @throws \Throwable | ||
*/ | ||
public function testCityListing() | ||
{ | ||
$this->browse(function (Browser $browser) { | ||
$browser->loginLegacy(); | ||
$browser->visit(new ListingPage()); | ||
}); | ||
} | ||
} |
Oops, something went wrong.