Skip to content

Commit

Permalink
update git.gov to match upstream data structure; fix bug in handbook …
Browse files Browse the repository at this point in the history
…script
  • Loading branch information
mgwalker committed Nov 20, 2024
1 parent b106312 commit cdd36fe
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 37 deletions.
6 changes: 3 additions & 3 deletions src/scripts/dot-gov.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ const DOMAIN_TYPES = {

/** Current list of fields available in the CSV file. */
const DATA_FIELDS = {
NAME: "Domain Name",
TYPE: "Domain Type",
NAME: "Domain name",
TYPE: "Domain type",
AGENCY: "Agency",
ORG: "Organization",
ORG: "Organization name",
CITY: "City",
STATE: "State",
};
Expand Down
56 changes: 28 additions & 28 deletions src/scripts/dot-gov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,81 +11,81 @@ describe("dot-gov domains", () => {
{
Agency: "Non-Federal Agency",
City: "Albany",
"Domain Name": "ALBANYCA.GOV",
"Domain Type": "City",
Organization: "City of Albany",
"Domain name": "ALBANYCA.GOV",
"Domain type": "City",
"Organization name": "City of Albany",
"Security Contact Email": "(blank)",
State: "CA",
},
{
Agency: "Non-Federal Agency",
City: "Belle Plaine",
"Domain Name": "BELLEPLAINEIOWA.GOV",
"Domain Type": "City",
Organization: "City of Belle Plaine",
"Domain name": "BELLEPLAINEIOWA.GOV",
"Domain type": "City",
"Organization name": "City of Belle Plaine",
"Security Contact Email": "(blank)",
State: "IA",
},
{
Agency: "U.S. Department of Agriculture",
City: "Washington",
"Domain Name": "RURAL.GOV",
"Domain Type": "Federal - Executive",
Organization: "Rural Development",
"Domain name": "RURAL.GOV",
"Domain type": "Federal - Executive",
"Organization name": "Rural Development",
"Security Contact Email": "cyber.(blank)",
State: "DC",
},
{
Agency: "The Supreme Court",
City: "Washington",
"Domain Name": "SUPREMECOURTUS.GOV",
"Domain Type": "Federal - Judicial",
Organization: "Supreme Court of the United Statest",
"Domain name": "SUPREMECOURTUS.GOV",
"Domain type": "Federal - Judicial",
"Organization name": "Supreme Court of the United Statest",
"Security Contact Email": "(blank)",
State: "DC",
},
{
Agency: "Government Publishing Office",
City: "Washington",
"Domain Name": "USCODE.GOV",
"Domain Type": "Federal - Legislative",
Organization: "United States Government Publishing Office",
"Domain name": "USCODE.GOV",
"Domain type": "Federal - Legislative",
"Organization name": "United States Government Publishing Office",
"Security Contact Email": "(blank)",
State: "DC",
},
{
Agency: "Non-Federal Agency",
City: "Arizona City",
"Domain Name": "ACSD-AZ.GOV",
"Domain Type": "Independent Intrastate",
Organization: "Arizona City Sanitary District ",
"Domain name": "ACSD-AZ.GOV",
"Domain type": "Independent Intrastate",
"Organization name": "Arizona City Sanitary District ",
"Security Contact Email": "(blank)",
State: "AZ",
},
{
Agency: "Non-Federal Agency",
City: "Mechanicsburg",
"Domain Name": "EMSCOMPACT.GOV",
"Domain Type": "Interstate",
Organization: "Interstate Commission for EMS Personnel Practice",
"Domain name": "EMSCOMPACT.GOV",
"Domain type": "Interstate",
"Organization name": "Interstate Commission for EMS Personnel Practice",
"Security Contact Email": "(blank)",
State: "PA",
},
{
Agency: "Non-Federal Agency",
City: "St Croix",
"Domain Name": "VIVOTE.GOV",
"Domain Type": "State",
Organization: "Election System of the Virgin Islands",
"Domain name": "VIVOTE.GOV",
"Domain type": "State",
"Organization name": "Election System of the Virgin Islands",
"Security Contact Email": "(blank)",
State: "VI",
},
{
Agency: "Non-Federal Agency",
City: "Ada",
"Domain Name": "CHICKASAW-NSN.GOV",
"Domain Type": "Tribal",
Organization: "the Chickasaw Nation",
"Domain name": "CHICKASAW-NSN.GOV",
"Domain type": "Tribal",
"Organization name": "the Chickasaw Nation",
"Security Contact Email": "(blank)",
State: "OK",
},
Expand Down Expand Up @@ -175,7 +175,7 @@ describe("dot-gov domains", () => {
it("if the API does return some domains", async () => {
fetchResponse.text.mockResolvedValue(
[
"Domain Name,Domain Type,Agency,Organization,City,State,Security Contact Email",
"Domain name,Domain type,Agency,Organization name,City,State,Security Contact Email",
"ALBANYCA.GOV,City,Non-Federal Agency,City of Albany,Albany,CA,(blank)",
"BELLEPLAINEIOWA.GOV,City,Non-Federal Agency,City of Belle Plaine,Belle Plaine,IA,(blank)",
"RURAL.GOV,Federal - Executive,U.S. Department of Agriculture,Rural Development,Washington,DC,cyber.(blank)",
Expand Down
8 changes: 5 additions & 3 deletions src/scripts/handbook.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ module.exports = (app) => {

const {
context: {
matches: [, , search],
matches: [, search],
},
event: { thread_ts: thread, ts },
say,
} = msg;

console.log(msg.context.matches);

const searchString = search
.replace(/[”“]/g, '"') // replace smart quotes
.replace(/[’‘]/g, "'"); // more smart quotes
?.replace(/[”“]/g, '"') // replace smart quotes
?.replace(/[’‘]/g, "'"); // more smart quotes
const url = `${baseUrl}${encodeURIComponent(searchString)}`;

try {
Expand Down
6 changes: 3 additions & 3 deletions src/scripts/handbook.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("TTS Handbook search", () => {

describe("it handles bot triggers", () => {
const message = {
context: { matches: [null, null, "search string"] },
context: { matches: [null, "search string"] },
event: { thread_ts: undefined, ts: 150 },
say: jest.fn(),
};
Expand All @@ -38,7 +38,7 @@ describe("TTS Handbook search", () => {
handbook(app);
handler = app.getHandler();

message.context.matches[2] = "search string";
message.context.matches[1] = "search string";
});

it("gracefully responds if there is an error", async () => {
Expand All @@ -53,7 +53,7 @@ describe("TTS Handbook search", () => {
});

it("converts characters accordingly before putting them in the search URL", async () => {
message.context.matches[2] = "”some ’search‘ goes here“";
message.context.matches[1] = "”some ’search‘ goes here“";
await handler(message);

expect(fetch).toHaveBeenCalledWith(
Expand Down

0 comments on commit cdd36fe

Please sign in to comment.