Browse Source

Maintenance: Improve current frontend login tests for the new mocking.

Dominik Klein 1 year ago
parent
commit
24f650b0b9

+ 3 - 2
app/frontend/apps/desktop/components/layout/LayoutPublicPage.vue

@@ -44,12 +44,13 @@ const hoverPoweredByLogo = ref(false)
         <slot />
       </main>
 
-      <div
+      <section
         v-if="$slots.bottomContent"
+        :aria-label="$t('Additional information and links')"
         class="flex flex-col space-y-3 w-full items-center justify-center py-3 align-middle text-xs"
       >
         <slot name="bottomContent" />
-      </div>
+      </section>
       <footer
         class="flex w-full items-center justify-center py-3 align-middle text-xs"
       >

+ 20 - 0
app/frontend/apps/desktop/pages/login/__tests__/login-a11y.spec.ts

@@ -0,0 +1,20 @@
+// Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
+
+import { axe } from 'vitest-axe'
+import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
+import { visitView } from '#tests/support/components/visitView.ts'
+import '#tests/graphql/builders/mocks.ts'
+
+describe('testing login a11y', () => {
+  beforeEach(() => {
+    mockApplicationConfig({
+      product_name: 'Zammad Test System',
+    })
+  })
+
+  it('has no accessibility violations', async () => {
+    const view = await visitView('/login')
+    const results = await axe(view.html())
+    expect(results).toHaveNoViolations()
+  })
+})

+ 1 - 0
app/frontend/apps/desktop/pages/login/__tests__/login-maintenance.spec.ts

@@ -18,6 +18,7 @@ import {
   mockPublicLinks,
   mockPublicLinksSubscription,
 } from '#shared/entities/public-links/__tests__/mocks/mockPublicLinks.ts'
+// TODO: import '#tests/graphql/builders/mocks.ts'
 
 vi.mock('#shared/server/apollo/client.ts', () => {
   return {

+ 20 - 28
app/frontend/apps/desktop/pages/login/__tests__/login-password-login.spec.ts

@@ -1,18 +1,10 @@
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
-import {
-  mockPublicLinks,
-  mockPublicLinksSubscription,
-} from '#shared/entities/public-links/__tests__/mocks/mockPublicLinks.ts'
 import { visitView } from '#tests/support/components/visitView.ts'
 import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
+import '#tests/graphql/builders/mocks.ts'
 
 describe('password login', () => {
-  beforeEach(() => {
-    mockPublicLinks([])
-    mockPublicLinksSubscription()
-  })
-
   it('shows if the setting is turned on', async () => {
     const applicationConfig = {
       user_show_password_login: true,
@@ -41,29 +33,29 @@ describe('password login', () => {
     expect(view.getByText('Sign in')).toBeInTheDocument()
   })
 
-  // it('hides if the setting is turned off and at least one auth provider is configured', async () => {
-  //   const applicationConfig = {
-  //     user_show_password_login: false,
-  //     auth_sso: true,
-  //   }
+  it('hides if the setting is turned off and at least one auth provider is configured', async () => {
+    const applicationConfig = {
+      user_show_password_login: false,
+      auth_sso: true,
+    }
 
-  //   mockApplicationConfig(applicationConfig)
+    mockApplicationConfig(applicationConfig)
 
-  //   const view = await visitView('/login')
+    const view = await visitView('/login')
 
-  //   expect(view.queryByText('Username / Email')).not.toBeInTheDocument()
-  //   expect(view.queryByText('Password')).not.toBeInTheDocument()
-  //   expect(view.queryByText('Sign in')).not.toBeInTheDocument()
+    expect(view.queryByText('Username / Email')).not.toBeInTheDocument()
+    expect(view.queryByText('Password')).not.toBeInTheDocument()
+    expect(view.queryByText('Sign in')).not.toBeInTheDocument()
 
-  //   expect(
-  //     view.getByText(
-  //       'If you have problems with the third-party login you can request a one-time password login as an admin.',
-  //     ),
-  //   ).toBeInTheDocument()
+    expect(
+      view.getByText(
+        'If you have problems with the third-party login you can request a one-time password login as an admin.',
+      ),
+    ).toBeInTheDocument()
 
-  //   const link = view.getByText('Request the password login here.')
+    const link = view.getByText('Request the password login here.')
 
-  //   expect(link).toHaveAttribute('href', '/#admin_password_auth')
-  //   expect(link).not.toHaveAttribute('target', '_blank')
-  // })
+    expect(link).toHaveAttribute('href', '/desktop/admin-password-auth')
+    expect(link).not.toHaveAttribute('target', '_blank')
+  })
 })

+ 1 - 6
app/frontend/apps/desktop/pages/login/__tests__/login-product-branding.spec.ts

@@ -1,11 +1,8 @@
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
-import {
-  mockPublicLinks,
-  mockPublicLinksSubscription,
-} from '#shared/entities/public-links/__tests__/mocks/mockPublicLinks.ts'
 import { visitView } from '#tests/support/components/visitView.ts'
 import { mockApplicationConfig } from '#tests/support/mock-applicationConfig.ts'
+import '#tests/graphql/builders/mocks.ts'
 
 const applicationConfig = {
   product_name: 'Zammad Example App',
@@ -15,8 +12,6 @@ const applicationConfig = {
 describe('testing login product branding', () => {
   beforeEach(() => {
     mockApplicationConfig(applicationConfig)
-    mockPublicLinks([])
-    mockPublicLinksSubscription()
   })
 
   it('check that expected product name is present', async () => {

+ 1 - 1
app/frontend/apps/desktop/pages/login/views/AdminPasswordAuth.vue

@@ -74,7 +74,7 @@ const retry = () => {
 </script>
 
 <template>
-  <LayoutPublicPage box-size="small" :show-logo="false" :title="pageTitle">
+  <LayoutPublicPage box-size="medium" :show-logo="false" :title="pageTitle">
     <CommonAlert v-if="adminPasswordAuthError" variant="danger">{{
       $t(adminPasswordAuthError)
     }}</CommonAlert>

+ 4 - 0
i18n/zammad.pot

@@ -953,6 +953,10 @@ msgstr ""
 msgid "Additional information"
 msgstr ""
 
+#: app/frontend/apps/desktop/components/layout/LayoutPublicPage.vue
+msgid "Additional information and links"
+msgstr ""
+
 #: db/seeds/object_manager_attributes.rb
 msgid "Address"
 msgstr ""