Skip to content

Commit

Permalink
Merge pull request #1097 from chaynHQ/develop
Browse files Browse the repository at this point in the history
Merge Develop onto Main
  • Loading branch information
eleanorreem authored Aug 28, 2024
2 parents 1b8a3a5 + e0e2f97 commit a4df2a5
Show file tree
Hide file tree
Showing 42 changed files with 1,255 additions and 153 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel", "@babel/preset-typescript"],
"plugins": ["istanbul"]
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ yarn-error.log*
/cypress/screenshots
/cypress/videos
/cypress/example
cypress.env.json
/.nyc_output

# Partytown
/public/~partytown
Expand Down
7 changes: 7 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@istanbuljs/nyc-config-babel",
"reporter": ["text-summary", "html"],
"include": ["pages/**/*.ts", "pages/**/*.tsx", "components/**/*.ts", "components/**/*.tsx"],
"instrument": true,
"all": true
}
7 changes: 7 additions & 0 deletions CYPRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,10 @@ To run the tests, follow the instructions below:
6. Click on the test you'd like to run. This will open another Chrome window and the chosen test will now run.

The above option will run the tests against a visible browser. To run a head-less version of the tests (i.e. no visible browser), use the command `yarn cypress:headless`. The headless cypress runs will be faster as the browser elements are not visible.

## Test Coverage

After all tests have been run using `yarn cypress:headless`, a code coverage report can be generated by running `yarn cypress:coverage`. This will generate two reports:

1. A coverage summary in the terminal
2. An `index.html` page found in `./coverage` which provides details of what lines of code have or have not been covered by tests, and can be viewed in a browser
32 changes: 24 additions & 8 deletions components/cards/SessionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ interface SessionCardProps {
session: ISbStoryData;
sessionSubtitle: string;
storyblokCourseId: number;
clickable: boolean;
}

const SessionCard = (props: SessionCardProps) => {
const { session, sessionSubtitle, storyblokCourseId } = props;
const { session, sessionSubtitle, storyblokCourseId, clickable } = props;
const [expanded, setExpanded] = useState<boolean>(false);

const t = useTranslations('Courses');
Expand All @@ -73,12 +74,27 @@ const SessionCard = (props: SessionCardProps) => {

return (
<Card sx={cardStyle}>
<CardActionArea
sx={cardActionStyle}
component={Link}
href={`/${session.full_slug}`}
aria-label={`${t('navigateToSession')} ${session.name}`}
>
{clickable ? (
<CardActionArea
sx={cardActionStyle}
component={Link}
href={`/${session.full_slug}`}
aria-label={`${t('navigateToSession')} ${session.name}`}
>
<CardContent sx={cardContentStyle}>
<Box sx={cardContentRowStyles}>
<SessionProgressDisplay
sessionId={session.id}
storyblokCourseId={storyblokCourseId}
/>
<Typography flex={1} component="h3" variant="h3">
{session.content.name}
</Typography>
</Box>
<Typography color="grey.700">{sessionSubtitle}</Typography>
</CardContent>
</CardActionArea>
) : (
<CardContent sx={cardContentStyle}>
<Box sx={cardContentRowStyles}>
<SessionProgressDisplay sessionId={session.id} storyblokCourseId={storyblokCourseId} />
Expand All @@ -88,7 +104,7 @@ const SessionCard = (props: SessionCardProps) => {
</Box>
<Typography color="grey.700">{sessionSubtitle}</Typography>
</CardContent>
</CardActionArea>
)}
<CardActions sx={cardActionsStyle}>
<IconButton
sx={{ marginLeft: 'auto' }}
Expand Down
1 change: 1 addition & 0 deletions components/forms/EmailRemindersSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const EmailRemindersSettingsForm = () => {
{showUpdateLaterMessage && <Typography variant="body2">{t('update')}</Typography>}

<LoadingButton
qa-id="email-reminders-settings-submit"
sx={{ mt: 3 }}
variant="contained"
fullWidth
Expand Down
3 changes: 2 additions & 1 deletion components/storyblok/StoryblokCoursePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const StoryblokCoursePage = (props: StoryblokCoursePageProps) => {
const partnerAccesses = useTypedSelector((state) => state.partnerAccesses);
const partnerAdmin = useTypedSelector((state) => state.partnerAdmin);
const courses = useTypedSelector((state) => state.courses);

const isLoggedIn = useTypedSelector((state) => Boolean(state.user.id));
const [incorrectAccess, setIncorrectAccess] = useState<boolean>(true);
const [courseProgress, setCourseProgress] = useState<PROGRESS_STATUS>(
PROGRESS_STATUS.NOT_STARTED,
Expand Down Expand Up @@ -217,6 +217,7 @@ const StoryblokCoursePage = (props: StoryblokCoursePageProps) => {
session={session}
sessionSubtitle={position}
storyblokCourseId={storyId}
clickable={isLoggedIn}
/>
);
})}
Expand Down
4 changes: 3 additions & 1 deletion components/storyblok/StoryblokPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const StoryblokPage = (props: StoryblokPageProps) => {

return (
<>
<Head>{title}</Head>
<Head>
<title>{title}</title>
</Head>
<main
{...storyblokEditable({ _uid, _editable, title, description, header_image, page_sections })}
>
Expand Down
5 changes: 2 additions & 3 deletions components/storyblok/StoryblokTeamMemberCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const StoryblokTeamMemberCard = (props: StoryblokTeamMemberCardProps) => {

return (
<Card
data-testid="TeamMemberCard"
sx={cardStyle}
{...storyblokEditable({
_uid,
Expand Down Expand Up @@ -127,9 +128,7 @@ const StoryblokTeamMemberCard = (props: StoryblokTeamMemberCardProps) => {
</CardActionArea>
<Collapse in={expanded} timeout="auto" unmountOnExit>
<CardContent sx={collapseContentStyle}>
<Typography variant="body2" mb={0} paragraph>
{render(bio, RichTextOptions)}
</Typography>
<Box>{render(bio, RichTextOptions)}</Box>
</CardContent>
</Collapse>
</Card>
Expand Down
5 changes: 4 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ dotenv.config({ path: '.env.local' });
export default defineConfig({
projectId: process.env.CYPRESS_PROJECT_ID,
fileServerFolder: 'cypress',
defaultCommandTimeout: 10000,
env: process.env, // Uses project environment variables set in .env
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/config/plugins')(on, config);
require('@cypress/code-coverage/task')(on, config);
return config;
},
specPattern: [
'cypress/integration/before/**/*.cy.{js,jsx,ts,tsx}',
Expand All @@ -19,5 +21,6 @@ export default defineConfig({
],
baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
supportFile: 'cypress/support/index.js',
experimentalRunAllSpecs: true,
},
});
61 changes: 61 additions & 0 deletions cypress/fixtures/meet-the-team.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"core": [
{
"name": "Hera Hussain",
"title": "Founder and CEO of Chayn",
"languages": "English, Urdu, Punjabi",
"image": {
"alt": "hera2",
"src": "hera2"
},
"description": "Hera Hussain is the founder and CEO of Chayn. She has years of experience supporting survivors. She’s our Safeguarding Lead. Hera was raised in Pakistan and came to the UK to study Psychology and Economics. Hera was on the Forbes 30 Under 30 and MIT Technology Review’s Innovators Under 35 list, and was awarded the British Empire Medal by the Queen.",
"closed": false
},
{
"name": "Francesca Jarvis",
"title": "Survivor Services Lead",
"languages": "English",
"image": {
"alt": "Picture of Francesca",
"src": "img-20220609-wa0009"
},
"description": "Francesca grew up in the UK and lives in London. Before joining Chayn as the Survivor Services Lead for our Bloom project, Francesca worked in frontline support services for survivors of sexual violence and youth work. She has a lot of experience supporting survivors around and through the criminal legal system, managing teams of frontline workers, and developing ways of working.",
"closed": false
},
{
"name": "Carolina Cal",
"title": "Survivor Services Facilitator",
"languages": "English, Portuguese, Spanish",
"image": {
"alt": "Carolina is a white women with long brown hair wearing a black top with leaves on it. She stands in front of a large green bush that fills the entire frame.",
"src": "carolina-headshot"
},
"description": "Carolina is from São Paulo in Brazil. She worked for Latin American Women’s Rights organisations in community engagement before joining Chayn and has extensive experience in facilitating wellbeing activities and engaging migrant women in conversations surrounding notions of migration, identity, gendered violence & intersectionality. Carolina has a MA in Applied Theatre from Central School of Speech & Drama and is passionate about using the arts to co-create social change with women from the Global Majority.",
"closed": false
},
{
"name": "Abbie Tshola",
"title": "Survivor Services Administrator",
"languages": "English, French",
"image": {
"alt": "Abbie is a Black woman taking a selfie. She is wearing a black top and has black hair. She is standing in front of a brick wall with a clock on it.",
"src": "abbie-headshot"
},
"description": "Abbie is from London, UK. Having recently graduated from the London School of Economics with an MSc Political Sociology degree, Abbie has considerable experience researching higher education through a decolonial and black feminist lens and has advocated for policies that improves the experience of marginalised students. Abbie also enjoys exploring UX Design and is currently building a portfolio which centres black feminist values in digital spaces.",
"closed": false
}
],
"supporting": [
{
"name": "Paz Romero",
"title": "Bloom video presenter, chat team",
"languages": "English, Spanish",
"image": {
"alt": "Picture of Paz",
"src": "paz2"
},
"description": "Paz Romero is a Latina, queer woman from Rio de la Plata. She was born south of Buenos Aires, Argentina and she’s a grassroots activist for women and sexual diversities rights. She coordinated a regional feminist organization; she’s a translator, proofreader, QC and project manager. Paz has provided us a lot of project support at Chayn, facilitated some of our Spanish-language Bloom videos, and is one of our 1-2-1 chat facilitators.",
"closed": true
}
]
}
20 changes: 0 additions & 20 deletions cypress/integration/after/after.cy.tsx

This file was deleted.

17 changes: 6 additions & 11 deletions cypress/integration/before/before.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ describe('Initial cleanup test', () => {
cy.logInWithEmailAndPassword(
Cypress.env('CYPRESS_SUPER_ADMIN_EMAIL'),
Cypress.env('CYPRESS_SUPER_ADMIN_PASSWORD'),
);

try {
).then(() => {
cy.deleteCypressAccessCodes();
cy.deleteAllCypressUsers();
cy.log('Before all function completed - stale cypress users deleted');
} catch (error) {
cy.log(
`Before all function failed - catching error to prevent failing tests. Error: ${error}`,
);
}
cy.deleteAllCypressUsers().then(() => {
cy.log('Before all function completed - stale cypress users deleted');
});

cy.logout();
cy.logout();
});
});
});
121 changes: 121 additions & 0 deletions cypress/integration/tests/home.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
const HOME_PAGE_URL = '/';

describe('Home page should display', () => {
before(() => {
cy.cleanUpTestState();
});

beforeEach(() => {
cy.visit(HOME_PAGE_URL);
});

it('join us section', () => {
cy.get('h1').should('contain', 'Join us on your healing journey');
cy.get('p').should(
'contain',
'Bloom is here for you to learn, heal and grow towards a confident future.',
);
cy.checkImage(
'Person sitting crossed legged with symbols floating around such as a video icon, flower, message icon and a persons head with a flower',
'landing_page_illustration',
);
cy.checkLink('/auth/register', 'Get started');
});

it('our free services section', () => {
cy.get('h2').should('contain', 'Our free services');

cy.checkImage('coursesIcon', 'icon_courses');
cy.get('h3').should('contain', 'Online video courses');
cy.checkLink('/courses', '');

cy.checkImage('chatIcon', 'icon_chat');
cy.get('h3').should('contain', '1-to-1 Messaging');
cy.checkLink('/chat', '');

cy.checkImage('activityIcon', 'icon_activities');
cy.get('h3').should('contain', 'Reflective activities');
cy.checkLink('/activities', '');

cy.checkImage('groundingIcon', 'icon_grounding');
cy.get('h3').should('contain', 'Guided grounding activities');
cy.checkLink('/grounding', '');

cy.checkImage('notesIcon', 'icon_notes');
cy.get('h3').should('contain', 'Notes: Whatsapp messages from us');
cy.checkLink('/subscription/whatsapp', '');

cy.checkLink('/auth/register', 'Get started');
});

it('why bloom section', () => {
cy.get('h2').should('contain', 'Why Bloom?');
cy.get('p').should('contain', 'Bloom is here for you, whoever and wherever you are.');

cy.checkImage('pinkHeartWhiteBackground', 'pinkheartwhitebackground');
cy.get('h3').should('contain', 'Free and Anonymous');

cy.checkImage('pinkPlayPauseWhiteBackground', 'pinkplaypausewhitebackground');
cy.get('h3').should('contain', 'Explore at your own pace');

cy.checkImage('pinkGlobeWhiteBackground', 'pinkglobewhitebackground');
cy.get('h3').should('contain', 'Multilingual');
});

it('our bloom team section', () => {
cy.get('h2').should('contain', 'Our Bloom Team');

cy.checkImage('spanish_team', 'spanish_team');
cy.get('h3').should('contain', 'Spanish');

cy.checkImage('hindi_team', 'hindi_team');
cy.get('h3').should('contain', 'Hindi');

cy.checkImage('french_team', 'french_team');
cy.get('h3').should('contain', 'French');

cy.checkImage('english_team', 'english_team');
cy.get('h3').should('contain', 'English');

cy.checkImage('portuguese_team', 'portuguese_team');
cy.get('h3').should('contain', 'Portuguese');

cy.checkImage('bloom_german', 'bloom_german-presenters');
cy.get('h3').should('contain', 'German');

cy.checkLink('/meet-the-team', 'Meet the team');
});

it('our themes section', () => {
cy.get('h2').should('contain', 'Our themes');
cy.checkImage('leaves with fire', 'leaf_mix_fire');

const themes = [
'Guilt and Shame',
'Positive coping mechanism',
'Myths of the Patriarchy',
'Sex after assault',
'Emotional boundaries',
'Image-based abuse',
];
themes.forEach((theme) => {
cy.get('p').contains(theme).parents('a[href="/courses"]').should('exist');
});

cy.checkLink('/auth/register', 'Get started');
});

it('testimonial section', () => {
cy.checkImage('blue_person_tea', 'blue_person_with_tea');
cy.get('blockquote').should(
'contain',
'It has brought so much clarity to my past experiences, putting words, labels, researched proof to what I didn’t know how to explain or process, I just knew the feelings.',
);

cy.checkImage('Illustration of a person sitting, holding a tea', 'illustration_person4_peach');
cy.get('blockquote').should(
'contain',
`Bloom has been a great experience for me. The course has made me reflect a lot on what it means to "work on yourself" and how that looks like. And through Bloom, I've realized that working on yourself is similar to school or hobbies - it takes commitment, time, and studying. This course is anonymous, accessible, and time sensitive - I think it gives grace to all participants who need that time, space, and encouragement to get through the sessions.`,
);
});
});
Loading

0 comments on commit a4df2a5

Please sign in to comment.