Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 7d3adba

Browse files
committed
tests for raspberry-linked login failure
1 parent 8a51e16 commit 7d3adba

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ok":false,
3+
"why":"raspberry-linked"
4+
}

cypress/integration/authenticatiion/login_spec.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Login Page', () => {
4949
cy.get(page.emailFormatError).should('be.visible');
5050
});
5151

52-
it('should show an error when the login fails (on mock server this is only when the incorrect email is provided)', () => {
52+
it('should show an error when the login fails (on mock server this is only when [email protected] email is provided)', () => {
5353
cy.server();
5454
cy.route('POST', '/api/2.0/users/login', 'fx:loginFail').as('loginFail');
5555
cy.get(page.loginFailed).should('not.be.visible');
@@ -61,6 +61,18 @@ describe('Login Page', () => {
6161
cy.get(page.loginFailed).should('be.visible');
6262
});
6363

64+
it('should show an raspberry linked error when login fails because linked (on mock server this is only when [email protected] email is provided)', () => {
65+
cy.server();
66+
cy.route('POST', '/api/2.0/users/login', 'fx:loginRaspberryFail').as('loginRaspberryFail');
67+
cy.get(page.loginFailed).should('not.be.visible');
68+
cy.get(page.email).click();
69+
cy.get(page.email).type('[email protected]');
70+
cy.get(page.password).type('rightpassword');
71+
cy.get(page.login).click();
72+
cy.wait('@loginRaspberryFail');
73+
cy.get(page.loginFailed).should('be.visible');
74+
});
75+
6476
it('should show both requirement errors when a login is attempted if no email and no password is provided', () => {
6577
cy.get(page.emailFormatError).should('not.be.visible'); // TODO: Should be emailReqError?
6678
cy.get(page.passwordReqError).should('not.be.visible');

cypress/pages/login.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default {
1010
emailFormatError: '.cd-login__email-format-err',
1111
passwordReqError: '.cd-login__password-req-err',
1212
loginFailed: '.cd-login__login-failed',
13+
loginRaspberryFailed: '.cd-login__login-raspberry-failed',
1314
registerLink: '.cd-login__register a',
1415
forgotPasswordLink: '.cd-login__forgot-password a',
1516
};

src/users/cd-login.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</form>
2929
<p v-show="errors.has('invalid-password')" class="cd-login__login-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Invalid email or password') }) }}</p>
3030
<p v-show="errors.has('raspberry-linked')" class="cd-login__login-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Account linked to a My Raspberry Pi account.') }) }}<a href='/rpi/login'>{{$t('Click here to login through My Raspberry Pi')}}</a>{{$t('Remember to use the same email address!')}}</p>
31+
<p v-show="errors.has('raspberry-linked')" class="cd-login__login-raspberry-failed text-danger">{{ $t('There was a problem logging in: {msg}', {msg: $t('Account linked to a My Raspberry Pi account.') }) }}<a href='/rpi/login'>{{$t('Click here to login through My Raspberry Pi')}}</a>{{$t('Remember to use the same email address!')}}</p>
3132
<p class="cd-login__forgot-password"><a href="/reset">{{ $t('Forgot password?') }}</a></p>
3233
<p class="cd-login__register">{{ $t("Don't have an account?") }} <a :href="registerUrl">{{ $t('Register here') }}</a></p>
3334
</div>

0 commit comments

Comments
 (0)