Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into test/chat-panel-stories
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext committed Dec 3, 2024
2 parents 31e11f9 + d40af98 commit a15d9a5
Show file tree
Hide file tree
Showing 34 changed files with 526 additions and 207 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,15 @@ jobs:
inject-env-vars: true

- name: Run tests
run: pnpm turbo test --cache-dir=".turbo" -- --maxWorkers=33%
run: pnpm turbo test --cache-dir=".turbo" -- --maxWorkers=33% --coverage

# Run only on production branch
- name: Report coverage to SonarCloud
if: ${{ github.event.pull_request.merged == true && github.base_ref == 'production' }}
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.javascript.lcov.reportPaths=packages/**/coverage/lcov.info,apps/nextjs/coverage/lcov.info
24 changes: 24 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## [1.17.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.17.0...v1.17.1) (2024-12-03)


### Bug Fixes

* add linting command to db package ([#392](https://github.com/oaknational/oak-ai-lesson-assistant/issues/392)) ([d2177d5](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d2177d5c061e973affd1ea52b0ef025c8c37cb29))
* address sonar major issues ([#393](https://github.com/oaknational/oak-ai-lesson-assistant/issues/393)) ([202a21f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/202a21fbac0d457514c9944735b174c79dced08c))
* do not define components inline ([#413](https://github.com/oaknational/oak-ai-lesson-assistant/issues/413)) ([abda175](https://github.com/oaknational/oak-ai-lesson-assistant/commit/abda1753afecd9385b19b695767568abdd4383c1))
* do not use array index for key / use void for onSubmit ([#409](https://github.com/oaknational/oak-ai-lesson-assistant/issues/409)) ([44b5961](https://github.com/oaknational/oak-ai-lesson-assistant/commit/44b59617f3af8cad83110efdc2cb4df23d06e073))
* help page cloudflare email ([#399](https://github.com/oaknational/oak-ai-lesson-assistant/issues/399)) ([f6262f2](https://github.com/oaknational/oak-ai-lesson-assistant/commit/f6262f26d470a30ea721343bbab2cbfded77b91d))
* high and medium severity bugs on sonar cloud - AI-637 ([#379](https://github.com/oaknational/oak-ai-lesson-assistant/issues/379)) ([fb0258e](https://github.com/oaknational/oak-ai-lesson-assistant/commit/fb0258ec2f3c0d5fb79d884d3918827460cba404))
* icons in dialogs ([#398](https://github.com/oaknational/oak-ai-lesson-assistant/issues/398)) ([9700214](https://github.com/oaknational/oak-ai-lesson-assistant/commit/970021462a94b800dba270130f5ba1b1548e8745))
* intentionality of async / promise code for question generation ([#402](https://github.com/oaknational/oak-ai-lesson-assistant/issues/402)) ([65d1c5f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/65d1c5f89c1b238e24315c02bde2e9eb253b4da3))
* memoize the sidebar context provider's value ([#408](https://github.com/oaknational/oak-ai-lesson-assistant/issues/408)) ([60ee010](https://github.com/oaknational/oak-ai-lesson-assistant/commit/60ee0102ea1ee733d6527c5460fd404cd7773292))
* minor sonar issues ([#390](https://github.com/oaknational/oak-ai-lesson-assistant/issues/390)) ([015cd25](https://github.com/oaknational/oak-ai-lesson-assistant/commit/015cd25984c3e5d1a545afef39fd111aa5245d58))
* prefer nullish coalescing ([#391](https://github.com/oaknational/oak-ai-lesson-assistant/issues/391)) ([b40def9](https://github.com/oaknational/oak-ai-lesson-assistant/commit/b40def9cfd3d69a0089db861a2f6ed47321a3753))
* readonly props for icons.tsx ([#389](https://github.com/oaknational/oak-ai-lesson-assistant/issues/389)) ([7b4d5bc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/7b4d5bcc508b3179ea5313ec783aba90d1a7f3ae))
* revert tabindex change ([#404](https://github.com/oaknational/oak-ai-lesson-assistant/issues/404)) ([ac72713](https://github.com/oaknational/oak-ai-lesson-assistant/commit/ac72713dc54595f6bfacfd99e63899616f18b8ec))
* sonar maintain issues [#4](https://github.com/oaknational/oak-ai-lesson-assistant/issues/4) ([#405](https://github.com/oaknational/oak-ai-lesson-assistant/issues/405)) ([eca0019](https://github.com/oaknational/oak-ai-lesson-assistant/commit/eca001996a684f8d01465196c1c600d00e43a964))
* sonar maintain linting [#1](https://github.com/oaknational/oak-ai-lesson-assistant/issues/1) ([#394](https://github.com/oaknational/oak-ai-lesson-assistant/issues/394)) ([f4d95fc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/f4d95fcbf39c3c43c3811f8c2022a37af363826a))
* sonar maintain linting [#2](https://github.com/oaknational/oak-ai-lesson-assistant/issues/2) ([#395](https://github.com/oaknational/oak-ai-lesson-assistant/issues/395)) ([1ed9d60](https://github.com/oaknational/oak-ai-lesson-assistant/commit/1ed9d6028713b096a68a0558d67608dc9efb812f))
* sonar maintain linting [#3](https://github.com/oaknational/oak-ai-lesson-assistant/issues/3) ([#403](https://github.com/oaknational/oak-ai-lesson-assistant/issues/403)) ([daa7efe](https://github.com/oaknational/oak-ai-lesson-assistant/commit/daa7efe6a2d5d2501f5108cd3c1ccaec86126655))
* sonar minors [#5](https://github.com/oaknational/oak-ai-lesson-assistant/issues/5) ([#414](https://github.com/oaknational/oak-ai-lesson-assistant/issues/414)) ([5f749f4](https://github.com/oaknational/oak-ai-lesson-assistant/commit/5f749f42f9f5d3d78c736438e313f4f5eff5406b))

# [1.17.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.16.2...v1.17.0) (2024-11-28)


Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const config = {
{
tsconfig: "tsconfig.test.json",
useESM: true,
isolatedModules: true,
},
],
"^.+\\.svg$": "<rootDir>/jest.svgTransform.js",
Expand All @@ -30,6 +31,7 @@ const config = {
rootDir: ".",
resetMocks: true,
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"],
collectCoverageFrom: ["src/**/*.{ts,tsx,js,jsx}"],
collectCoverage:
process.env.CI === "true" || process.env.COLLECT_TEST_COVERAGE === "true",
coverageReporters: ["lcov", "text"],
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ChatLeftHandSide = ({
setShowLessonMobile={setShowLessonMobile}
showLessonMobile={showLessonMobile}
isDemoUser={isDemoUser}
showStreamingStatus={process.env.NEXT_PUBLIC_ENVIRONMENT !== "prd"}
/>
<div>
<ChatPanelArea chatAreaRef={chatAreaRef} isDemoLocked={isDemoLocked}>
Expand All @@ -48,9 +49,7 @@ const ChatLeftHandSide = ({
demo={demo}
/>
</ChatPanelArea>
{!isDemoLocked && (
<QuickActionButtons isEmptyScreen={!!messages.length} />
)}
{!isDemoLocked && <QuickActionButtons />}
</div>
<ChatPanel isDemoLocked={isDemoLocked} />
<span className="absolute right-0 top-[-70px] z-10 hidden h-[calc(100vh+100px)] w-3 bg-black sm:block" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Meta, StoryObj } from "@storybook/react";

import {
ChatContext,
type ChatContextProps,
} from "@/components/ContextProviders/ChatProvider";

import ChatLhsHeader from "./chat-lhs-header";

const ChatDecorator: Story["decorators"] = (Story, { parameters }) => (
<ChatContext.Provider
value={
{
ailaStreamingStatus: "Idle",
...parameters.chatContext,
} as unknown as ChatContextProps
}
>
<Story />
</ChatContext.Provider>
);

const meta: Meta<typeof ChatLhsHeader> = {
title: "Components/Chat/ChatLhsHeader",
component: ChatLhsHeader,
tags: ["autodocs"],
decorators: [ChatDecorator],
args: {
showStreamingStatus: false,
},
};

export default meta;
type Story = StoryObj<typeof ChatLhsHeader>;

export const Default: Story = {
args: {},
};

export const NonProdStreamingStatus: Story = {
args: {
showStreamingStatus: true,
},
parameters: {
chatContext: {
ailaStreamingStatus: "StreamingLessonPlan",
},
},
};

export const DemoBannerPadding: Story = {
args: {
isDemoUser: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ type ChatLhsHeaderProps = {
setShowLessonMobile: (value: boolean) => void;
showLessonMobile: boolean;
isDemoUser: boolean;
showStreamingStatus: boolean;
};

const ChatLhsHeader = ({
setShowLessonMobile,
showLessonMobile,
isDemoUser,
showStreamingStatus,
}: Readonly<ChatLhsHeaderProps>) => {
const router = useRouter();
const chat = useLessonChat();
return (
<>
<div className="mt-6 hidden items-center justify-end gap-5 sm:flex">
{process.env.NEXT_PUBLIC_ENVIRONMENT !== "prd" && (
{showStreamingStatus && (
<div className="flex flex-grow flex-row space-x-4 text-left text-xs">
<div data-testid="chat-aila-streaming-status">
{chat.ailaStreamingStatus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function ChatPanel({ isDemoLocked }: Readonly<ChatPanelProps>) {
const chat = useLessonChat();
const {
id,
messages,
isLoading,
messages,
input,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import type { Meta, StoryObj } from "@storybook/react";

import {
ChatContext,
type ChatContextProps,
} from "@/components/ContextProviders/ChatProvider";
import { lessonPlanTrackingContext } from "@/lib/analytics/lessonPlanTrackingContext";

import ChatQuickButtons from "./chat-quick-buttons";

const DummyMessage = {};

const ChatDecorator: Story["decorators"] = (Story, { parameters }) => (
<ChatContext.Provider
value={
{
messages: [DummyMessage],
...parameters.chatContext,
} as unknown as ChatContextProps
}
>
<Story />
</ChatContext.Provider>
);

const LessonPlanTrackingContextDecorator: Story["decorators"] = (Story) => (
<lessonPlanTrackingContext.Provider
value={{
onClickContinue: () => {},
onClickRetry: () => {},
onClickStartFromExample: () => {},
onClickStartFromFreeText: () => {},
onStreamFinished: () => {},
onSubmitText: () => {},
}}
>
<Story />
</lessonPlanTrackingContext.Provider>
);

const meta: Meta<typeof ChatQuickButtons> = {
title: "Components/Chat/ChatQuickButtons",
component: ChatQuickButtons,
tags: ["autodocs"],
decorators: [ChatDecorator, LessonPlanTrackingContextDecorator],
};

export default meta;
type Story = StoryObj<typeof ChatQuickButtons>;

export const Idle: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Idle",
},
},
};

export const Loading: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Loading",
},
},
};

export const LoadingWithoutMessages: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Loading",
messages: [],
},
},
};

export const RequestMade: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "RequestMade",
},
},
};

export const StreamingLessonPlan: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "StreamingLessonPlan",
},
},
};

export const StreamingChatResponse: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "StreamingChatResponse",
},
},
};

export const Moderating: Story = {
args: {},
parameters: {
chatContext: {
ailaStreamingStatus: "Moderating",
},
},
};

export const StreamingWithQueuedUserAction: Story = {
args: {},
parameters: {
chatContext: {
queuedUserAction: "regenerate",
ailaStreamingStatus: "StreamingLessonPlan",
},
},
};

export const ModeratingWithQueuedUserAction: Story = {
args: {},
parameters: {
chatContext: {
queuedUserAction: "regenerate",
ailaStreamingStatus: "Moderating",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ import type { AilaStreamingStatus } from "./Chat/hooks/useAilaStreamingStatus";
import ChatButton from "./ui/chat-button";
import { IconRefresh, IconStop } from "./ui/icons";

export type QuickActionButtonsProps = Readonly<{
isEmptyScreen: boolean;
}>;

const shouldAllowStop = (
ailaStreamingStatus: AilaStreamingStatus,
isEmptyScreen: boolean,
hasMessages: boolean,
queuedUserAction: string | null,
) => {
if (!isEmptyScreen) {
if (!hasMessages) {
return false;
}

Expand All @@ -43,7 +39,7 @@ const shouldAllowStop = (
return false;
};

const QuickActionButtons = ({ isEmptyScreen }: QuickActionButtonsProps) => {
const QuickActionButtons = () => {
const chat = useLessonChat();
const { trackEvent } = useAnalytics();
const lessonPlanTracking = useLessonPlanTracking();
Expand All @@ -57,6 +53,8 @@ const QuickActionButtons = ({ isEmptyScreen }: QuickActionButtonsProps) => {
queuedUserAction,
} = chat;

const hasMessages = !!messages.length;

const shouldAllowUserAction =
["Idle", "Moderating"].includes(ailaStreamingStatus) && !queuedUserAction;

Expand Down Expand Up @@ -106,7 +104,7 @@ const QuickActionButtons = ({ isEmptyScreen }: QuickActionButtonsProps) => {

{shouldAllowStop(
ailaStreamingStatus,
isEmptyScreen,
hasMessages,
queuedUserAction,
) && (
<ChatButton
Expand Down
15 changes: 15 additions & 0 deletions apps/nextjs/src/components/Onboarding/AcceptTermsForm.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import { AcceptTermsForm } from "./AcceptTermsForm";

const meta: Meta<typeof AcceptTermsForm> = {
title: "Pages/Onboarding/AcceptTermsForm",
component: AcceptTermsForm,
};

export default meta;
type Story = StoryObj<typeof AcceptTermsForm>;

export const Default: Story = {
args: {},
};
3 changes: 2 additions & 1 deletion apps/nextjs/src/components/Onboarding/AcceptTermsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import Link from "next/link";
import Button from "@/components/Button";
import CheckBox from "@/components/CheckBox";
import SignUpSignInLayout from "@/components/SignUpSignInLayout";
import TermsContent from "@/components/TermsContent";
import { trpc } from "@/utils/trpc";

import TermsContent from "./TermsContent";

export const AcceptTermsForm = () => {
const [dropDownOpen, setDropDownOpen] = useState(true);
const { isLoaded } = useUser();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";

import { LegacyUpgradeNotice } from "./LegacyUpgradeNotice";

const meta: Meta<typeof LegacyUpgradeNotice> = {
title: "Pages/Onboarding/LegacyUpgradeNotice",
component: LegacyUpgradeNotice,
};

export default meta;
type Story = StoryObj<typeof LegacyUpgradeNotice>;

export const Default: Story = {
args: {},
};
Loading

0 comments on commit a15d9a5

Please sign in to comment.