Skip to content

Commit

Permalink
MNTOR-3880 - Manual removal rollback (#5419)
Browse files Browse the repository at this point in the history
* comment out changes

* Remove comment out test linter

* protect route

* append 3880 to commented out code
  • Loading branch information
codemist authored Dec 16, 2024
1 parent 2b7e760 commit 0d2ad5a
Show file tree
Hide file tree
Showing 11 changed files with 223 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export const View = (props: Props) => {
const exposureStatus = getExposureStatus(
exposure,
props.enabledFeatureFlags.includes("AdditionalRemovalStatuses"),
isDataBrokerUnderMaintenance(exposure),
// TODO: Waiting for criteria for data brokers under maintenance to be determined
// isDataBrokerUnderMaintenance(exposure),
);

return (
Expand Down Expand Up @@ -561,11 +562,12 @@ export const View = (props: Props) => {
);
};

export function isDataBrokerUnderMaintenance(
exposure: Exposure | OnerepScanResultDataBrokerRow,
): boolean {
return (
isScanResult(exposure) &&
exposure.broker_status === "removal_under_maintenance"
);
}
// TODO: Waiting for criteria for data brokers under maintenace to be determined
// export function isDataBrokerUnderMaintenance(
// exposure: Exposure | OnerepScanResultDataBrokerRow,
// ): boolean {
// return (
// isScanResult(exposure) &&
// exposure.broker_status === "removal_under_maintenance"
// );
// }
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,29 @@ import { getSubscriberBreaches } from "../../../../../../../../../functions/serv
import { getSubscriberEmails } from "../../../../../../../../../functions/server/getSubscriberEmails";
import { RemovalUnderMaintenanceView } from "./RemovalUnderMaintenanceView";
import { hasPremium } from "../../../../../../../../../functions/universal/user";
import { getEnabledFeatureFlags } from "../../../../../../../../../../db/tables/featureFlags";
import { AutoSignIn } from "../../../../../../../../../components/client/AutoSignIn";

export default async function RemovalUnderMaintenance() {
const session = await getServerSession();
const countryCode = getCountryCode(headers());
if (!session?.user?.subscriber?.id || !hasPremium(session.user)) {

if (!session) {
return <AutoSignIn />;
}

const enabledFeatureFlags = await getEnabledFeatureFlags({
email: session.user.email,
});

if (
!session?.user?.subscriber?.id ||
!hasPremium(session.user) ||
!enabledFeatureFlags.includes("EnableRemovalUnderMaintenanceStep")
) {
redirect("/user/dashboard");
}

const profileId = await getOnerepProfileId(session.user.subscriber.id);
const latestScan = await getScanResultsWithBroker(
profileId,
Expand Down
7 changes: 4 additions & 3 deletions src/app/components/client/FixNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ export const Steps = (props: {
{label} {count > 0 && `(${count})`}
</div>
);
const dataBrokerStepCompleted =
hasCompletedStepSection(props.data, "Scan") &&
hasCompletedStepSection(props.data, "DataBrokerManualRemoval");
const dataBrokerStepCompleted = hasCompletedStepSection(props.data, "Scan");
// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// && hasCompletedStepSection(props.data, "DataBrokerManualRemoval");

return (
<ul className={styles.steps}>
{isEligibleForStep(props.data, "Scan") && (
Expand Down
54 changes: 30 additions & 24 deletions src/app/components/client/exposure_card/ExposureCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ const ScanMockItemInProgress = createRandomScanResult({
status: "optout_in_progress",
manually_resolved: false,
});
const ScanMockItemRemovalUnderMaintenance = createRandomScanResult({
status: "optout_in_progress",
manually_resolved: false,
broker_status: "removal_under_maintenance",
});

const ScanMockItemRemovalUnderMaintenanceFixed = createRandomScanResult({
status: "optout_in_progress",
manually_resolved: true,
broker_status: "removal_under_maintenance",
});
// TODO: Waiting for criteria for data brokers under maintenace to be determined
// const ScanMockItemRemovalUnderMaintenance = createRandomScanResult({
// status: "optout_in_progress",
// manually_resolved: false,
// broker_status: "removal_under_maintenance",
// });

// TODO: Waiting for criteria for data brokers under maintenace to be determined
// const ScanMockItemRemovalUnderMaintenanceFixed = createRandomScanResult({
// status: "optout_in_progress",
// manually_resolved: true,
// broker_status: "removal_under_maintenance",
// });

const BreachMockItemRemoved = createRandomBreach({
isResolved: true,
dataClassesEffected: [
Expand Down Expand Up @@ -115,21 +119,23 @@ export const DataBreachActionNeeded: Story = {
},
};

export const DataBrokerRemovalUnderMaintenance: Story = {
args: {
exposureImg: FamilyTreeImage,
exposureData: ScanMockItemRemovalUnderMaintenance,
isPremiumUser: true,
},
};
// TODO: Waiting for criteria for data brokers under maintenace to be determined
// export const DataBrokerRemovalUnderMaintenance: Story = {
// args: {
// exposureImg: FamilyTreeImage,
// exposureData: ScanMockItemRemovalUnderMaintenance,
// isPremiumUser: true,
// },
// };

export const DataBrokerRemovalUnderMaintenanceFixed: Story = {
args: {
exposureImg: FamilyTreeImage,
exposureData: ScanMockItemRemovalUnderMaintenanceFixed,
isPremiumUser: true,
},
};
// TODO: Waiting for criteria for data brokers under maintenace to be determined
// export const DataBrokerRemovalUnderMaintenanceFixed: Story = {
// args: {
// exposureImg: FamilyTreeImage,
// exposureData: ScanMockItemRemovalUnderMaintenanceFixed,
// isPremiumUser: true,
// },
// };

export const DataBreachFixed: Story = {
args: {
Expand Down
91 changes: 49 additions & 42 deletions src/app/components/client/exposure_card/ExposureCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import Meta, {
DataBrokerActionNeeded,
DataBrokerInProgress,
DataBrokerManualRemoved,
DataBrokerRemovalUnderMaintenance,
DataBrokerRemovalUnderMaintenanceFixed,
DataBrokerRemoved,
DataBrokerRequestedRemoval,
// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// DataBrokerRemovalUnderMaintenance,
// DataBrokerRemovalUnderMaintenanceFixed,
} from "./ExposureCard.stories";

jest.mock("../../../hooks/useTelemetry");
Expand Down Expand Up @@ -75,35 +76,39 @@ describe("ScanResultCard", () => {
expect(innerDescription).toBeInTheDocument();
});

// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// Data broker removal under maintenance
it("shows the right description for a scan result card with removal under maintenance status", () => {
const ComposedProgressCard = composeStory(
DataBrokerRemovalUnderMaintenance,
Meta,
);
render(<ComposedProgressCard />);
const innerDescription = screen.getByText(
"We’ve asked this data broker to remove your profile but they haven’t done it.",
{ exact: false },
);

expect(innerDescription).toBeInTheDocument();
});

// eslint-disable-next-line jest/no-commented-out-tests
// it("shows the right description for a scan result card with removal under maintenance status", () => {
// const ComposedProgressCard = composeStory(
// DataBrokerRemovalUnderMaintenance,
// Meta,
// );
// render(<ComposedProgressCard />);
// const innerDescription = screen.getByText(
// "We’ve asked this data broker to remove your profile but they haven’t done it.",
// { exact: false },
// );

// expect(innerDescription).toBeInTheDocument();
// });

// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// Data broker removal under maintenance resolved
it("shows the right description for a scan result card with removal under maintenance status that's been resolved", () => {
const ComposedProgressCard = composeStory(
DataBrokerRemovalUnderMaintenanceFixed,
Meta,
);
render(<ComposedProgressCard />);
const innerDescription = screen.getByText(
"You could be added back in the future, so ⁨Monitor⁩ will continue to scan data broker sites for new exposures.",
{ exact: false },
);

expect(innerDescription).toBeInTheDocument();
});
// eslint-disable-next-line jest/no-commented-out-tests
// it("shows the right description for a scan result card with removal under maintenance status that's been resolved", () => {
// const ComposedProgressCard = composeStory(
// DataBrokerRemovalUnderMaintenanceFixed,
// Meta,
// );
// render(<ComposedProgressCard />);
// const innerDescription = screen.getByText(
// "You could be added back in the future, so ⁨Monitor⁩ will continue to scan data broker sites for new exposures.",
// { exact: false },
// );

// expect(innerDescription).toBeInTheDocument();
// });

// Data broker removal in progress
it("shows the right description for a scan result card where removal is in progress", () => {
Expand All @@ -117,20 +122,22 @@ describe("ScanResultCard", () => {
expect(innerDescription).toBeInTheDocument();
});

// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// Data broker removal under maintenance
it("shows the right description for a scan result card where removal is under maintenance", () => {
const ComposedProgressCard = composeStory(
DataBrokerRemovalUnderMaintenance,
Meta,
);
render(<ComposedProgressCard />);
const innerDescription = screen.getByText(
"We’ve asked this data broker to remove your profile but they haven’t done it.",
{ exact: false },
);

expect(innerDescription).toBeInTheDocument();
});
// eslint-disable-next-line jest/no-commented-out-tests
// it("shows the right description for a scan result card where removal is under maintenance", () => {
// const ComposedProgressCard = composeStory(
// DataBrokerRemovalUnderMaintenance,
// Meta,
// );
// render(<ComposedProgressCard />);
// const innerDescription = screen.getByText(
// "We’ve asked this data broker to remove your profile but they haven’t done it.",
// { exact: false },
// );

// expect(innerDescription).toBeInTheDocument();
// });

it("shows an additional note for “requested removal” status label", () => {
const ComposedProgressCard = composeStory(DataBrokerRequestedRemoval, Meta);
Expand Down
49 changes: 27 additions & 22 deletions src/app/components/client/exposure_card/ScanResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,25 @@ export const ScanResultCard = (props: ScanResultCardProps) => {
const dataBrokerDescription = () => {
// Data broker cards manually resolved do not change their status to "removed";
// instead, we track them using the "manually_resolved" property.
if (scanResult.broker_status === "removal_under_maintenance") {
if (scanResult.manually_resolved) {
return l10n.getFragment(
"exposure-card-description-info-for-sale-fixed-removal-under-maintenance-manually-fixed",
{ elems: { data_broker_profile: dataBrokerProfileLink } },
);
}
return l10n.getFragment(
"exposure-card-description-info-for-sale-manual-removal-needed",
{
elems: {
b: <b />,
},
},
);
}

// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// if (scanResult.broker_status === "removal_under_maintenance") {
// if (scanResult.manually_resolved) {
// return l10n.getFragment(
// "exposure-card-description-info-for-sale-fixed-removal-under-maintenance-manually-fixed",
// { elems: { data_broker_profile: dataBrokerProfileLink } },
// );
// }
// return l10n.getFragment(
// "exposure-card-description-info-for-sale-manual-removal-needed",
// {
// elems: {
// b: <b />,
// },
// },
// );
// }

if (scanResult.manually_resolved) {
return l10n.getFragment(
"exposure-card-description-info-for-sale-fixed-manually-fixed",
Expand Down Expand Up @@ -249,9 +252,10 @@ export const ScanResultCard = (props: ScanResultCardProps) => {
);
}

if (props.scanResult.broker_status === "removal_under_maintenance") {
return <span>{props.resolutionCta}</span>;
}
// TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// if (props.scanResult.broker_status === "removal_under_maintenance") {
// return <span>{props.resolutionCta}</span>;
// }

switch (props.scanResult.status) {
case "new":
Expand Down Expand Up @@ -323,9 +327,10 @@ export const ScanResultCard = (props: ScanResultCardProps) => {
</dt>
<dd>
<StatusPill
isRemovalUnderMaintenance={
scanResult.broker_status === "removal_under_maintenance"
}
// isRemovalUnderMaintenance={
// // TODO: MNTOR-3880 Waiting for criteria for data brokers under maintenace to be determined
// // scanResult.broker_status === "removal_under_maintenance"
// }
exposure={scanResult}
note={statusPillNote}
enabledFeatureFlags={props.enabledFeatureFlags}
Expand Down
Loading

0 comments on commit 0d2ad5a

Please sign in to comment.