3
0

Add cypress ids to auth/templates

This commit is contained in:
Katrin Yordanova
2022-05-18 18:30:15 +03:00
parent f30c2de43b
commit 0bf47a2fc4
17 changed files with 223 additions and 54 deletions

View File

@@ -22,6 +22,7 @@
</time>
</div>
<button
data-test-id="button-revoke-access"
type="submit"
name="revoke"
value="{{ .ID }}"
@@ -30,8 +31,10 @@
{{ tr "authorized-clients.template.list.buttons.revoke" }}
</button>
</div>
{{ else }}
<div class="text-center m-3 mb-3">
<div
data-test-id="text-empty-list"
class="text-center m-3 mb-3"
>
<i>{{ tr "authorized-clients.template.list.empty" }}</i>
</div>
{{ end }}

View File

@@ -8,7 +8,11 @@
>
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger font-weight-bold mb-3" role="alert">
<div
data-test-id="error"
class="text-danger font-weight-bold mb-3"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -17,42 +21,54 @@
{{ tr "change-password.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
name="email"
readonly
placeholder="{{ tr "change-password.template.form.email.placeholder" }}"
value="{{ .user.Email }}"
aria-label="{{ tr "change-password.template.form.email.label" }}">
aria-label="{{ tr "change-password.template.form.email.label" }}"
>
</div>
<div class="mb-3">
<label>
{{ tr "change-password.template.form.old-password.label" }}
</label>
<input
data-test-id="input-old-password"
type="password"
required
class="form-control"
name="oldPassword"
autocomplete="current-password"
placeholder="{{ tr "change-password.template.form.old-password.placeholder" }}"
aria-label="{{ tr "change-password.template.form.old-password.label" }}">
aria-label="{{ tr "change-password.template.form.old-password.label" }}"
>
</div>
<div class="mb-3">
<label>
{{ tr "change-password.template.form.new-password.label" }}
</label>
<input
data-test-id="input-new-password"
type="password"
required
class="form-control"
name="newPassword"
autocomplete="new-password"
placeholder="{{ tr "change-password.template.form.new-password.placeholder" }}"
aria-label="{{ tr "change-password.template.form.new-password.label" }}">
aria-label="{{ tr "change-password.template.form.new-password.label" }}"
>
</div>
<div class="text-right">
<button class="btn btn-primary btn-block btn-lg" type="submit">{{ tr "change-password.template.form.button.change-password" }}</button>
<button
data-test-id="button-change-password"
class="btn btn-primary btn-block btn-lg"
type="submit"
>
{{ tr "change-password.template.form.button.change-password" }}
</button>
</div>
</form>
</div>

View File

@@ -8,7 +8,11 @@
>
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger font-weight-bold mb-3" role="alert">
<div
data-test-id="error"
class="text-danger font-weight-bold mb-3"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -17,28 +21,38 @@
{{ tr "create-password.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
name="email"
readonly
value="{{ .user.Email }}"
aria-label="{{ tr "create-password.template.form.email.label" }}">
aria-label="{{ tr "create-password.template.form.email.label" }}"
>
</div>
<div class="mb-3">
<label>
{{ tr "create-password.template.form.password.label" }}
</label>
<input
data-test-id="input-password"
type="password"
required
class="form-control"
name="password"
autocomplete="password"
placeholder="{{ tr "create-password.template.form.password.placeholder" }}"
aria-label="{{ tr "create-password.template.form.password.label" }}">
aria-label="{{ tr "create-password.template.form.password.label" }}"
>
</div>
<div class="text-right">
<button class="btn btn-primary btn-block btn-lg" type="submit">{{ tr "create-password.template.form.button.create-password" }}</button>
<button
data-test-id="button-create-password"
class="btn btn-primary btn-block btn-lg"
type="submit"
>
{{ tr "create-password.template.form.button.create-password" }}
</button>
</div>
</form>
</div>

View File

@@ -1,7 +1,7 @@
</main>
{{ template "inc_toasts.html.tpl" .alerts }}
<div class="footer col text-center py-4 text-white">
{{ tr "inc_footer.code-link" }}<a href="https://github.com/cortezaproject/" target="_blank" class="text-white ml-2">GitHub</a>
{{ tr "inc_footer.code-link" }}<a data-test-id="link-github" href="https://github.com/cortezaproject/" target="_blank" class="text-white ml-2">GitHub</a>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>

View File

@@ -19,9 +19,9 @@
<div class="position-absolute user text-white m-2">
<a class="font-weight-bold text-white" href="{{ links.Base }}"><i class="bi bi-grid-3x2-gap-fill text-white mr-1 align-middle" style="font-size: 1.4rem;"></i></a>
{{ tr "inc_header.logged-in-as" }}
<a class="font-weight-bold text-white" href="{{ links.Profile }}">{{ coalesce .user.Name .user.Handle .user.Email }}</a>
<a data-test-id="link-redirect-to-profile" class="font-weight-bold text-white" href="{{ links.Profile }}">{{ coalesce .user.Name .user.Handle .user.Email }}</a>
|
<a class="font-weight-bold text-white" href="{{ links.Logout }}">{{ tr "inc_header.logout" }}</a>
<a data-test-id="link-logout" class="font-weight-bold text-white" href="{{ links.Logout }}">{{ tr "inc_header.logout" }}</a>
</div>
{{ end }}
<main class="auth mt-sm-5 pt-md-5">

View File

@@ -1,16 +1,24 @@
<div class="header card-header border-0 p-0">
<div class="text-center w-100 my-4">
<a href="{{ links.Profile }}">
<img class="logo" alt="Company logo" src="{{ links.Assets }}/logo.png">
<img
data-test-id="img-corteza-logo"
class="logo"
alt="Company logo"
src="{{ links.Assets }}/logo.png"
>
</a>
</div>
{{ $activeNav := default "" .activeNav }}
{{ if not .hideNav }}
{{ if and .user .client }}
<div class="py-1 px-3">
<a href="{{ links.OAuth2AuthorizeClient }}" class="text-danger">
<a
data-test-id="link-finalize-authorization"
class="text-danger"
href="{{ links.OAuth2AuthorizeClient }}"
>
{{ tr "inc_nav.template.authorize-client" }} {{ .client.Name }}
<i class="bi bi-chevron-double-right"></i>
</a>
@@ -18,16 +26,40 @@
{{ else if .user }}
<ul class="nav ml-1 d-flex justify-content-around">
<li class="nav-item {{ if eq $activeNav "profile" }}active{{ end }}">
<a class="nav-link" href="{{ links.Profile }}">{{ tr "inc_nav.template.class.your-profile" }}</a>
<a
data-test-id="link-tab-profile"
class="nav-link"
href="{{ links.Profile }}"
>
{{ tr "inc_nav.template.class.your-profile" }}
</a>
</li>
<li class="nav-item {{ if eq $activeNav "security" }}active{{ end }}">
<a class="nav-link" href="{{ links.Security }}">{{ tr "inc_nav.template.class.security" }}</a>
<a
data-test-id="link-tab-security"
class="nav-link"
href="{{ links.Security }}"
>
{{ tr "inc_nav.template.class.security" }}
</a>
</li>
<li class="nav-item {{ if eq $activeNav "sessions" }}active{{ end }}">
<a class="nav-link" href="{{ links.Sessions }}">{{ tr "inc_nav.template.class.login-session" }}</a>
<a
data-test-id="link-tab-login-session"
class="nav-link"
href="{{ links.Sessions }}"
>
{{ tr "inc_nav.template.class.login-session" }}
</a>
</li>
<li class="nav-item {{ if eq $activeNav "clients" }}active{{ end }}">
<a class="nav-link" href="{{ links.AuthorizedClients }}">{{ tr "inc_nav.template.class.authorized-clients" }}</a>
<a
data-test-id="link-tab-authorized-clients"
class="nav-link"
href="{{ links.AuthorizedClients }}"
>
{{ tr "inc_nav.template.class.authorized-clients" }}
</a>
</li>
</ul>
{{ end }}

View File

@@ -9,7 +9,11 @@
>
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger mb-4 font-weight-bold" role="alert">
<div
data-test-id="error"
class="text-danger mb-4 font-weight-bold"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -18,9 +22,9 @@
{{ tr "login.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
data-test-id="input-email"
name="email"
required
placeholder="{{ tr "login.template.form.email.placeholder" }}"
@@ -34,10 +38,10 @@
{{ tr "login.template.form.password.label" }}
</label>
<input
data-test-id="input-password"
type="password"
required
class="form-control"
data-test-id="input-password"
name="password"
placeholder="{{ tr "login.template.form.password.placeholder" }}"
autocomplete="current-password"
@@ -47,8 +51,8 @@
<div class="col text-right">
{{ if .enableRememberMe }}
<button
class="btn btn-primary btn-block btn-lg"
data-test-id="button-login-and-remember"
class="btn btn-primary btn-block btn-lg"
name="keep-session"
value="true"
type="submit"
@@ -57,6 +61,7 @@
</button>
{{ end }}
<button
data-test-id="button-login"
class="btn btn-light btn-block"
type="submit"
>
@@ -68,8 +73,8 @@
<div class="row">
<div class="col text-right">
<button
data-test-id="button-continue"
class="btn btn-primary btn-block btn-lg"
data-test-id="button-login"
name="keep-session"
value="true"
type="submit"
@@ -83,12 +88,22 @@
<div class="row text-center px-3 pb-3">
{{ if .settings.PasswordResetEnabled }}
<div class="col cols-6">
<a href="{{ links.RequestPasswordReset }}">{{ tr "login.template.links.request-password-reset" }}</a>
<a
data-test-id="link-request-password-reset"
href="{{ links.RequestPasswordReset }}"
>
{{ tr "login.template.links.request-password-reset" }}
</a>
</div>
{{ end }}
{{ if .settings.SignupEnabled }}
<div class="col cols-6">
<a href="{{ links.Signup }}">{{ tr "login.template.links.signup" }}</a>
<a
data-test-id="link-signup"
href="{{ links.Signup }}"
>
{{ tr "login.template.links.signup" }}
</a>
</div>
{{ end }}
</div>

View File

@@ -2,7 +2,11 @@
<div class="card-body">
<form>
{{ if .form.error }}
<div class="text-danger font-weight-bold" role="alert">
<div
data-test-id="error"
class="text-danger font-weight-bold"
role="alert"
>
{{ .form.error }}
</div>
{{ else }}

View File

@@ -3,13 +3,19 @@
<h4 class="card-title p-3 border-bottom">{{ tr "mfa-totp.template.title" }}</h4>
{{ if .enforced }}
<p class="p-3 text-danger mb-0 font-weight-bold">
<p
data-test-id="p-enforced-TOTP"
class="p-3 text-danger mb-0 font-weight-bold"
>
{{ tr "mfa-totp.template.enforced" }}
</p>
{{ end }}
<div class="container p-3 m-0">
<div
data-test-id="div-configure-TOTP"
class="container p-3 m-0"
>
<div class="row">
<div class="col-12 col-sm-6 p-0 mb-3">
<pre class="h5 px-4">{{ .secret }}</pre>
@@ -45,6 +51,7 @@
</div>
<button
data-test-id="button-submit"
class="btn btn-primary btn-block btn-lg"
name="keep-session"
value="true"

View File

@@ -24,7 +24,8 @@
<p class="text-center">
<button
type="submit"
data-test-id="button-allow"
type="submit"
name="allow"
{{ if .disabled }}disabled{{ end }}
class="btn btn-{{ if .disabled }}secondary{{ else }}primary{{ end }} btn-lg m-2"
@@ -33,6 +34,7 @@
{{ tr "oauth2-authorize-client.template.form.buttons.allow" }}
</button>
<button
data-test-id="button-deny"
type="submit"
name="deny"
class="btn btn-danger btn-lg m-2"

View File

@@ -1,7 +1,11 @@
{{ template "inc_header.html.tpl" . }}
<div class="card-body p-0">
<h4 class="card-title p-3 border-bottom">{{ tr "password-reset-requested.template.title" }}</h4>
<div class="p-3" role="alert">
<div
data-test-id="div-reset-instructions"
class="p-3"
role="alert"
>
{{ tr "password-reset-requested.template.instructions" }}
</div>
<div class="text-center my-3">

View File

@@ -9,7 +9,11 @@
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger mb-4 font-weight-bold" role="alert">
<div
data-test-id="error"
class="text-danger mb-4 font-weight-bold"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -17,6 +21,7 @@
<div class="mb-3">
<label for="profileFormEmail">{{ tr "profile.template.form.email.label" }}</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
name="email"
@@ -25,7 +30,8 @@
autocomplete="username"
readonly
value="{{ .form.email }}"
aria-label="{{ tr "profile.template.form.email.label" }}">
aria-label="{{ tr "profile.template.form.email.label" }}"
>
<div>
{{ if .emailConfirmationRequired }}
<div class="form-text text-danger">
@@ -38,6 +44,7 @@
<div class="mb-3">
<label for="profileFormName">{{ tr "profile.template.form.name.label" }}</label>
<input
data-test-id="input-name"
type="text"
class="form-control"
name="name"
@@ -45,12 +52,14 @@
placeholder="{{ tr "profile.template.form.name.placeholder" }}"
value="{{ .form.name }}"
autocomplete="name"
aria-label="{{ tr "profile.template.form.name.label" }}">
aria-label="{{ tr "profile.template.form.name.label" }}"
>
</div>
<div class="mb-3">
<label for="profileFormHandle">{{ tr "profile.template.form.handle.label" }}</label>
<input
data-test-id="input-handle"
type="text"
class="form-control handle-mask"
name="handle"
@@ -58,13 +67,15 @@
placeholder="{{ tr "profile.template.form.handle.placeholder" }}"
value="{{ .form.handle }}"
autocomplete="handle"
aria-label="{{ tr "profile.template.form.handle.label" }}">
aria-label="{{ tr "profile.template.form.handle.label" }}"
>
</div>
<div class="mb-3">
<label for="profileFormPreferredLanguage">{{ tr "profile.template.form.preferred-language.label" }}</label>
<select
data-test-id="select-language"
class="form-control"
name="preferredLanguage"
id="profileFormPreferredLanguage"
@@ -85,6 +96,7 @@
<div>
<button
data-test-id="button-submit"
type="submit"
class="btn btn-primary btn-block btn-lg"
>

View File

@@ -8,7 +8,11 @@
>
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger font-weight-bold mb-4" role="alert">
<div
data-test-id="error"
class="text-danger font-weight-bold mb-4"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -17,6 +21,7 @@
{{ tr "request-password-reset.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
name="email"
@@ -24,10 +29,17 @@
placeholder="{{ tr "request-password-reset.template.form.email.placeholder" }}"
autocomplete="username"
value="{{ if .form }}{{ .form.email }}{{ end }}"
aria-label="{{ tr "request-password-reset.template.form.email.label" }}">
aria-label="{{ tr "request-password-reset.template.form.email.label" }}"
>
</div>
<div class="text-right">
<button class="btn btn-primary btn-block btn-lg" type="submit">{{ tr "request-password-reset.template.form.buttons.request" }}</button>
<button
data-test-id="button-password-reset"
class="btn btn-primary btn-block btn-lg"
type="submit"
>
{{ tr "request-password-reset.template.form.buttons.request" }}
</button>
</div>
</form>
<div class="text-center my-3">

View File

@@ -17,29 +17,39 @@
{{ tr "reset-password.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
name="email"
readonly
placeholder="{{ tr "reset-password.template.form.email.placeholder" }}"
value="{{ .user.Email }}"
aria-label="{{ tr "reset-password.template.form.emaillabel" }}">
aria-label="{{ tr "reset-password.template.form.emaillabel" }}"
>
</div>
<div class="mb-3">
<label>
{{ tr "reset-password.template.form.new-password.label" }}
</label>
<input
data-test-id="input-new-password"
type="password"
required
class="form-control"
name="password"
autocomplete="new-password"
placeholder="{{ tr "reset-password.template.form.new-password.placeholder" }}"
aria-label="{{ tr "reset-password.template.form.new-passwordlabel" }}">
aria-label="{{ tr "reset-password.template.form.new-passwordlabel" }}"
>
</div>
<div class="text-right">
<button class="btn btn-primary btn-block btn-lg" type="submit">{{ tr "reset-password.template.form.buttons.change-password" }}</button>
<button
data-test-id="button-change-password"
class="btn btn-primary btn-block btn-lg"
type="submit"
>
{{ tr "reset-password.template.form.buttons.change-password" }}
</button>
</div>
</form>
</div>

View File

@@ -9,7 +9,12 @@
{{ if .settings.LocalEnabled }}
<h5>{{ tr "security.template.password.title" }}</h5>
<a href="{{ links.ChangePassword }}">{{ tr "security.template.password.change-link" }}</a>
<a
data-test-id="link-change-password"
href="{{ links.ChangePassword }}"
>
{{ tr "security.template.password.change-link" }}
</a>
{{ end }}
<hr />
@@ -37,10 +42,24 @@
<div class="col-md-2 col-sm-12">
{{ if .totpEnforced }}
{{ if not .settings.MultiFactor.TOTP.Enforced }}
<button name="action" value="disableTOTP" class="btn btn-danger float-right">{{ tr "security.template.mfa.totp.disable" }}</button>
<button
data-test-id="button-disable-totp"
name="action"
value="disableTOTP"
class="btn btn-danger float-right"
>
{{ tr "security.template.mfa.totp.disable" }}
</button>
{{ end }}
{{ else }}
<button name="action" value="configureTOTP" class="btn btn-primary float-right">{{ tr "security.template.mfa.totp.configure" }}</button>
<button
data-test-id="button-configure-totp"
name="action"
value="configureTOTP"
class="btn btn-primary float-right"
>
{{ tr "security.template.mfa.totp.configure" }}
</button>
{{ end }}
</div>
</div>
@@ -66,10 +85,24 @@
<div class="col-md-2 col-sm-12">
{{ if .emailOtpEnforced }}
{{ if not .settings.MultiFactor.EmailOTP.Enforced }}
<button name="action" value="disableEmailOTP" class="btn btn-danger float-right">{{ tr "security.template.mfa.email.disable" }}</button>
<button
data-test-id="button-disable-email-otp"
name="action"
value="disableEmailOTP"
class="btn btn-danger float-right"
>
{{ tr "security.template.mfa.email.disable" }}
</button>
{{ end }}
{{ else }}
<button name="action" value="enableEmailOTP" class="btn btn-primary float-right">{{ tr "security.template.mfa.email.enable" }}</button>
<button
data-test-id="button-enable-email-otp"
name="action"
value="enableEmailOTP"
class="btn btn-primary float-right"
>
{{ tr "security.template.mfa.email.enable" }}
</button>
{{ end }}
</div>

View File

@@ -9,6 +9,7 @@
<h4 class="card-title d-inline">{{ tr "sessions.template.title" }}</h4>
{{- if and .sessions (gt (len .sessions) 1) }}
<button
data-test-id="button-logout-from-everywhere"
type="submit"
name="delete-all-but-current"
value="true"

View File

@@ -8,7 +8,11 @@
>
{{ .csrfField }}
{{ if .form.error }}
<div class="text-danger font-weight-bold mb-3" role="alert">
<div
data-test-id="error"
class="text-danger font-weight-bold mb-3"
role="alert"
>
{{ .form.error }}
</div>
{{ end }}
@@ -18,9 +22,9 @@
{{ tr "signup.template.form.email.label" }}
</label>
<input
data-test-id="input-email"
type="email"
class="form-control"
data-test-id="input-email"
name="email"
required
placeholder="{{ tr "signup.template.form.email.placeholder" }}"
@@ -33,9 +37,9 @@
{{ tr "signup.template.form.password.label" }}
</label>
<input
data-test-id="input-password"
type="password"
class="form-control"
data-test-id="input-password"
name="password"
required
placeholder="{{ tr "signup.template.form.password.placeholder" }}"
@@ -47,9 +51,9 @@
{{ tr "signup.template.form.name.label" }}
</label>
<input
data-test-id="input-name"
type="text"
class="form-control"
data-test-id="input-name"
name="name"
placeholder="{{ tr "signup.template.form.name.placeholder" }}"
value="{{ .form.name }}"
@@ -61,9 +65,9 @@
{{ tr "signup.template.form.nickname.label" }}
</label>
<input
data-test-id="input-handle"
type="text"
class="form-control handle-mask"
data-test-id="input-handle"
name="handle"
placeholder="{{ tr "signup.template.form.nickname.placeholder" }}"
value="{{ .form.handle }}"
@@ -73,8 +77,8 @@
<div>
<button
id="submit"
class="btn btn-primary btn-block btn-lg"
data-test-id="button-submit"
class="btn btn-primary btn-block btn-lg"
type="submit"
>{{ tr "signup.template.form.button.sign-up" }}</button>
</div>