Skip to content

Commit

Permalink
Merge pull request #537 from chaynHQ/develop
Browse files Browse the repository at this point in the history
Merge Develop onto Main
  • Loading branch information
swetha-charles committed Jun 22, 2023
2 parents 487a9ec + 02dea5a commit f3d0505
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/cypress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ jobs:
CYPRESS_badoo_partner_admin_password: ${{secrets.CYPRESS_TEST_ACCOUNT_PASSWORD}}
CYPRESS_super_admin_email: ${{secrets.CYPRESS_SUPER_ADMIN_EMAIL}}
CYPRESS_super_admin_password: ${{secrets.CYPRESS_TEST_ACCOUNT_PASSWORD}}
CYPRESS_public_email: ${{secrets.CYPRESS_PUBLIC_EMAIL}}
CYPRESS_public_password: ${{secrets.CYPRESS_PUBLIC_PASSWORD}}
CYPRESS_api_url: ${{secrets.CYPRESS_BLOOM_BACKEND_API_URL}}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions components/forms/CreateAccessCodeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const CreateAccessCodeForm = () => {

if (!selectedTier) {
setFormError(t('form.errors.featureRequired'));
setLoading(false);
return;
}

Expand Down
13 changes: 8 additions & 5 deletions components/session/MultipleBonusContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LinkIcon from '@mui/icons-material/Link';
import { useTranslations } from 'next-intl';
import { StoryData } from 'storyblok-js-client';
import { render } from 'storyblok-rich-text-react-renderer';
import SessionDetail from '../../pages/courses/image-based-abuse/[sessionSlug]';
Expand All @@ -11,6 +10,12 @@ import { Dots } from '../common/Dots';
* This React component is used to render storyblok component "Bonus Block".
* This is currently used in the following session page: {@link SessionDetail}
*/

type BonusContent = {
_uid: string;
title: string;
content: unknown;
};
interface MultipleBonusContentProps {
story: StoryData;
eventData: { [index: string]: any };
Expand All @@ -19,15 +24,13 @@ interface MultipleBonusContentProps {
const MultipleBonusContent = (props: MultipleBonusContentProps) => {
const { story, eventData } = props;

const t = useTranslations('Courses');

return (
<>
<Dots />
{story.content.bonus.map((bonus: any) => (
{story.content.bonus.map((bonus: BonusContent) => (
<SessionContentCard
key={bonus._uid}
title={t('sessionDetail.bonusTitle')}
title={bonus.title}
titleIcon={LinkIcon}
richtextContent
eventPrefix="SESSION_BONUS_CONTENT"
Expand Down
51 changes: 51 additions & 0 deletions cypress/integration/user-course-session-behaviour.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
describe('A logged in user should be able to navigate to a course session and complete it', () => {
const newUserEmail = `cypresstestemail+${Date.now()}@chayn.co`;
const password = 'testpassword';

before(() => {
cy.cleanUpTestState();

cy.createUser({
//create test user
emailInput: newUserEmail,
passwordInput: password,
});
});

it('Should go to courses page and select a course & session', () => {
cy.logInWithEmailAndPassword(newUserEmail, password); //log in to test user

cy.get(`[qa-id=secondary-nav-courses-button]`).should('exist').click(); //navigate to courses

cy.get('a[href*="healing-from-sexual-trauma"]', {
timeout: 4000,
})
.first()
.click(); //click on a course when link load

// cy.getIframeBody().find('button').click(); Attempting to watch the session video. iframe isnt working at the moment

cy.get('a[href*="what-is-sexual-trauma"]', {
timeout: 4000,
})
.first()
.click(); //click on a session when link loads
});

it('Should read activity & bonus content and complete session', () => {
cy.visit('/courses/healing-from-sexual-trauma/what-is-sexual-trauma');
cy.wait(5000);

cy.get('h3').contains('Activity').click(); //open activities

cy.get('h3').contains('Bonus content').click(); //open bonus content

cy.get('button').contains('Session complete').click(); //mark course as complete

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

after(() => {
cy.logout();
});
});
18 changes: 17 additions & 1 deletion cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Cypress.Commands.add('createAccessCode', (accessCode) => {

Cypress.Commands.add('deleteUser', () => {
cy.getAuthEmail().then((email) => {
if (email && email.indexOf('cypress') > 0) {
if (email && email.indexOf('cypress') >= 0) {
cy.getAccessToken().then((token) => {
cy.request({
url: `${Cypress.env('api_url')}/user`,
Expand All @@ -84,6 +84,7 @@ Cypress.Commands.add('deleteUser', () => {
}
});
});

Cypress.Commands.add('createUser', ({ codeInput, emailInput, passwordInput, partnerId }) => {
cy.request({
url: `${Cypress.env('api_url')}/user`,
Expand Down Expand Up @@ -173,6 +174,21 @@ const attachCustomCommands = (Cypress, { auth }) => {
}
});
});

//Function to grab iframe needs some work. At the moment it can't see the inner content.
//This will help with test to watch session videos
Cypress.Commands.add('getIframeBody', () => {
return (
cy
.get('iframe')
.its('0.contentDocument')
.should('exist')
// automatically retries until body is loaded
.its('body')
.should('not.be.undefined')
.then(cy.wrap)
);
});
};

attachCustomCommands(Cypress, firebase);
2 changes: 1 addition & 1 deletion cypress/support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ declare namespace Cypress {
partnerId?: string;
}): Chainable<Element>;

deleteUser(email: string): Chainable<Element>;
deleteUser(): Chainable<Element>;
deleteAccessCode(): Chainable<Element>;
getAccessCode(): Chainable<Element>;
getAuthEmail(): Chainable<Element>;
Expand Down

0 comments on commit f3d0505

Please sign in to comment.