ci: ✅ Fix e2e tests
This commit is contained in:
@ -26,7 +26,7 @@ export const Edges = ({
|
||||
left="0"
|
||||
top="0"
|
||||
pointerEvents="none"
|
||||
shape-rendering="geometricPrecision"
|
||||
shapeRendering="geometricPrecision"
|
||||
>
|
||||
<DrawingEdge />
|
||||
{edges.map((edge) => (
|
||||
|
@ -162,7 +162,7 @@ export const TypebotContext = ({
|
||||
useEffect(() => {
|
||||
if (!typebot || !currentTypebotRef.current) return
|
||||
if (typebotId !== currentTypebotRef.current.id) {
|
||||
setLocalTypebot({ ...typebot })
|
||||
setLocalTypebot({ ...typebot }, { updateDate: false })
|
||||
flush()
|
||||
} else if (
|
||||
new Date(typebot.updatedAt) >
|
||||
|
@ -84,7 +84,7 @@ test.describe.parallel('Image bubble step', () => {
|
||||
force: true,
|
||||
position: { x: 0, y: 0 },
|
||||
})
|
||||
await expect(page.locator('img[alt="Step image"]')).toHaveAttribute(
|
||||
await expect(page.locator('img[alt="Block image"]')).toHaveAttribute(
|
||||
'src',
|
||||
new RegExp('giphy.com/media', 'gm')
|
||||
)
|
||||
|
@ -12,7 +12,10 @@ enum ActionType {
|
||||
}
|
||||
|
||||
export interface Actions<T> {
|
||||
set: (newPresent: T | ((current: T) => T)) => void
|
||||
set: (
|
||||
newPresent: T | ((current: T) => T),
|
||||
options?: { updateDate: boolean }
|
||||
) => void
|
||||
undo: () => void
|
||||
redo: () => void
|
||||
flush: () => void
|
||||
@ -24,6 +27,7 @@ export interface Actions<T> {
|
||||
interface Action<T> {
|
||||
type: ActionType
|
||||
newPresent?: T
|
||||
updateDate?: boolean
|
||||
}
|
||||
|
||||
export interface State<T> {
|
||||
@ -72,7 +76,7 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
|
||||
}
|
||||
|
||||
case ActionType.Set: {
|
||||
const { newPresent } = action
|
||||
const { newPresent, updateDate } = action
|
||||
if (
|
||||
isNotDefined(newPresent) ||
|
||||
(present &&
|
||||
@ -92,7 +96,12 @@ const reducer = <T>(state: State<T>, action: Action<T>) => {
|
||||
// )
|
||||
return {
|
||||
past: [...past, present].filter(isDefined),
|
||||
present: { ...newPresent, updatedAt: new Date() },
|
||||
present: {
|
||||
...newPresent,
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore
|
||||
updatedAt: updateDate ? new Date() : newPresent.updatedAt,
|
||||
},
|
||||
future: [],
|
||||
}
|
||||
}
|
||||
@ -124,14 +133,21 @@ const useUndo = <T>(initialPresent: T): [State<T>, Actions<T>] => {
|
||||
}
|
||||
}, [canRedo])
|
||||
|
||||
const set = useCallback((newPresent: T | ((current: T) => T)) => {
|
||||
const updatedTypebot =
|
||||
'id' in newPresent
|
||||
? newPresent
|
||||
: (newPresent as (current: T) => T)(presentRef.current)
|
||||
presentRef.current = updatedTypebot
|
||||
dispatch({ type: ActionType.Set, newPresent: updatedTypebot })
|
||||
}, [])
|
||||
const set = useCallback(
|
||||
(newPresent: T | ((current: T) => T), options = { updateDate: true }) => {
|
||||
const updatedTypebot =
|
||||
'id' in newPresent
|
||||
? newPresent
|
||||
: (newPresent as (current: T) => T)(presentRef.current)
|
||||
presentRef.current = updatedTypebot
|
||||
dispatch({
|
||||
type: ActionType.Set,
|
||||
newPresent: updatedTypebot,
|
||||
updateDate: options.updateDate,
|
||||
})
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
const flush = useCallback(() => {
|
||||
dispatch({ type: ActionType.Flush })
|
||||
|
Reference in New Issue
Block a user