Skip to content

Commit cbd6a98

Browse files
Merge pull request #262 from NYPL/qa
deploy bug fixes
2 parents f743cfd + 53d1998 commit cbd6a98

File tree

41 files changed

+400
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+400
-280
lines changed

.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ OAUTH_CLIENT_SECRET=askTeammate
66
IPSTACK_KEY=askTeammate
77
NEXT_PUBLIC_DS_GLOBAL_HEADER=https://ds-header.nypl.org/header.min.js?containerId=nypl-header
88
NEXT_PUBLIC_DS_GLOBAL_FOOTER=https://ds-header.nypl.org/footer.min.js?containerId=nypl-footer
9-
NEXT_PUBLIC_ADOBE_ANALYTICS_TAG=https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js
9+
NEXT_PUBLIC_ADOBE_ANALYTICS_TAG=https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js
10+
COOKIE_DOMAIN=.nypl.org

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"react/prop-types": 0,
3636
"react/display-name": 0,
3737
"@typescript-eslint/no-use-before-define": 0,
38-
"@typescript-eslint/camelcase": "off"
38+
"@typescript-eslint/camelcase": "off",
39+
"react/react-in-jsx-scope": 0
3940
},
4041
"settings": {
4142
"react": {

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## CHANGE LOG
22

3+
### v1.1.0 Duplicate patron bug fixes
4+
- Add cookie-based redirect back to congrats page from any page after success
5+
- Remove hasUsernameBeenValidated flag and hidden input field
6+
- Update loading layer to remain until navigation away from submission page
7+
- Remove password display from congrats graphic
8+
39
### v1.0.0 Remediation Project (security) update
410

511
- Switch deployment to GitHub Actions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
export const mockConfirmation = {
2+
title: "congrats title",
3+
description: {
4+
part1: "congrats part1",
5+
part2: "congrats part2",
6+
part3: "congrats part3",
7+
},
8+
nextSteps: {
9+
explore: "congrats explore",
10+
borrow: "congrats borrow",
11+
updates: "congrats updates",
12+
more: "congrats more",
13+
},
14+
};
15+
export const mockPersonal = {
16+
title: "Step 1 of 5: Personal Information",
17+
firstName: {
18+
label: "First Name",
19+
},
20+
lastName: {
21+
label: "Last Name",
22+
},
23+
birthdate: {
24+
label: "Date of Birth",
25+
},
26+
ageGate: "Yes, I am over 13 years old.",
27+
email: {
28+
label: "Email Address",
29+
},
30+
eCommunications: {
31+
labelText:
32+
"Yes, I would like to receive information about NYPL's programs and services",
33+
},
34+
};
35+
export const mockLocation = {
36+
address: {
37+
title: "Home Address",
38+
line1: { label: "Street Address" },
39+
line2: { label: "Apartment / Suite" },
40+
city: { label: "City" },
41+
state: { label: "State", instruction: "2-letter abbreviation" },
42+
postalCode: {
43+
label: "Postal Code",
44+
instruction: "5 or 9-digit postal code",
45+
},
46+
},
47+
};
48+
export const mockAccount = {
49+
title: "Step 4 of 5: Customize Your Account",
50+
description:
51+
"Create a username and password so you can log in and manage your account or access an array of our digital resources. Your username should be unique.",
52+
username: {
53+
label: "Username",
54+
instruction: "5-25 alphanumeric characters. No special characters.",
55+
checkButton: "Check if username is available",
56+
},
57+
password: {
58+
label: "Password",
59+
instruction:
60+
"We encourage you to select a strong password that includes: at least 8 characters, a mixture of uppercase and lowercase letters, a mixture of letters and numbers, and at least one special character <i>except</i> period (.) <br />Example: MyLib1731@<br />Password cannot contain common patterns such as consecutively repeating a character three or more times, e.g. aaaatf54 or repeating a pattern, e.g. abcabcab",
61+
},
62+
verifyPassword: {
63+
label: "Verify Password",
64+
instruction: "8-32 characters",
65+
},
66+
showPassword: "Show Password",
67+
library: {
68+
selectLibrary: "Select a home library:",
69+
placeholder: "Type a library name, such as Parkchester Library",
70+
title: "Home Library",
71+
description: {
72+
part1:
73+
"Choosing a home library will help us make sure you&apos;re getting everything you need from a branch that&apos;s most convenient for you.",
74+
part2:
75+
"You can skip this step and update it at any point through your account.",
76+
},
77+
},
78+
};
79+
export const mockReview = {
80+
title: "Step 5 of 5: Confirm Your Information",
81+
description:
82+
"Make sure all the information you’ve entered is correct. If needed, you can still make changes before you submit your application.",
83+
section: {
84+
personal: "Personal Information",
85+
address: {
86+
label: "Address",
87+
location: "Location",
88+
home: "Home",
89+
work: "Work",
90+
},
91+
homeLibrary: "Home Library",
92+
},
93+
createAccount: "Create Your Account",
94+
receiveNewsletter: "Receive information about NYPL's programs and services",
95+
yes: "Yes",
96+
no: "No",
97+
nextStep:
98+
"After you submit your application, you will see a confirmation page with your account information, and you will be able to log in and request books and materials.",
99+
};
100+
export const mockButton = {
101+
start: "Get Started",
102+
edit: "Edit",
103+
submit: "Submit",
104+
next: "Next",
105+
previous: "Previous",
106+
};
+48-118
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,32 @@
11
import { render, screen } from "@testing-library/react";
22
import { axe } from "jest-axe";
33
import React from "react";
4+
import {
5+
mockConfirmation,
6+
mockPersonal,
7+
mockAccount,
8+
mockReview,
9+
mockButton,
10+
mockLocation,
11+
} from "./fixtures/react-i18next-fixtures";
12+
import router from "next/router";
413

514
import ReviewPage from "../pages/review";
615
import { TestProviderWrapper, mockTFunction } from "../testHelper/utils";
716

17+
jest.mock("next/router", () => {
18+
const mockRouter = jest.requireActual("next-router-mock");
19+
return { ...mockRouter, push: jest.fn() };
20+
});
21+
822
jest.mock("react-i18next", () => {
923
const en = {
10-
personal: {
11-
title: "Step 1 of 5: Personal Information",
12-
firstName: {
13-
label: "First Name",
14-
},
15-
lastName: {
16-
label: "Last Name",
17-
},
18-
birthdate: {
19-
label: "Date of Birth",
20-
},
21-
ageGate: "Yes, I am over 13 years old.",
22-
email: {
23-
label: "Email Address",
24-
},
25-
eCommunications: {
26-
labelText:
27-
"Yes, I would like to receive information about NYPL's programs and services",
28-
},
29-
},
30-
location: {
31-
address: {
32-
title: "Home Address",
33-
line1: { label: "Street Address" },
34-
line2: { label: "Apartment / Suite" },
35-
city: { label: "City" },
36-
state: { label: "State", instruction: "2-letter abbreviation" },
37-
postalCode: {
38-
label: "Postal Code",
39-
instruction: "5 or 9-digit postal code",
40-
},
41-
},
42-
},
43-
account: {
44-
title: "Step 4 of 5: Customize Your Account",
45-
description:
46-
"Create a username and password so you can log in and manage your account or access an array of our digital resources. Your username should be unique.",
47-
username: {
48-
label: "Username",
49-
instruction: "5-25 alphanumeric characters. No special characters.",
50-
checkButton: "Check if username is available",
51-
},
52-
password: {
53-
label: "Password",
54-
instruction:
55-
"We encourage you to select a strong password that includes: at least 8 characters, a mixture of uppercase and lowercase letters, a mixture of letters and numbers, and at least one special character <i>except</i> period (.) <br />Example: MyLib1731@<br />Password cannot contain common patterns such as consecutively repeating a character three or more times, e.g. aaaatf54 or repeating a pattern, e.g. abcabcab",
56-
},
57-
verifyPassword: {
58-
label: "Verify Password",
59-
instruction: "8-32 characters",
60-
},
61-
showPassword: "Show Password",
62-
library: {
63-
selectLibrary: "Select a home library:",
64-
placeholder: "Type a library name, such as Parkchester Library",
65-
title: "Home Library",
66-
description: {
67-
part1:
68-
"Choosing a home library will help us make sure you&apos;re getting everything you need from a branch that&apos;s most convenient for you.",
69-
part2:
70-
"You can skip this step and update it at any point through your account.",
71-
},
72-
},
73-
},
74-
review: {
75-
title: "Step 5 of 5: Confirm Your Information",
76-
description:
77-
"Make sure all the information you’ve entered is correct. If needed, you can still make changes before you submit your application.",
78-
section: {
79-
personal: "Personal Information",
80-
address: {
81-
label: "Address",
82-
location: "Location",
83-
home: "Home",
84-
work: "Work",
85-
},
86-
homeLibrary: "Home Library",
87-
},
88-
createAccount: "Create Your Account",
89-
receiveNewsletter:
90-
"Receive information about NYPL's programs and services",
91-
yes: "Yes",
92-
no: "No",
93-
nextStep:
94-
"After you submit your application, you will see a confirmation page with your account information, and you will be able to log in and request books and materials.",
95-
},
96-
button: {
97-
start: "Get Started",
98-
edit: "Edit",
99-
submit: "Submit",
100-
next: "Next",
101-
previous: "Previous",
102-
},
24+
confirmation: mockConfirmation,
25+
personal: mockPersonal,
26+
account: mockAccount,
27+
review: mockReview,
28+
button: mockButton,
29+
location: mockLocation,
10330
};
10431
return {
10532
// this mock makes sure any components using the translate hook can use it without a warning being shown
@@ -108,36 +35,39 @@ jest.mock("react-i18next", () => {
10835
}),
10936
};
11037
});
111-
jest.mock("next/router", () => ({
112-
useRouter() {
113-
return {
114-
route: "/",
115-
pathname: "",
116-
query: { lang: "en" },
117-
asPath: "",
118-
};
119-
},
120-
}));
12138

12239
describe("ReviewPage", () => {
123-
let container;
124-
beforeEach(() => {
125-
const utils = render(
126-
<TestProviderWrapper>
127-
<ReviewPage />
128-
</TestProviderWrapper>
129-
);
40+
describe("general tests", () => {
41+
let container;
42+
beforeEach(() => {
43+
const utils = render(
44+
<TestProviderWrapper>
45+
<ReviewPage />
46+
</TestProviderWrapper>
47+
);
13048

131-
container = utils.container;
132-
});
49+
container = utils.container;
50+
});
51+
52+
test("passes axe accessibility test", async () => {
53+
expect(await axe(container)).toHaveNoViolations();
54+
});
13355

134-
test("passes axe accessibility test", async () => {
135-
expect(await axe(container)).toHaveNoViolations();
56+
test("renders a title and description", () => {
57+
expect(
58+
screen.getByText("Step 5 of 5: Confirm Your Information")
59+
).toBeInTheDocument();
60+
});
13661
});
13762

138-
test("renders a title and description", () => {
139-
expect(
140-
screen.getByText("Step 5 of 5: Confirm Your Information")
141-
).toBeInTheDocument();
63+
describe("redirects", () => {
64+
test("redirects if user has already logged in", async () => {
65+
render(
66+
<TestProviderWrapper>
67+
<ReviewPage hasUserAlreadyRegistered={true} />
68+
</TestProviderWrapper>
69+
);
70+
setTimeout(() => expect(router.push).toHaveBeenCalled(), 50);
71+
});
14272
});
14373
});

appConfig.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
export default {
2-
appTitle: "Library Card Application Form",
3-
appName: "NYPL Library Card App",
4-
favIconPath: "https://ux-static.nypl.org/images/favicon.ico",
5-
api: {
6-
oauth: process.env.OAUTH_PROVIDER_URL,
7-
patron: process.env.PATRON_CREATION_URL,
8-
validate: process.env.PATRON_VALIDATION_URL,
9-
},
10-
clientId: process.env.OAUTH_CLIENT_ID,
11-
clientSecret: process.env.OAUTH_CLIENT_SECRET,
12-
ipStackKey: process.env.IPSTACK_KEY,
13-
nodeEnv: process.env.NODE_ENV,
14-
agencyType: {
15-
default: "198",
16-
nys: "199",
17-
},
18-
scopes: "account:write account:read",
19-
dsHeader: process.env.NEXT_PUBLIC_DS_GLOBAL_HEADER,
20-
dsFooter: process.env.NEXT_PUBLIC_DS_GLOBAL_FOOTER,
21-
adobeAnalyticsTag: process.env.NEXT_PUBLIC_ADOBE_ANALYTICS_TAG,
1+
export const appTitle = "Library Card Application Form"
2+
export const appName = "NYPL Library Card App"
3+
export const favIconPath = "https://ux-static.nypl.org/images/favicon.ico"
4+
export const api = {
5+
oauth: process.env.OAUTH_PROVIDER_URL,
6+
patron: process.env.PATRON_CREATION_URL,
7+
validate: process.env.PATRON_VALIDATION_URL,
228
};
9+
export const clientId = process.env.OAUTH_CLIENT_ID
10+
export const clientSecret = process.env.OAUTH_CLIENT_SECRET
11+
export const ipStackKey = process.env.IPSTACK_KEY
12+
export const nodeEnv = process.env.NODE_ENV
13+
export const agencyType = {
14+
default: "198",
15+
nys: "199",
16+
};
17+
export const scopes = "account:write account:read"
18+
export const dsHeader = process.env.NEXT_PUBLIC_DS_GLOBAL_HEADER
19+
export const dsFooter = process.env.NEXT_PUBLIC_DS_GLOBAL_FOOTER
20+
export const adobeAnalyticsTag = process.env.NEXT_PUBLIC_ADOBE_ANALYTICS_TAG
21+
export const cookieDomain = process.env.COOKIE_DOMAIN
22+

jest.config.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ module.exports = {
77
"!**/node_modules/**",
88
],
99
setupFilesAfterEnv: ["<rootDir>/testHelper/browser.ts"],
10-
testPathIgnorePatterns: ["/node_modules/", "/.next/", ".spec"],
10+
testPathIgnorePatterns: [
11+
"/node_modules/",
12+
"/.next/",
13+
".spec",
14+
"/__tests__/fixtures/*",
15+
],
1116
// A map from regular expressions to paths to transformers
1217
transform: {
1318
// Use babel-jest to transpile tests with the next/babel preset

0 commit comments

Comments
 (0)