diff --git a/src/components/NcPasswordField/NcPasswordField.vue b/src/components/NcPasswordField/NcPasswordField.vue index a933a56bfd..479b860f19 100644 --- a/src/components/NcPasswordField/NcPasswordField.vue +++ b/src/components/NcPasswordField/NcPasswordField.vue @@ -93,40 +93,17 @@ export default { ``` - - + + diff --git a/tests/component/components/Nc*Field/NcPasswordField.visual.spec.ts b/tests/component/components/Nc*Field/NcPasswordField.visual.spec.ts new file mode 100644 index 0000000000..2c4619ff0c --- /dev/null +++ b/tests/component/components/Nc*Field/NcPasswordField.visual.spec.ts @@ -0,0 +1,78 @@ +/*! + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect, test } from '@playwright/experimental-ct-vue' +import NcPasswordField from './NcPassword.story.vue' + +test.skip(({ browserName }) => browserName !== 'chromium') + +test.describe('NcPasswordField', () => { + test('password is hidden', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField) + + await expect(page.getByRole('textbox', { name: 'Password' })).toBeVisible() + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) + + test('password can be shown', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField, { + props: { + visible: true, + }, + }) + + await expect(page.getByRole('textbox', { name: 'Password' })).toBeVisible() + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) + + test('password can be shown by trailing button click', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField) + + const el = page.getByRole('textbox', { name: 'Password' }) + await expect(el).toBeVisible() + await expect(el).toHaveAttribute('type', 'password') + + await page.getByRole('button', { name: 'Show password' }).click() + await expect(el).toHaveAttribute('type', 'text') + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) + + test('password as-text is hidden', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField, { + props: { + asText: true, + }, + }) + + await expect(page.getByRole('textbox', { name: 'Password' })).toBeVisible() + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) + + test('password as-text can be shown', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField, { + props: { + asText: true, + visible: true, + }, + }) + + await expect(page.getByRole('textbox', { name: 'Password' })).toBeVisible() + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) + + test('password as-text can be shown by trailing button click', { tag: '@visual' }, async ({ mount, page }) => { + await mount(NcPasswordField, { + props: { + asText: true, + }, + }) + + const el = page.getByRole('textbox', { name: 'Password' }) + await expect(el).toBeVisible() + + await page.getByRole('button', { name: 'Show password' }).click() + await expect(page.locator('.story-wrapper')).toHaveScreenshot() + }) +}) diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-1-chromium-linux.png new file mode 100644 index 0000000000..4a0f7c4461 Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-1-chromium-linux.png differ diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-by-trailing-button-click-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-by-trailing-button-click-1-chromium-linux.png new file mode 100644 index 0000000000..53449466cb Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-can-be-shown-by-trailing-button-click-1-chromium-linux.png differ diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-is-hidden-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-is-hidden-1-chromium-linux.png new file mode 100644 index 0000000000..ae8f8805c4 Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-as-text-is-hidden-1-chromium-linux.png differ diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-1-chromium-linux.png new file mode 100644 index 0000000000..4a0f7c4461 Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-1-chromium-linux.png differ diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-by-trailing-button-click-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-by-trailing-button-click-1-chromium-linux.png new file mode 100644 index 0000000000..53449466cb Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-can-be-shown-by-trailing-button-click-1-chromium-linux.png differ diff --git a/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-is-hidden-1-chromium-linux.png b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-is-hidden-1-chromium-linux.png new file mode 100644 index 0000000000..ae8f8805c4 Binary files /dev/null and b/tests/component/snapshots/components/Nc*Field/NcPasswordField.visual.spec.ts-snapshots/NcPasswordField-password-is-hidden-1-chromium-linux.png differ