1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-18 17:23:37 +00:00

PM-24242 Add IDs to AtRisk Notification for automation (#15865)

* PM-24242

* fix ts issue in storybook
This commit is contained in:
Daniel Riera
2025-08-06 09:49:23 -04:00
committed by GitHub
parent 8980016d2d
commit 55464a0fc9
5 changed files with 15 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ import { Spinner } from "../icons";
export type ActionButtonProps = { export type ActionButtonProps = {
buttonText: string | TemplateResult; buttonText: string | TemplateResult;
dataTestId?: string;
disabled?: boolean; disabled?: boolean;
isLoading?: boolean; isLoading?: boolean;
theme: Theme; theme: Theme;
@@ -17,6 +18,7 @@ export type ActionButtonProps = {
export function ActionButton({ export function ActionButton({
buttonText, buttonText,
dataTestId,
disabled = false, disabled = false,
isLoading = false, isLoading = false,
theme, theme,
@@ -32,6 +34,7 @@ export function ActionButton({
return html` return html`
<button <button
class=${actionButtonStyles({ disabled, fullWidth, isLoading, theme })} class=${actionButtonStyles({ disabled, fullWidth, isLoading, theme })}
data-testid="${dataTestId}"
title=${buttonText} title=${buttonText}
type="button" type="button"
@click=${handleButtonClick} @click=${handleButtonClick}

View File

@@ -2,6 +2,8 @@ import { Meta, StoryObj } from "@storybook/web-components";
import { ThemeTypes } from "@bitwarden/common/platform/enums"; import { ThemeTypes } from "@bitwarden/common/platform/enums";
import { NotificationTypes } from "../../../../../notification/abstractions/notification-bar";
import { getNotificationTestId } from "../../../../../notification/bar";
import { import {
AtRiskNotification, AtRiskNotification,
AtRiskNotificationProps, AtRiskNotificationProps,
@@ -30,8 +32,10 @@ export default {
}, },
} as Meta<AtRiskNotificationProps>; } as Meta<AtRiskNotificationProps>;
const Template = (args: AtRiskNotificationProps) => AtRiskNotification({ ...args }); const Template = (args: AtRiskNotificationProps) => {
const notificationTestId = getNotificationTestId(NotificationTypes.AtRiskPassword);
return AtRiskNotification({ ...args, notificationTestId });
};
export const Default: StoryObj<AtRiskNotificationProps> = { export const Default: StoryObj<AtRiskNotificationProps> = {
render: Template, render: Template,
}; };

View File

@@ -18,11 +18,13 @@ export type AtRiskNotificationProps = NotificationBarIframeInitData & {
handleCloseNotification: (e: Event) => void; handleCloseNotification: (e: Event) => void;
} & { } & {
i18n: I18n; i18n: I18n;
notificationTestId: string;
}; };
export function AtRiskNotification({ export function AtRiskNotification({
handleCloseNotification, handleCloseNotification,
i18n, i18n,
notificationTestId,
theme = ThemeTypes.Light, theme = ThemeTypes.Light,
params, params,
}: AtRiskNotificationProps) { }: AtRiskNotificationProps) {
@@ -33,7 +35,7 @@ export function AtRiskNotification({
); );
return html` return html`
<div class=${atRiskNotificationContainerStyles(theme)}> <div data-testid="${notificationTestId}" class=${atRiskNotificationContainerStyles(theme)}>
${NotificationHeader({ ${NotificationHeader({
handleCloseNotification, handleCloseNotification,
i18n, i18n,

View File

@@ -26,6 +26,7 @@ export function AtRiskNotificationFooter({
open(passwordChangeUri, "_blank"); open(passwordChangeUri, "_blank");
}, },
buttonText: AdditionalTasksButtonContent({ buttonText: i18n.changePassword, theme }), buttonText: AdditionalTasksButtonContent({ buttonText: i18n.changePassword, theme }),
dataTestId: "change-password-button",
theme, theme,
fullWidth: false, fullWidth: false,
})} })}

View File

@@ -200,7 +200,7 @@ export function getNotificationTestId(
[NotificationTypes.Unlock]: "unlock-notification-bar", [NotificationTypes.Unlock]: "unlock-notification-bar",
[NotificationTypes.Add]: "save-notification-bar", [NotificationTypes.Add]: "save-notification-bar",
[NotificationTypes.Change]: "update-notification-bar", [NotificationTypes.Change]: "update-notification-bar",
[NotificationTypes.AtRiskPassword]: "at-risk-password-notification-bar", [NotificationTypes.AtRiskPassword]: "at-risk-notification-bar",
}[notificationType]; }[notificationType];
} }
@@ -287,6 +287,7 @@ async function initNotificationBar(message: NotificationBarWindowMessage) {
type: notificationBarIframeInitData.type as NotificationType, type: notificationBarIframeInitData.type as NotificationType,
theme: resolvedTheme, theme: resolvedTheme,
i18n, i18n,
notificationTestId,
params: initData.params, params: initData.params,
handleCloseNotification, handleCloseNotification,
}), }),