-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,11 @@ | |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { describe, expect, it } from "@jest/globals"; | ||
import { getNextGuidedStep } from "./getRelevantGuidedSteps"; | ||
import { | ||
getNextGuidedStep, | ||
hasCompletedStep, | ||
isEligibleForStep, | ||
} from "./getRelevantGuidedSteps"; | ||
import { | ||
createRandomBreach, | ||
createRandomScanResult, | ||
|
@@ -562,7 +566,7 @@ describe("getNextGuidedStep", () => { | |
).toBe("Done"); | ||
}); | ||
|
||
it("links to the removal under maintenance step if a user has scan resutls with a data broker that has a removal under maintenance status", () => { | ||
it("links to the removal under maintenance step if a user has scan results with a data broker that has a removal under maintenance status", () => { | ||
expect( | ||
getNextGuidedStep( | ||
{ | ||
|
@@ -596,6 +600,209 @@ describe("getNextGuidedStep", () => { | |
}); | ||
}); | ||
|
||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
it("does not link to the removal under maintenance step if the feature flag is off", () => { | ||
expect( | ||
getNextGuidedStep({ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
status: "optout_in_progress", | ||
manually_resolved: false, | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { | ||
email: "[email protected]", | ||
}, | ||
}).id, | ||
).toBe("Done"); | ||
}); | ||
|
||
it("returns true when all data brokers that are removal under maintenance are resolved", () => { | ||
expect( | ||
hasCompletedStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: true, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
["EnableRemovalUnderMaintenanceStep"], | ||
), | ||
).toBe(true); | ||
}); | ||
|
||
it("returns false when data brokers that are removal under maintenance are not resolved", () => { | ||
expect( | ||
hasCompletedStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: false, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
["EnableRemovalUnderMaintenanceStep"], | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
it("returns false when data brokers that are removal under maintenance are resolved, but the flag is off", () => { | ||
expect( | ||
hasCompletedStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: true, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
[], | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
it("is not eligible for step if the data brokers under maintenance is already removed", () => { | ||
expect( | ||
isEligibleForStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: false, | ||
status: "removed", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
["EnableRemovalUnderMaintenanceStep"], | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
it("is not eligible for step if the data brokers under maintenance is already manually resolved", () => { | ||
expect( | ||
isEligibleForStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: true, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag | ||
["EnableRemovalUnderMaintenanceStep"], | ||
), | ||
).toBe(false); | ||
}); | ||
|
||
it("is eligible for step if there are valid data brokers under maintenance", () => { | ||
expect( | ||
isEligibleForStep( | ||
{ | ||
countryCode: "us", | ||
latestScanData: { | ||
scan: { | ||
...completedScan.scan!, | ||
onerep_scan_status: "finished", | ||
}, | ||
results: [ | ||
createRandomScanResult({ | ||
manually_resolved: true, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
createRandomScanResult({ | ||
manually_resolved: false, | ||
status: "removed", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
createRandomScanResult({ | ||
manually_resolved: false, | ||
status: "optout_in_progress", | ||
broker_status: "removal_under_maintenance", | ||
}), | ||
], | ||
}, | ||
subscriberBreaches: [], | ||
user: { email: "[email protected]" }, | ||
}, | ||
"DataBrokerManualRemoval", | ||
["EnableRemovalUnderMaintenanceStep"], | ||
), | ||
).toBe(true); | ||
}); | ||
|
||
it("links to the Credit Card step if the user's credit card has been breached", () => { | ||
expect( | ||
getNextGuidedStep({ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters