Page MenuHomePhorge

D1498.1775190892.diff
No OneTemporary

Authored By
Unknown
Size
11 KB
Referenced Files
None
Subscribers
None

D1498.1775190892.diff

diff --git a/src/resources/vue/User/Info.vue b/src/resources/vue/User/Info.vue
--- a/src/resources/vue/User/Info.vue
+++ b/src/resources/vue/User/Info.vue
@@ -273,14 +273,8 @@
axios[method](location, this.user)
.then(response => {
- if (response.data.status == 'success') {
- this.$toast.success(response.data.message)
- }
-
- // on new user redirect to users list
- if (this.user_id === 'new') {
- this.$router.push({ name: 'users' })
- }
+ this.$toast.success(response.data.message)
+ this.$router.push({ name: 'users' })
})
},
onInputSku(e) {
diff --git a/src/resources/vue/User/Profile.vue b/src/resources/vue/User/Profile.vue
--- a/src/resources/vue/User/Profile.vue
+++ b/src/resources/vue/User/Profile.vue
@@ -104,9 +104,8 @@
delete this.profile.password
delete this.profile.password_confirm
- if (response.data.status == 'success') {
- this.$toast.success(response.data.message)
- }
+ this.$toast.success(response.data.message)
+ this.$router.push({ name: 'dashboard' })
})
}
}
diff --git a/src/tests/Browser.php b/src/tests/Browser.php
--- a/src/tests/Browser.php
+++ b/src/tests/Browser.php
@@ -185,6 +185,27 @@
return $this;
}
+ /**
+ * Clears the input field and related vue v-model data.
+ */
+ public function vueClear($selector)
+ {
+ if ($this->resolver->prefix != 'body') {
+ $selector = $this->resolver->prefix . ' ' . $selector;
+ }
+
+ // The existing clear(), and type() with empty string do not work.
+ // We have to clear the field and dispatch 'input' event programatically.
+
+ $this->script(
+ "var element = document.querySelector('$selector');"
+ . "element.value = '';"
+ . "element.dispatchEvent(new Event('input'))"
+ );
+
+ return $this;
+ }
+
/**
* Execute code within body context.
* Useful to execute code that selects elements outside of a component context
diff --git a/src/tests/Browser/UserProfileTest.php b/src/tests/Browser/UserProfileTest.php
--- a/src/tests/Browser/UserProfileTest.php
+++ b/src/tests/Browser/UserProfileTest.php
@@ -93,33 +93,33 @@
->assertValue('div.row:nth-child(9) input[type=password]', '')
->assertSeeIn('button[type=submit]', 'Submit');
+ // Test form error handling
+ $browser->type('#phone', 'aaaaaa')
+ ->type('#external_email', 'bbbbb')
+ ->click('button[type=submit]')
+ ->waitFor('#phone + .invalid-feedback')
+ ->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.')
+ ->assertSeeIn(
+ '#external_email + .invalid-feedback',
+ 'The external email must be a valid email address.'
+ )
+ ->assertFocused('#phone')
+ ->assertToast(Toast::TYPE_ERROR, 'Form validation error')
+ ->clearToasts();
+
// Clear all fields and submit
// FIXME: Should any of these fields be required?
- $browser->type('#first_name', '')
- ->type('#last_name', '')
- ->type('#organization', '')
- ->type('#phone', '')
- ->type('#external_email', '')
- ->type('#billing_address', '')
- ->select('#country', '')
- ->click('button[type=submit]');
+ $browser->vueClear('#first_name')
+ ->vueClear('#last_name')
+ ->vueClear('#organization')
+ ->vueClear('#phone')
+ ->vueClear('#external_email')
+ ->vueClear('#billing_address')
+ ->click('button[type=submit]')
+ ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
})
- ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
-
- // Test error handling
- $browser->with('@form', function (Browser $browser) {
- $browser->type('#phone', 'aaaaaa')
- ->type('#external_email', 'bbbbb')
- ->click('button[type=submit]')
- ->waitFor('#phone + .invalid-feedback')
- ->assertSeeIn('#phone + .invalid-feedback', 'The phone format is invalid.')
- ->assertSeeIn(
- '#external_email + .invalid-feedback',
- 'The external email must be a valid email address.'
- )
- ->assertFocused('#phone')
- ->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- });
+ // On success we're redirected to Dashboard
+ ->on(new Dashboard());
});
}
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php
--- a/src/tests/Browser/UsersTest.php
+++ b/src/tests/Browser/UsersTest.php
@@ -158,56 +158,53 @@
->assertValue('div.row:nth-child(7) input[type=password]', '')
->assertSeeIn('div.row:nth-child(8) label', 'Confirm password')
->assertValue('div.row:nth-child(8) input[type=password]', '')
- ->assertSeeIn('button[type=submit]', 'Submit');
-
- // Clear some fields and submit
- $browser->type('#first_name', '')
- ->type('#last_name', '')
+ ->assertSeeIn('button[type=submit]', 'Submit')
+ // Clear some fields and submit
+ ->vueClear('#first_name')
+ ->vueClear('#last_name')
->click('button[type=submit]');
})
- ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
+ ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.')
+ ->on(new UserList())
+ ->click('@table tr:nth-child(3) a')
+ ->on(new UserInfo())
+ ->assertSeeIn('#user-info .card-title', 'User account')
+ ->with('@form', function (Browser $browser) {
+ // Test error handling (password)
+ $browser->type('#password', 'aaaaaa')
+ ->vueClear('#password_confirmation')
+ ->click('button[type=submit]')
+ ->waitFor('#password + .invalid-feedback')
+ ->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.')
+ ->assertFocused('#password')
+ ->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- // Test error handling (password)
- $browser->with('@form', function (Browser $browser) {
- $browser->type('#password', 'aaaaaa')
- ->type('#password_confirmation', '')
- ->click('button[type=submit]')
- ->waitFor('#password + .invalid-feedback')
- ->assertSeeIn('#password + .invalid-feedback', 'The password confirmation does not match.')
- ->assertFocused('#password')
- ->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- });
+ // TODO: Test password change
- // TODO: Test password change
+ // Test form error handling (aliases)
+ $browser->vueClear('#password')
+ ->vueClear('#password_confirmation')
+ ->with(new ListInput('#aliases'), function (Browser $browser) {
+ $browser->addListEntry('invalid address');
+ })
+ ->click('button[type=submit]')
+ ->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- // Test form error handling (aliases)
- $browser->with('@form', function (Browser $browser) {
- // TODO: For some reason, clearing the input value
- // with ->type('#password', '') does not work, maybe some dusk/vue intricacy
- // For now we just use the default password
- $browser->type('#password', 'simple123')
- ->type('#password_confirmation', 'simple123')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
- $browser->addListEntry('invalid address');
- })
- ->click('button[type=submit]')
- ->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- })
- ->with('@form', function (Browser $browser) {
- $browser->with(new ListInput('#aliases'), function (Browser $browser) {
- $browser->assertFormError(2, 'The specified alias is invalid.', false);
- });
- });
+ $browser->with(new ListInput('#aliases'), function (Browser $browser) {
+ $browser->assertFormError(2, 'The specified alias is invalid.', false);
+ });
- // Test adding aliases
- $browser->with('@form', function (Browser $browser) {
- $browser->with(new ListInput('#aliases'), function (Browser $browser) {
- $browser->removeListEntry(2)
- ->addListEntry('john.test@kolab.org');
+ // Test adding aliases
+ $browser->with(new ListInput('#aliases'), function (Browser $browser) {
+ $browser->removeListEntry(2)
+ ->addListEntry('john.test@kolab.org');
+ })
+ ->click('button[type=submit]')
+ ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
})
- ->click('button[type=submit]')
- ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
- });
+ ->on(new UserList())
+ ->click('@table tr:nth-child(3) a')
+ ->on(new UserInfo());
$john = User::where('email', 'john@kolab.org')->first();
$alias = UserAlias::where('user_id', $john->id)->where('alias', 'john.test@kolab.org')->first();
@@ -273,7 +270,10 @@
->assertMissing('@skus table + .hint')
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
- });
+ })
+ ->on(new UserList())
+ ->click('@table tr:nth-child(3) a')
+ ->on(new UserInfo());
$expected = ['activesync', 'groupware', 'mailbox', 'storage', 'storage', 'storage'];
$this->assertUserEntitlements($john, $expected);
@@ -400,7 +400,6 @@
})
->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.')
// check redirection to users list
- ->waitForLocation('/users')
->on(new UserList())
->whenAvailable('@table', function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 5)

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 4:34 AM (4 h, 30 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822587
Default Alt Text
D1498.1775190892.diff (11 KB)

Event Timeline