Compare commits
3 Commits
codex/refa
...
codex/refa
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9f229815a | ||
|
|
db9333049f | ||
|
|
48aae30dc0 |
@@ -141,6 +141,11 @@
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"web/app/(shareLayout)/webapp-signin/components/mail-and-code-auth.tsx": {
|
||||
"no-restricted-imports": {
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
"web/app/(shareLayout)/webapp-signin/components/mail-and-password-auth.tsx": {
|
||||
"jsx_a11y/tabindex-no-positive": {
|
||||
"count": 3
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import MailAndCodeAuth from '../mail-and-code-auth'
|
||||
|
||||
const pushMock = vi.fn()
|
||||
const replaceMock = vi.fn()
|
||||
const setCountdownLeftTimeMock = vi.fn()
|
||||
const sendWebAppEMailLoginCodeMock = vi.fn()
|
||||
const searchParams = new URLSearchParams({
|
||||
redirect_url: encodeURIComponent('/chatbot/test-app'),
|
||||
})
|
||||
|
||||
vi.mock('@/next/navigation', () => ({
|
||||
useRouter: () => ({ push: pushMock, replace: replaceMock }),
|
||||
useSearchParams: () => searchParams,
|
||||
}))
|
||||
|
||||
vi.mock('@/context/i18n', () => ({
|
||||
useLocale: () => 'en-US',
|
||||
}))
|
||||
|
||||
vi.mock('@/app/components/signin/storage', () => ({
|
||||
COUNT_DOWN_TIME_MS: 60_000,
|
||||
useSetCountdownLeftTime: () => setCountdownLeftTimeMock,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/common', () => ({
|
||||
sendWebAppEMailLoginCode: (...args: unknown[]) => sendWebAppEMailLoginCodeMock(...args),
|
||||
}))
|
||||
|
||||
describe('MailAndCodeAuth', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
sendWebAppEMailLoginCodeMock.mockResolvedValue({ result: 'success', data: 'token-abc' })
|
||||
})
|
||||
|
||||
it('submits from the email field through the native form', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(<MailAndCodeAuth />)
|
||||
|
||||
const emailInput = screen.getByRole('textbox', { name: 'login.email' })
|
||||
const submitButton = screen.getByRole('button', { name: 'login.signup.verifyMail' })
|
||||
|
||||
expect(emailInput).toHaveAttribute('name', 'email')
|
||||
expect(emailInput).toHaveAttribute('autocomplete', 'email')
|
||||
expect(emailInput).toHaveAttribute('spellcheck', 'false')
|
||||
expect(submitButton).toHaveAttribute('type', 'submit')
|
||||
|
||||
await user.tab()
|
||||
expect(emailInput).toHaveFocus()
|
||||
await user.type(emailInput, 'user@example.com{Enter}')
|
||||
|
||||
await waitFor(() => {
|
||||
expect(sendWebAppEMailLoginCodeMock).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
expect(pushMock).toHaveBeenCalledWith(expect.stringContaining('/webapp-signin/check-code?'))
|
||||
})
|
||||
})
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Button } from '@langgenius/dify-ui/button'
|
||||
import { Field, FieldControl, FieldLabel } from '@langgenius/dify-ui/field'
|
||||
import { Form } from '@langgenius/dify-ui/form'
|
||||
import { toast } from '@langgenius/dify-ui/toast'
|
||||
import { noop } from 'es-toolkit/function'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { resolveWebAppLoginRedirect } from '@/app/(shareLayout)/webapp-signin/login-redirect'
|
||||
import Input from '@/app/components/base/input'
|
||||
import { COUNT_DOWN_TIME_MS, useSetCountdownLeftTime } from '@/app/components/signin/storage'
|
||||
import { emailRegex } from '@/config'
|
||||
import { useLocale } from '@/context/i18n'
|
||||
@@ -64,37 +64,33 @@ export default function MailAndCodeAuth() {
|
||||
}
|
||||
|
||||
return (
|
||||
<Form
|
||||
onFormSubmit={() => {
|
||||
void handleGetEMailVerificationCode()
|
||||
}}
|
||||
>
|
||||
<Field name="email" className="mb-2 block">
|
||||
<FieldLabel className="my-2 py-0 system-md-semibold! text-text-secondary">
|
||||
<form onSubmit={noop}>
|
||||
<input type="text" className="hidden" />
|
||||
<div className="mb-2">
|
||||
<label htmlFor="email" className="my-2 system-md-semibold text-text-secondary">
|
||||
{t(($) => $.email, { ns: 'login' })}
|
||||
</FieldLabel>
|
||||
</label>
|
||||
<div className="mt-1">
|
||||
<FieldControl
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
spellCheck={false}
|
||||
value={email}
|
||||
placeholder={t(($) => $.emailPlaceholder, { ns: 'login' }) as string}
|
||||
onValueChange={setEmail}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-3">
|
||||
<Button
|
||||
type="submit"
|
||||
loading={loading}
|
||||
disabled={loading || !email}
|
||||
variant="primary"
|
||||
className="w-full"
|
||||
onClick={handleGetEMailVerificationCode}
|
||||
>
|
||||
{t(($) => $['signup.verifyMail'], { ns: 'login' })}
|
||||
</Button>
|
||||
</div>
|
||||
</Field>
|
||||
</Form>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('assigner/panel', () => {
|
||||
}),
|
||||
)
|
||||
|
||||
await user.click(screen.getAllByRole('button')[0]!)
|
||||
await user.click(screen.getByRole('button', { name: 'common.operation.add' }))
|
||||
|
||||
expect(mockUseHandleAddOperationItem).toHaveBeenCalledWith(createData().items)
|
||||
expect(handleOperationListChanges).toHaveBeenCalledWith([
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import type { FC } from 'react'
|
||||
import type { AssignerNodeType } from './types'
|
||||
import type { NodePanelProps } from '@/app/components/workflow/types'
|
||||
import { RiAddLine } from '@remixicon/react'
|
||||
import * as React from 'react'
|
||||
import { memo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import ActionButton from '@/app/components/base/action-button'
|
||||
import VarList from './components/var-list'
|
||||
@@ -11,7 +9,7 @@ import useConfig from './use-config'
|
||||
|
||||
const i18nPrefix = 'nodes.assigner'
|
||||
|
||||
const Panel: FC<NodePanelProps<AssignerNodeType>> = ({ id, data }) => {
|
||||
const Panel = ({ id, data }: NodePanelProps<AssignerNodeType>) => {
|
||||
const { t } = useTranslation()
|
||||
const handleAddOperationItem = useHandleAddOperationItem()
|
||||
const {
|
||||
@@ -38,8 +36,11 @@ const Panel: FC<NodePanelProps<AssignerNodeType>> = ({ id, data }) => {
|
||||
<div className="flex grow flex-col items-start justify-center system-sm-semibold-uppercase text-text-secondary">
|
||||
{t(($) => $[`${i18nPrefix}.variables`], { ns: 'workflow' })}
|
||||
</div>
|
||||
<ActionButton onClick={handleAddOperation}>
|
||||
<RiAddLine className="size-4 shrink-0 text-text-tertiary" />
|
||||
<ActionButton
|
||||
aria-label={t(($) => $['operation.add'], { ns: 'common' })}
|
||||
onClick={handleAddOperation}
|
||||
>
|
||||
<span aria-hidden="true" className="i-ri-add-line size-4 shrink-0 text-text-tertiary" />
|
||||
</ActionButton>
|
||||
</div>
|
||||
<VarList
|
||||
@@ -62,4 +63,4 @@ const Panel: FC<NodePanelProps<AssignerNodeType>> = ({ id, data }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(Panel)
|
||||
export default memo(Panel)
|
||||
|
||||
Reference in New Issue
Block a user