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

Change content source #123

Merged
merged 23 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b087319
Initial refactor to new content model
jst-cyr Dec 8, 2023
f299b07
Remove console write
jst-cyr Dec 8, 2023
bd4ff2b
Adding new handling for when no themes are returned by the app
jst-cyr Dec 8, 2023
60d032d
Fixing reference to 'allTheme' property
jst-cyr Dec 8, 2023
75793bd
Fixing name of query property
jst-cyr Dec 8, 2023
44df6ee
Fixing references to gameOutcome
jst-cyr Dec 8, 2023
09785de
Fixing the OutcomeReason GraphQL type to match with expected type fro…
jst-cyr Dec 8, 2023
dc4757f
Removing console output of personas and avatars
jst-cyr Dec 8, 2023
b2b6c6b
Fixing persona property name in service
jst-cyr Dec 8, 2023
f95cf44
Fixing field IDs in Prompts query
jst-cyr Dec 8, 2023
367b212
Fixing test to not assume order of the persona buttons.
jst-cyr Dec 8, 2023
925f6e6
Fixing second test to also explicitly select the Developer persona
jst-cyr Dec 8, 2023
c3da9be
Cypress test: Fixing value of Developer button
jst-cyr Dec 8, 2023
5a67f11
Fixing reading of Question ID from Prompt
jst-cyr Dec 8, 2023
ecbc37f
Fixing another reference to prompt "questionid" with lowercase.
jst-cyr Dec 8, 2023
cbb60ae
Updating Cypress Tests to use the new v2 API key for running tests
jst-cyr Dec 8, 2023
09f225c
Merge branch 'main' into change-content-source
jst-cyr Dec 11, 2023
dd6aee8
Merge branch 'main' into change-content-source
jst-cyr Dec 11, 2023
e614bcd
Merge branch 'main' into change-content-source
jst-cyr Dec 11, 2023
75374b9
Updating interface IPrompt to match with new schema for question field
jst-cyr Dec 12, 2023
5d3e688
Fixing minor typo in a comment.
jst-cyr Dec 12, 2023
3398b52
Merge branch 'main' into change-content-source
jst-cyr Dec 12, 2023
45bde99
Rolling back to original Secret variable
jst-cyr Dec 12, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
component: true
env:
SITECORE_CH1_ENDPOINT_URL: ${{ secrets.SITECORE_CH1_ENDPOINT_URL }}
SITECORE_CH1_CLIENT_KEY: ${{ secrets.SITECORE_CH1_CLIENT_KEY }}
SITECORE_CH1_CLIENT_KEY: ${{ secrets.SITECORE_CH1_CLIENT_KEY_v2 }}
NEXT_PUBLIC_EMAIL_FORM_ENDPOINT: ${{ secrets.NEXT_PUBLIC_EMAIL_FORM_ENDPOINT }}


2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ jobs:
wait-on: "http://localhost:3000"
env:
SITECORE_CH1_ENDPOINT_URL: ${{ secrets.SITECORE_CH1_ENDPOINT_URL }}
SITECORE_CH1_CLIENT_KEY: ${{ secrets.SITECORE_CH1_CLIENT_KEY }}
SITECORE_CH1_CLIENT_KEY: ${{ secrets.SITECORE_CH1_CLIENT_KEY_v2 }}
4 changes: 2 additions & 2 deletions cypress/e2e/OutcomeFlow/outcome.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ describe('Outcome Page', () => {
it('XM Cloud should be the only product', () => {
cy.visit('/');
cy.get('#start').click();
cy.get('.css-1izj7gt > :nth-child(4)').click();
cy.get('[value="Developer"]').click();
cy.get(':nth-child(9) > .chakra-button').click();
cy.get('.chakra-container > :nth-child(3) > .chakra-button').click();
cy.get('[value="xm"]').click();
Expand All @@ -22,7 +22,7 @@ describe('Outcome Page', () => {
cy.visit('/');
cy.get('#start').click();
cy.get(':nth-child(11) > .chakra-button').click();
cy.get('.css-1izj7gt > :nth-child(2)').click();
cy.get('[value="Developer"]').click();
cy.get('.chakra-container > :nth-child(3) > .chakra-button').click();
cy.get('[value="xp"]').click();
cy.get('[value="sessionpersonalization"]').click();
Expand Down
4 changes: 2 additions & 2 deletions cypress/fixtures/themes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "a5F4KpHzIkO1Re9iHmJjWA",
"name": "Fantasy Adventure",
"description": "Migrations can be fun! Take a journey through the fantasy world of the 5th Age. You will be guided through a maze of challenges that will help you find the scroll of Sitecore migration that will guide you and your party to saving the realm!",
"characterImage": {
"image": {
"results": [
{
"id": "vMw9EsLFnkuUk7bATvTOJQ",
Expand All @@ -22,4 +22,4 @@
]
}
}
]
]
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Outcome.gql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
fragment OutcomeDetails on GameOutcome {
fragment OutcomeDetails on Outcome {
id
name
themes {
results {
... on GameTheme {
... on Theme {
id
name
}
Expand All @@ -13,7 +13,7 @@ fragment OutcomeDetails on GameOutcome {
productsIntro
outcomeReasons {
results {
... on GameOutcomeReason {
... on Outcomereason {
product
reason
}
Expand All @@ -34,15 +34,15 @@ fragment OutcomeDetails on GameOutcome {
}

query GetOutcomeByThemeIdQuery($id: ID!) {
allGameOutcome(where: { themes: { gameOutcome_ids: $id } }) {
allOutcome(where: { themes: { outcome_ids: $id } }) {
results {
...OutcomeDetails
}
}
}

query GetOutcomeByIdQuery($id: String!) {
gameOutcome(id: $id) {
outcome(id: $id) {
...OutcomeDetails
}
}
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Personas.gql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fragment PersonaFragment on GamePersona {
fragment PersonaFragment on Persona {
id
name
personaImage {
Expand All @@ -10,7 +10,7 @@ fragment PersonaFragment on GamePersona {
}
theme {
results {
... on GameTheme {
... on Theme {
id
name
}
Expand All @@ -19,21 +19,21 @@ fragment PersonaFragment on GamePersona {
}

query GetAllPersonasQuery {
allGamePersona {
allPersona {
results {
...PersonaFragment
}
}
}

query GetPersonaByIdQuery($id: String!) {
gamePersona(id: $id) {
persona(id: $id) {
...PersonaFragment
}
}

query GetPersonasByThemeIdQuery($id: ID!) {
allGamePersona(where: { theme: { gamePersona_ids: $id } }) {
allPersona(where: { theme: { persona_ids: $id } }) {
results {
...PersonaFragment
}
Expand Down
10 changes: 5 additions & 5 deletions src/GraphQL/Queries/Prompts.gql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
fragment PromptDetails on Prompt {
id
name
questionid
text
questionId
question
bodyText
theme {
results {
__typename
... on GameTheme {
... on Theme {
id
}
}
Expand All @@ -21,14 +21,14 @@ fragment PromptDetails on Prompt {
}
persona {
results {
... on GamePersona {
... on Persona {
id
}
}
}
optionType {
results {
... on PromptOptionTypes {
... on PromptOptionType {
id
name
}
Expand Down
12 changes: 6 additions & 6 deletions src/GraphQL/Queries/Themes.gql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
fragment Theme on GameTheme {
fragment ThemeFragment on Theme {
id
name
description
chakraTheme
startButtonText
disabled
characterImage {
image {
results {
id
fileUrl
Expand All @@ -22,15 +22,15 @@ fragment Theme on GameTheme {
}

query GetAllThemesQuery {
allGameTheme {
allTheme {
results {
...Theme
...ThemeFragment
}
}
}

query GetThemesByIdQuery($id: String!) {
gameTheme(id: $id) {
...Theme
theme(id: $id) {
...ThemeFragment
}
}
10 changes: 5 additions & 5 deletions src/components/Prompts/CurrentPrompt/CurrentPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {

let answer: IAnswer = {
promptId: prompt!.id,
promptQuestionId: prompt!.questionid,
prompt: prompt!.text,
promptQuestionId: prompt!.questionId,
prompt: prompt!.question,
value: new Array(option.value),
valuePrettyText: new Array(option.label),
};
Expand All @@ -32,8 +32,8 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {
const multiSelectSubmit = (selectedOptions: IOption[]) => {
let answer: IAnswer = {
promptId: prompt!.id,
promptQuestionId: prompt!.questionid,
prompt: prompt!.text,
promptQuestionId: prompt!.questionId,
prompt: prompt!.question,
value: selectedOptions.map((o) => o.value),
valuePrettyText: selectedOptions.map((o) => o.label),
};
Expand Down Expand Up @@ -67,7 +67,7 @@ export const CurrentPrompt: FC<PromptProps> = ({ prompt, answerSelected }) => {
paddingLeft={{ base: '15px', md: '15px' }}
paddingRight={{ base: '15px', md: '15px' }}
>
{prompt?.text}
{prompt?.question}
</Text>
</CardBody>
<CardFooter padding={'15px'}>
Expand Down
3 changes: 0 additions & 3 deletions src/components/ui/ChooseCharacterDisplay/ChooseCharacter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ export const ChooseCharacter: FC<ChooseCharacterProps> = ({ avatars, personas })
router.push('/prompt');
};

console.log('Personas', personas);
console.log('Avatars', avatars);

return (
<>
<PersonaList
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/InfoBar/InfoBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const InfoBar: FC<InfoBarProps> = ({ remainingQuestions, isSolution = fal
)}
</GridItem>
<GridItem colSpan={6}>
{gameInfoContext.theme?.characterImage?.results !== undefined && (
{gameInfoContext.theme?.image?.results !== undefined && (
<AvatarGroup spacing="xs">
<Avatar
size={'xl'}
src={gameInfoContext.theme.characterImage!.results[0].fileUrl}
title={gameInfoContext.theme.characterImage!.results[0].fileName ?? ''}
src={gameInfoContext.theme.image!.results[0].fileUrl}
title={gameInfoContext.theme.image!.results[0].fileName ?? ''}
/>
<div style={{ flex: 1 }}>
<Text>{gameInfoContext.theme.name}</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/ui/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const Settings: FC<SettingsProps> = () => {

if (themes && themes.length > 0) {
setThemes(themes);
} else {
throw new Error('No themes loaded. At least one theme is required.');
}

setLoading(false);
Expand Down
18 changes: 4 additions & 14 deletions src/components/ui/ThemeList/ThemeList.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
import {
Box,
Button,
Center,
Flex,
Heading,
Image,
Stack,
Text,
useColorModeValue
} from '@chakra-ui/react';
import { Box, Button, Center, Flex, Heading, Image, Stack, Text, useColorModeValue } from '@chakra-ui/react';
import { ITheme } from 'models';
import { FC } from 'react';

Expand Down Expand Up @@ -47,10 +37,10 @@ export const ThemeList: FC<ThemeListProps> = ({ themes, handleThemeChange, class
height={'100%'}
bg={useColorModeValue('white', 'gray.800')}
>
{theme.characterImage?.results !== undefined && (
{theme.image?.results !== undefined && (
<Image
src={theme.characterImage!.results[0].fileUrl}
alt={theme.characterImage!.results[0].fileName ?? ''}
src={theme.image!.results[0].fileUrl}
alt={theme.image!.results[0].fileName ?? ''}
maxHeight={['0', '300px']}
fit={'cover'}
rounded={['sm', 'lg']}
Expand Down
8 changes: 4 additions & 4 deletions src/lib/OutcomeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { GetOutcomeByIdQuery, GetOutcomeByThemeIdQuery } from '../GraphQL/Querie
import { chOneService } from './CHOneService';

export const OutcomeService = () => {
const GetOutcomeById = async (gameOutcomeId: string): Promise<IOutcome | undefined> => {
const GetOutcomeById = async (outcomeId: string): Promise<IOutcome | undefined> => {
const { error, data } = await chOneService().query({
query: GetOutcomeByIdQuery,
variables: { id: gameOutcomeId },
variables: { id: outcomeId },
});

if (error) {
console.log(error);
return undefined;
}

const results = data?.gameOutcome as IOutcome;
const results = data?.outcome as IOutcome;

return results;
};
Expand All @@ -31,7 +31,7 @@ export const OutcomeService = () => {
return undefined;
}

const results = data?.allGameOutcome as IResult<IOutcome[]>;
const results = data?.allOutcome as IResult<IOutcome[]>;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/PersonaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PersonaService = () => {
return undefined;
}

const results = data?.gamePersona as IPersona;
const results = data?.persona as IPersona;

return results;
};
Expand All @@ -28,7 +28,7 @@ export const PersonaService = () => {
return undefined;
}

const results = data?.allGamePersona as IResult<IPersona[]>;
const results = data?.allPersona as IResult<IPersona[]>;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ThemeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ThemeService = () => {
return null;
}

const results = data?.allGameTheme as IResult<ITheme[]>;
const results = data?.allTheme as IResult<ITheme[]>;

return results;
};
Expand All @@ -24,7 +24,7 @@ export const ThemeService = () => {
return undefined;
}

const results = data?.gameTheme as ITheme;
const results = data?.theme as ITheme;

return results;
};
Expand Down
4 changes: 2 additions & 2 deletions src/models/IPrompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { JSONContent } from '@tiptap/core';
import { IImage, IOption, IOptionType, IPersona, IResult, ITheme } from 'models';

export interface IPrompt {
text: string;
question: string;
bodyText?: JSONContent;
id: string;
name: string;
questionid: string;
questionId: string;
options?: IResult<IOption[]>;
optionType: IResult<IOptionType[]>;
nextPrompts?: IResult<IPrompt[]>; // If prompt requires additional prompts, this is the list of prompt ids
Expand Down
2 changes: 1 addition & 1 deletion src/models/ITheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface ITheme {
name: string;
description: string;
id: string;
characterImage?: IResult<IImage[]>;
image?: IResult<IImage[]>;
avatarGallery?: IResult<IImage[]>;
chakraTheme: string;
startButtonText: string;
Expand Down
2 changes: 1 addition & 1 deletion src/models/OutcomeConditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export class OutcomeConditions {
}

/**
* Analyzes current answers to determine if this is a complex personalizations cenario
* Analyzes current answers to determine if this is a complex personalization scenario
* that would require Sitecore Personalize or CDP
*/
isComplexPersonalization(): boolean {
Expand Down
Loading