forked from ProcessMaker/processmaker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRequestsTest.php
More file actions
90 lines (76 loc) · 2.52 KB
/
RequestsTest.php
File metadata and controls
90 lines (76 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace Tests\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Hash;
use Laravel\Dusk\Browser;
use ProcessMaker\Models\User;
use Tests\Browser\Pages\LoginPage;
use Tests\Browser\Pages\RequestsPage;
use Tests\DuskTestCase;
class RequestsTest extends DuskTestCase
{
private function setuser()
{
$user = User::where('username', 'testuser')->first();
if (!$user) {
$user = User::factory()->create([
'username' => 'testuser',
'password' => Hash::make('secret'),
'status' => 'ACTIVE',
]);
}
return $user;
}
public function test_request_route_protected()
{
$this->browse(function (Browser $browser) {
$browser->visit('/requests')
->assertPathIs('/login');
});
}
public function test_request_route_loads()
{
$user = $this->setuser();
$this->browse(function ($first) use ($user) {
$first->loginAs($user)
->visit(new RequestsPage)
->assertRouteIs('requests.index')
->assertSee('My Requests');
});
}
public function test_pmql_initial_load()
{
$user = $this->setuser();
$this->browse(function ($first) use ($user) {
$first->loginAs($user)
->visit(new RequestsPage)
->assertVue('pmql', '(status = "In Progress") AND (requester = "' . $user->username . '")', '#requests-listing');
});
}
public function test_vuetable_initial_load()
{
// Initial load of the site would have no requests started
$user = $this->setuser();
$this->browse(function ($first) use ($user) {
$first->loginAs($user)
->visit(new RequestsPage)
->waitUntilMissing('.vuetable')
->assertVue('data', '', '@container');
});
}
public function test_start_request()
{
$user = $this->setuser();
$this->browse(function ($first) use ($user) {
$first->loginAs($user)
->visit(new RequestsPage)
->waitFor('#navbar')
->click('#navbar-request-button')
->whenAvailable('#requests-modal', function ($modal) {
$modal->assertSee('New Request')
->waitFor('.no-requests')
->assertSee("You don't have any Processes.");
});
});
}
}