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

Fix referral partner courses bug #1095

Merged
merged 3 commits into from
Aug 21, 2024
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
9 changes: 7 additions & 2 deletions cypress/integration/tests/delete-user.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ describe('Delete User', () => {
cy.get('#delete-account-button', { timeout: 10000 })
.should('contain.text', 'Delete Account')
.click();
cy.get('#confirm-dialog-submit', { timeout: 10000 }).click();
cy.url({ timeout: 10000 }).should('include', '/');

// Temporarily disabled due to leaving deleted accounts in staging db
// TODO: add a call to hard delete the user after this test, using the user id
// There is no API route to hard deleting a user currently - add one or improve the DELETE /cypress endpoint

// cy.get('#confirm-dialog-submit', { timeout: 10000 }).click();
// cy.url({ timeout: 10000 }).should('include', '/');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ describe.only('A logged in user should be able to navigate to a course session a
cy.get('button').contains('Send').click(); //submit feedback

cy.get('h3').contains('Thank you for submitting your feedback').should('exist'); //check user feedback

cy.deleteUser(); //delete test user
});

after(() => {
Expand Down
1 change: 1 addition & 0 deletions hooks/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const useStateUtils = () => {
await dispatch(clearCoursesSlice());
await dispatch(clearUserSlice());
await dispatch(api.util.resetApiState());
window.localStorage.removeItem('referralPartner');
}, [dispatch]);

return { clearState };
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function MyApp(props: MyAppProps) {
const path = router.asPath;

if (path?.includes('/welcome/')) {
const referralPartner = path.split('/')[2]; // Gets "bumble" from /welcome/bumble
const referralPartner = path.split('/')[2].split('?')[0]; // Gets "bumble" from /welcome/bumble?code=123

if (referralPartner) {
window.localStorage.setItem('referralPartner', referralPartner);
Expand Down
5 changes: 2 additions & 3 deletions pages/courses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useTypedSelector } from '../../hooks/store';
import illustrationCourses from '../../public/illustration_courses.svg';
import { columnStyle, rowStyle } from '../../styles/common';
import logEvent, { getEventUserData } from '../../utils/logEvent';
import { capitaliseFirstLetter } from '../../utils/strings';

const containerStyle = {
backgroundColor: 'secondary.light',
Expand Down Expand Up @@ -99,9 +100,7 @@ const CourseList: NextPage<Props> = ({ stories }) => {
setLoadedCourses(coursesWithAccess);
} else if (referralPartner) {
const coursesWithAccess = stories.filter((story) =>
story.content.included_for_partners.includes(
referralPartner.charAt(0).toUpperCase() + referralPartner.slice(1),
),
story.content.included_for_partners.includes(capitaliseFirstLetter(referralPartner)),
);
setLoadedCourses(coursesWithAccess);
} else {
Expand Down
3 changes: 3 additions & 0 deletions utils/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const capitaliseFirstLetter = (string: string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
};
Loading