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

Feature/share buttons #140

Merged
merged 8 commits into from
Mar 1, 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
5 changes: 4 additions & 1 deletion cypress/e2e/OutcomeFlow/outcome.cy.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if combining multiple things in a test is a good idea. For now just a generalized comment. Nothing to change I don't think. But I was wondering how you might use before (which could run the steps to get to the outcome page) and then have individual tests for each of the cases you want to test. Not sure that's how that feature works lol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely don't want to run the same flow multiple times to test different things. So I'm not sure that which I thought of works where it only runs the test once up to the outcome page, but maybe something to look into?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We should have a few full-flow tests from beginning to end, but I don't want one test to end up testing 15 things working on the outcome page.

I think now that we have outcome pages we could visit the URL /outcome/48fc3ad8-ecc4-4a53-a07b-2cd136a59959 as the first step of the cypress test. We don't need to go through the whole flow for certain things like the share button.

Merging this for now but any further outcome page tests we should consider just navigating directly to a known existing outcome.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('Outcome Page', () => {
it('XM Cloud should be the only product', () => {
it('XM Cloud should be the only product and share button exists', () => {
cy.visit('/');
cy.get('#start').click();
cy.get('[value="Developer"]').click();
Expand All @@ -16,6 +16,9 @@ describe('Outcome Page', () => {
cy.get('.chakra-modal__close-btn').click();
cy.get('#required-products').should('exist').children().should('have.length', 1);
cy.get('#required-products').children().should('contain', 'XM Cloud');
cy.get('#shareButton').click();
cy.get('header').contains('Share Your Migration Advisor Results').should('exist');

});

it('multiple required products', () => {
Expand Down
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"react-hook-form": "^7.47.0",
"react-icons": "4.8.0",
"react-lite-youtube-embed": "^2.3.52",
"react-share": "^5.1.0",
"typescript": "^4.9.5",
"uuid": "^9.0.1",
"web-vitals": "^2.1.4"
Expand Down
14 changes: 10 additions & 4 deletions src/components/Outcomes/OutcomeGenerator/OutcomeGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@ import {
AccordionPanel,
Box,
Heading,
Button,
SimpleGrid,
HStack,
Text,
} from '@chakra-ui/react';
import { useGameInfoContext } from 'components/Contexts';
import { ConditionalResponse } from 'components/Outcomes';
import { LinkCard, Loading, RichTextOutput, YouTubeVideoDisplay } from 'components/ui';
import ShareModal from 'components/ui/ShareModal/ShareModal';
import { OutcomeService } from 'lib/OutcomeService';
import { IOutcome } from 'models';
import { ExperienceEdgeOption, OutcomeConditions, TargetProduct } from 'models/OutcomeConditions';
import { FC, useCallback, useEffect, useState } from 'react';

interface OutcomeGeneratorProps {}
interface OutcomeGeneratorProps { }

export const OutcomeGenerator: FC<OutcomeGeneratorProps> = () => {
const gameInfoContext = useGameInfoContext();
Expand Down Expand Up @@ -69,9 +72,12 @@ export const OutcomeGenerator: FC<OutcomeGeneratorProps> = () => {

return (
<>
<Heading size="lg" mb={2}>
{outcome.title}
</Heading>
<HStack justify={'space-between'}>
<Heading size="lg" mb={2}>
{outcome.title}
</Heading>
<ShareModal />
</HStack>

<Text>
<RichTextOutput content={outcome.productsIntro} />
Expand Down
79 changes: 79 additions & 0 deletions src/components/ui/ShareModal/ShareModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react'
import { useRouter } from 'next/router'
import { Button, HStack, Input, Modal, ModalBody, ModalCloseButton, ModalContent, ModalHeader, ModalOverlay, useDisclosure, useClipboard } from '@chakra-ui/react';
import { XIcon, TwitterShareButton, LinkedinIcon, LinkedinShareButton, EmailShareButton, EmailIcon, WhatsappShareButton, TelegramShareButton, RedditShareButton, WhatsappIcon, TelegramIcon, RedditIcon } from "react-share";
import { MdContentCopy } from "react-icons/md";

const shareText = "I just completed the Sitecore Migration Advisor assessment and got my migration resources. Check it out!"

export default function ShareModal() {
const { isOpen, onOpen, onClose } = useDisclosure()

const router = useRouter()

let shareUrl = ''
if (typeof window !== 'undefined') {
shareUrl = window.location.origin + router.asPath;
}
const { onCopy, value, setValue, hasCopied } = useClipboard(shareUrl);

return (
<div>
<Button id='shareButton' onClick={onOpen}>Share</Button>

<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Share Your Migration Advisor Results</ModalHeader>
<ModalCloseButton />
<ModalBody mb={2}>
<HStack mb={2} justifyContent={'center'} gap={4} >
<WhatsappShareButton
url={shareUrl}
title={shareText}>
<WhatsappIcon size={32} round={true} />
</WhatsappShareButton>
<TelegramShareButton
url={shareUrl}
title={shareText}>
<TelegramIcon size={32} round={true} />
</TelegramShareButton>
<RedditShareButton
url={shareUrl}
title={shareText}>
<RedditIcon size={32} round={true} />
</RedditShareButton>
<EmailShareButton
url={shareUrl}
subject='Sitecore Migration Advisor Results'
body={shareText}>
<EmailIcon size={32} round={true} />
</EmailShareButton>
<LinkedinShareButton
url={shareUrl}
title={shareText}>
<LinkedinIcon size={32} round={true} />
</LinkedinShareButton>
<TwitterShareButton
url={shareUrl}
title={shareText}>
<XIcon size={32} round={true} />
</TwitterShareButton>
</HStack>
<HStack>
<Input
value={shareUrl}
contentEditable={false}
onChange={(e) => {
setValue(e.target.value);
}}
mr={2}
/>
<Button whiteSpace={'nowrap'} onClick={onCopy}><MdContentCopy /></Button>
</HStack>
</ModalBody>
</ModalContent>
</Modal>
</div >
)
}
Loading