Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/1815 removed unused audits amend #679

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ jobs:


# store videos so they are accessible via circleci UI. You must turn on video recording via cypress.config.ts first (video: true).
# - store_artifacts:
# path: ~/repo/cypress/videos
# destination: videos
- store_artifacts:
path: ~/repo/cypress/videos
destination: videos



Expand Down
17 changes: 14 additions & 3 deletions cypress/e2e/annual-review/banners.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,26 @@ Feature: Annual review banners
And A "lawyers" list exists for Eurasia
And eurasia lawyers are due to begin annual review

Scenario:
Scenario: Start banner
When the batch process has run
And I am viewing list item index for reference:"SMOKE"
Then I see the start banner

Scenario:
When a list item has been with the provider for 100 days with the reference "UNPUBLISH_DAY_TEST"

Scenario: 1 Service provider is going to be unpublished banner
And 1 days before unpublish
And the batch process has run
And the worker process has run
And the other eurasia lawyers have answered
And I am viewing list item index for reference:"SMOKE"
Then I see "1 service provider is going to be unpublished"


Scenario: 2 Service providers are going to be unpublished banner
When a list item has been with the provider for 100 days with the reference "UNPUBLISH_DAY_TEST"
And 1 days before unpublish
And the batch process has run
And the worker process has run
And the other eurasia lawyers have answered
And I am viewing list item index for reference:"SMOKE"
Then I see "2 service providers are going to be unpublished"
31 changes: 23 additions & 8 deletions cypress/e2e/annual-review/provider-emails.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
Feature: Check correct email is sent to provider that has had edits requested
Feature: Recurring reminder emails (weeklyUnpublish) are sent

Background: Setup list and provider
Given A "lawyers" list exists for Eurasia
Given A "lawyers" list exists for Eurasia
And eurasia lawyers are due to begin annual review in 0 days

Scenario Outline: Provider is sent a differnt unpublish email based on weeks since annual review
When eurasia lawyers have annual review in "-<daysSinceAnnualReview>" days
And the batch process has run
And the worker process has run
Then the reminder email for "<reminderWeek>" weeks is sent to eligible providers
Scenario Outline: Providers are sent weekly reminder emails
When eurasia lawyers have annual review in "-<days>" days
And the batch process has run
And the worker process has run
Then the reminder email for "<reminderWeek>" weeks is sent to eligible providers

Examples:
| daysSinceAnnualReview | reminderWeek |
| days | reminderWeek |
| 8 | 1 |
| 15 | 2 |
| 22 | 3 |
| 29 | 4 |
| 36 | 5 |


Scenario: Providers are not sent weekly reminder emails if one has been sent recently
When eurasia lawyers have annual review in "-8" days
And the batch process has run
And the worker process has run
And the reminder email for "1" weeks is sent to eligible providers
And the worker process has run
And the worker process has run
Then the weeklyReminder emails were not re-sent




18 changes: 11 additions & 7 deletions cypress/e2e/annual-review/reminder-day-before-unpublish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@ Feature: Check that a provider is sent a reminder email only on the day before t
Background:
Given A "lawyers" list exists for Eurasia
And eurasia lawyers are due to begin annual review
And a list item has been with the provider for 100 days with the reference "DAY_BEFORE_UNPUBLISH_TEST"


Scenario: Provider is sent a reminder email the day before they're unpublished
When 1 days before unpublish
And the batch process has run
And the worker process has run
Then the unpublish reminder email for 1 days is sent to eligible providers

Scenario: The provider is not sent a reminder email on the day they're unpublished
When 0 days before unpublish
And the batch process has run
And the worker process has run
Then the unpublish reminder email is not sent

Scenario: Provider is NOT sent an email two days before the unpublish date
When 2 days before unpublish
And the batch process has run
Expand All @@ -37,9 +31,19 @@ Feature: Check that a provider is sent a reminder email only on the day before t

Scenario: Provider is NOT sent an email if entry is edited before unpublish date
When 1 days before unpublish
And a list item has been with the provider for 100 days with the reference "DAY_BEFORE_UNPUBLISH_TEST"
And the batch process has run
And the provider with reference "DAY_BEFORE_UNPUBLISH_TEST" has edited their details
And the worker process has run
Then the unpublish reminder email is not sent to user with reference "DAY_BEFORE_UNPUBLISH_TEST"

Scenario: The provider is not sent a reminder email on the day they're unpublished if they have responded
When 0 days before unpublish
And a list item has been with the provider for 100 days with the reference "DAY_BEFORE_UNPUBLISH_TEST"
And the batch process has run
And the provider with reference "DAY_BEFORE_UNPUBLISH_TEST" has edited their details
And the worker process has run
Then the unpublish email is not sent to user with reference "DAY_BEFORE_UNPUBLISH_TEST"



4 changes: 2 additions & 2 deletions cypress/e2e/annual-review/unpublish.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ As consular staff,
And I am logged in as a "Admin"
And I am viewing list item index for reference:"SMOKE"
Then I see "Buster"
And I see "ANNUAL REVIEW OVERDUE"
And I see "ANNUAL REVIEW OVERDUE" 6 times
And the provider with reference "UNPUBLISH_DAY_TEST" should be unpublished

Scenario: A list item is deleted after being unpublished for a year
Expand All @@ -27,4 +27,4 @@ As consular staff,
Scenario: A list item is NOT deleted after being unpublished for under a year
And there is a list item unpublished automatically "under" a year ago
And the worker process has run
Then the list item should not be deleted
Then the list item should not be deleted
8 changes: 4 additions & 4 deletions cypress/e2e/annual-review/worker.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ Feature: Emails sent on key dates
And eurasia lawyers are due to begin annual review
And the batch process has run

Scenario:
Scenario: Post receives an email on the "POST_ONE_MONTH" key date
Given the current time is within the "POST_ONE_MONTH" key date range
When the worker process has run
Then the "POST_ONE_MONTH" key date email is sent to post

Scenario:
Scenario: Post receives an email on the "POST_ONE_WEEK" key date
Given the current time is within the "POST_ONE_WEEK" key date range
When the worker process has run
Then the "POST_ONE_WEEK" key date email is sent to post

Scenario:
Scenario: Post receives an email on the "POST_ONE_DAY" key date
Given the current time is within the "POST_ONE_DAY" key date range
When the worker process has run
Then the "POST_ONE_DAY" key date email is sent to post

Scenario:
Scenario: Post receives an email on the "START" key date
Given the current time is within the "START" key date range
When the worker process has run
Then the "START" key date email is sent to post
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,27 @@ Then("an email for the {string} key date is sent to eligible providers", async f
},
},
}).then((result) => {
list = result;
cy.task("db", {
operation: "audit.findMany",
operation: "event.findMany",
variables: {
where: {
type: "listItem",
auditEvent: "REMINDER",
type: "REMINDER",
annualReviewEmailType: "started",
AND: [
{
jsonData: {
path: ["reminderType"],
equals: "sendStartedProviderEmail",
},
},
{
jsonData: {
path: ["annualReviewRef"],
equals: list.jsonData.currentAnnualReview.reference,
path: ["reference"],
equals: result.jsonData.currentAnnualReview.reference,
},
},
],
},
orderBy: {
createdAt: "desc",
time: "desc",
},
},
}).then((result) => {
cy.log(result);
cy.expect(result.length).to.be.gt(0);
result.forEach((audit) => {
cy.expect(audit.jsonData.itemId).to.be.oneOf(list.jsonData.currentAnnualReview.eligibleListItems);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ Given("eurasia lawyers are due to begin annual review", async () => {
await createIneligible();
});

Given("eurasia lawyers are due to begin annual review in {int} days", async (days) => {
await setAnnualReview(0);
await createEligible();
await createIneligible();
});

async function createEligible() {
const eligibleReferences = ["eligible-1", "eligible-2", "eligible-3", "eligible-4", "eligible-5"];

Expand All @@ -19,17 +25,17 @@ async function createIneligible() {
await createRepublishedRecently();
}

async function setAnnualReview() {
async function setAnnualReview(days = 28) {
const today = new Date();
const fourWeeksAway = new Date(today.getUTCFullYear(), today.getUTCMonth(), today.getDate() + 28);
const startDate = new Date(today.getUTCFullYear(), today.getUTCMonth(), today.getDate() + days);

await cy.task("db", {
operation: "list.update",
variables: {
where: {
reference: "SMOKE",
},
data: { nextAnnualReviewStartDate: fourWeeksAway },
data: { nextAnnualReviewStartDate: startDate },
},
});
}
Expand Down Expand Up @@ -108,7 +114,7 @@ async function createEligibleListItem(reference) {
variables: {
data: {
reference,
...listItemCreateBaseObject(),
...listItemCreateBaseObject(reference),
history: {
createMany: {
data: [events.NEW(), events.PUBLISHED()],
Expand Down Expand Up @@ -187,23 +193,27 @@ async function baseJsonData() {
},
};
}
function jsonDataLawyers() {
function jsonDataLawyers(ref) {
return {
...baseJsonData(),
areasOfLaw: [],
size: "Independent lawyer / sole practitioner",
proBono: true,
legalAid: true,
metadata: {
emailVerified: true,
},
contactName: ref,
};
}
function listItemCreateBaseObject() {
function listItemCreateBaseObject(ref) {
return {
type: "lawyers",
isApproved: true,
isPublished: true,
isBlocked: false,
status: "PUBLISHED",
jsonData: jsonDataLawyers(),
jsonData: jsonDataLawyers(ref),
list: {
connect: {
reference: "SMOKE",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { subDays, startOfDay } from "date-fns";
import { subDays, startOfDay, startOfToday } from "date-fns";

When("{int} days before unpublish", async (daysBeforeUnpublishing) => {
const DAYS_FROM_START_UNTIL_UNPUBLISH = 42;
const annualReviewDate = startOfDay(subDays(new Date(), DAYS_FROM_START_UNTIL_UNPUBLISH - daysBeforeUnpublishing));
const today = startOfToday();
const annualReviewDate = subDays(today, DAYS_FROM_START_UNTIL_UNPUBLISH - daysBeforeUnpublishing);
cy.task("db", {
operation: "list.update",
variables: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
When("the other eurasia lawyers have answered", () => {
const eligible = ["eligible-1", "eligible-2", "eligible-3", "eligible-4"];

eligible.forEach((reference) => {
cy.task("db", {
operation: "listItem.update",
variables: {
where: {
reference,
},
data: {
status: "CHECK_ANNUAL_REVIEW",
history: {
create: [
{
type: "CHECK_ANNUAL_REVIEW",
time: new Date(),
jsonData: {},
},
],
},
},
},
});
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
const TOTAL_NO_UNPUBLISH_WEEKS = 5
const TOTAL_NO_UNPUBLISH_WEEKS = 5;
Then("the reminder email for {string} weeks is sent to eligible providers", async (noOfWeeks) => {
cy.task("db", {
operation: "list.findFirst",
Expand All @@ -14,11 +14,14 @@ Then("the reminder email for {string} weeks is sent to eligible providers", asyn
variables: {
where: {
type: "REMINDER",
annualReviewEmailType: "weeklyUnpublish",
AND: [
{
jsonData: {
path: ["notes"],
equals: [`sent reminder for week ${noOfWeeks}. (${TOTAL_NO_UNPUBLISH_WEEKS - noOfWeeks} until unpublish date)`],
equals: [
`sent reminder for week ${noOfWeeks}. (${TOTAL_NO_UNPUBLISH_WEEKS - noOfWeeks} until unpublish date)`,
],
},
},
{
Expand All @@ -31,7 +34,41 @@ Then("the reminder email for {string} weeks is sent to eligible providers", asyn
},
},
}).then((result) => {
cy.wrap(result.length).as("emailsSent");
cy.expect(result.length).to.be.gt(0);
})
})
});
});
});

Then("the weeklyReminder emails were not re-sent", async () => {
cy.task("db", {
operation: "list.findFirst",
variables: {
where: {
reference: "SMOKE",
},
},
}).then((list) => {
cy.task("db", {
operation: "event.findMany",
variables: {
where: {
type: "REMINDER",
annualReviewEmailType: "weeklyUnpublish",
AND: [
{
jsonData: {
path: ["reference"],
equals: list.jsonData.currentAnnualReview.reference,
},
},
],
},
},
}).then((result) => {
cy.get("@emailsSent").then((emailsSent) => {
cy.expect(emailsSent).to.be.equal(result.length);
});
});
});
});
Loading
Loading