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

feat: Explicitly handle redaction #2313

Merged
merged 3 commits into from
Oct 17, 2023
Merged
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
4 changes: 1 addition & 3 deletions api.planx.uk/admin/session/bops.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { expectedPayload } from "../../tests/mocks/bopsMocks";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/bops`;

const mockGenerateBOPSPayload = jest.fn().mockResolvedValue({
exportData: expectedPayload,
});
const mockGenerateBOPSPayload = jest.fn().mockResolvedValue(expectedPayload);

jest.mock("@opensystemslab/planx-core", () => {
return {
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/admin/session/bops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getBOPSPayload = async (
next: NextFunction,
) => {
try {
const { exportData } = await $api.export.bopsPayload(req.params.sessionId);
const exportData = await $api.export.bopsPayload(req.params.sessionId);
res.set("content-type", "application/json");
return res.send(exportData);
} catch (error) {
Expand Down
17 changes: 7 additions & 10 deletions api.planx.uk/admin/session/csv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import { authHeader } from "../../tests/mockJWT";
const endpoint = (strings: TemplateStringsArray) =>
`/admin/session/${strings[0]}/csv`;

const mockGenerateCSVData = jest.fn().mockResolvedValue({
responses: [
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
],
redactedResponses: [],
});
const mockGenerateCSVData = jest.fn().mockResolvedValue([
{
question: "Is this a test?",
responses: [{ value: "Yes" }],
metadata: {},
},
]);
jest.mock("@opensystemslab/planx-core", () => {
return {
CoreDomainClient: jest.fn().mockImplementation(() => ({
Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/admin/session/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getCSVData(
) {
try {
const $client = getClient();
const { responses } = await $client.export.csvData(req.params.sessionId);
const responses = await $client.export.csvData(req.params.sessionId);

if (req.query?.download) {
stringify(responses, {
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function getRedactedCSVData(
) {
try {
const $client = getClient();
const { redactedResponses } = await $client.export.csvData(
const redactedResponses = await $client.export.csvDataRedacted(
req.params.sessionId,
);

Expand Down
4 changes: 2 additions & 2 deletions api.planx.uk/admin/session/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const getHTMLExport: HTMLExportHandler = async (req, res, next) => {
const session = await $client.session.find(req.params.sessionId);
if (!session) throw Error(`Unable to find session ${req.params.sessionId}`);

const { responses } = await $client.export.csvData(req.params.sessionId);
const responses = await $client.export.csvData(req.params.sessionId);
const boundingBox =
session.data.passport.data["property.boundary.site.buffered"];

Expand Down Expand Up @@ -65,7 +65,7 @@ export const getRedactedHTMLExport: HTMLExportHandler = async (
const session = await $client.session.find(req.params.sessionId);
if (!session) throw Error(`Unable to find session ${req.params.sessionId}`);

const { redactedResponses } = await $client.export.csvData(
const redactedResponses = await $client.export.csvDataRedacted(
req.params.sessionId,
);
const boundingBox =
Expand Down
4 changes: 3 additions & 1 deletion api.planx.uk/admin/session/oneAppXML.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const mockGenerateOneAppXML = jest
jest.mock("../../client", () => {
return {
$api: {
generateOneAppXML: () => mockGenerateOneAppXML(),
export: {
oneAppPayload: () => mockGenerateOneAppXML(),
},
},
};
});
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/admin/session/oneAppXML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getOneAppXML = async (
next: NextFunction,
) => {
try {
const xml = await $api.generateOneAppXML(req.params.sessionId);
const xml = await $api.export.oneAppPayload(req.params.sessionId);
res.set("content-type", "text/xml");
return res.send(xml);
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion api.planx.uk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@airbrake/node": "^2.1.8",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#d92224b",
"@opensystemslab/planx-core": "git+https://github.com/theopensystemslab/planx-core#3a85966",
"@types/isomorphic-fetch": "^0.0.36",
"adm-zip": "^0.5.10",
"aws-sdk": "^2.1467.0",
Expand Down
Loading
Loading