-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
356 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
libs/providers/github/src/functions/create-new-question-pr.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
libs/providers/question-bank-local/src/lib/write-local-question-bank.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { trpc } from '@chair-flight/trpc/client'; | ||
import { CssBaseline, CssVarsProvider } from '@mui/joy'; | ||
import { RouterContext } from 'next/dist/shared/lib/router-context'; | ||
import { FunctionComponent, Suspense } from 'react'; | ||
import { mswDecorator } from 'msw-storybook-addon'; | ||
import { theme } from "../theme"; | ||
import { vi } from 'vitest'; | ||
|
||
export const action = vi.fn(); | ||
|
||
export const decorators = [ | ||
(Story: FunctionComponent) => ( | ||
<Suspense fallback="Loading..."> | ||
<Story /> | ||
</Suspense> | ||
), | ||
(Story: FunctionComponent) => ( | ||
<CssVarsProvider theme={theme}> | ||
<CssBaseline /> | ||
<Story /> | ||
</CssVarsProvider> | ||
), | ||
(Story: FunctionComponent, other: any) => ( | ||
<RouterContext.Provider | ||
value={{ | ||
push(...args: unknown[]) { | ||
action('nextRouter.push')(...args); | ||
return Promise.resolve(true); | ||
}, | ||
replace(...args: unknown[]) { | ||
action('nextRouter.replace')(...args); | ||
return Promise.resolve(true); | ||
}, | ||
reload(...args: unknown[]) { | ||
action('nextRouter.reload')(...args); | ||
}, | ||
back(...args: unknown[]) { | ||
action('nextRouter.back')(...args); | ||
}, | ||
forward() { | ||
action('nextRouter.forward')(); | ||
}, | ||
prefetch(...args: unknown[]) { | ||
action('nextRouter.prefetch')(...args); | ||
return Promise.resolve(); | ||
}, | ||
beforePopState(...args: unknown[]) { | ||
action('nextRouter.beforePopState')(...args); | ||
}, | ||
events: { | ||
on(...args: unknown[]) { | ||
action('nextRouter.events.on')(...args); | ||
}, | ||
off(...args: unknown[]) { | ||
action('nextRouter.events.off')(...args); | ||
}, | ||
emit(...args: unknown[]) { | ||
action('nextRouter.events.emit')(...args); | ||
}, | ||
}, | ||
locale: other?.globals?.locale, | ||
route: '/', | ||
asPath: '/', | ||
basePath: '/', | ||
isFallback: false, | ||
isLocaleDomain: false, | ||
isReady: true, | ||
isPreview: false, | ||
pathname: '/', | ||
query: {}, | ||
...other?.parameters.nextjs?.router, | ||
|
||
}} | ||
> | ||
<Story /> | ||
</RouterContext.Provider> | ||
), | ||
(Story: FunctionComponent) => { | ||
const Component = trpc.withTRPC(Story); | ||
return <Component />; | ||
}, | ||
mswDecorator, | ||
]; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as matchers from "@testing-library/jest-dom/matchers"; | ||
import { cleanup } from "@testing-library/react"; | ||
import { afterEach, expect, vi } from "vitest"; | ||
import { initialize } from "msw-storybook-addon"; | ||
|
||
expect.extend(matchers); | ||
|
||
initialize({ | ||
onUnhandledRequest: 'error', | ||
}); | ||
|
||
|
||
beforeAll(() => { | ||
Object.defineProperty(window, 'matchMedia', { | ||
writable: true, | ||
value: vi.fn().mockImplementation(query => ({ | ||
matches: false, | ||
media: query, | ||
onchange: null, | ||
addListener: vi.fn(), // deprecated | ||
removeListener: vi.fn(), // deprecated | ||
addEventListener: vi.fn(), | ||
removeEventListener: vi.fn(), | ||
dispatchEvent: vi.fn(), | ||
})), | ||
}) | ||
}); | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
libs/react/containers/src/questions/question-editor/question-editor.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { composeStories } from '@storybook/react'; | ||
import * as stories from './question-editor.stories'; | ||
import { render, screen, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import { default as userEvent } from '@testing-library/user-event'; | ||
import { decorators } from '../../__tests__/decorators' | ||
import { setupServer } from 'msw/node'; | ||
import { rest } from 'msw'; | ||
import { useEffect, useState } from 'react'; | ||
import { getWorker } from 'msw-storybook-addon'; | ||
|
||
const { BasePage, VariantSTupid } = composeStories(stories, { decorators }); | ||
|
||
describe('QuestionEditor', () => { | ||
|
||
|
||
it('is possible to create a new variant', async () => { | ||
render(<BasePage />); | ||
|
||
const loading = screen.getByText("Loading..."); | ||
await waitForElementToBeRemoved(loading); | ||
|
||
|
||
|
||
//const initialCards = await screen.findAllByTestId('variant-card'); | ||
//const addButton = screen.getByRole('button', { name: /new variant/i }); | ||
//await userEvent.click(addButton,); | ||
//const newCards = await screen.findAllByTestId('variant-card'); | ||
//expect(initialCards.length + 1).toBe(newCards.length); | ||
}); | ||
|
||
it.only("works with really simple case", async () => { | ||
|
||
render(<VariantSTupid />); | ||
|
||
//getWorker().listHandlers(); | ||
|
||
await screen.findByText("potato"); | ||
await screen.findByText("starting"); | ||
// await waitForElementToBeRemoved(loading); | ||
|
||
}) | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.