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

test: improving robustness of unpublish.spec e2e #9052

Merged
merged 2 commits into from
Mar 27, 2025
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -260,7 +260,13 @@ export const DocumentPanelHeader = memo(
<Card hidden={collapsed} style={{lineHeight: 0}} borderBottom>
<Flex gap={3} paddingY={3}>
<HorizontalScroller>
<Flex flex={1} gap={1} overflow="auto" paddingX={3}>
<Flex
flex={1}
gap={1}
overflow="auto"
paddingX={3}
data-testid="document-perspective-list"
>
<DocumentPerspectiveList />
</Flex>
</HorizontalScroller>
8 changes: 4 additions & 4 deletions test/e2e/tests/document-actions/unpublish.spec.ts
Original file line number Diff line number Diff line change
@@ -30,13 +30,13 @@ test(`should be able to unpublish a published document`, async ({page, createDra
await expect(unpublishButton).toBeVisible()
await unpublishButton.click()

await page.waitForTimeout(2_000)

await expect(unpublishModal).toBeVisible()
await expect(unpublishModal).toBeVisible({timeout: 4_000})
await page.getByTestId('confirm-button').click()

const documentPerspectiveList = page.getByTestId('document-perspective-list')
const button = documentPerspectiveList.getByRole('button', {name: 'Published', exact: true})

// Check the published button is disabled that is the reference to determine the published document doesn't exist.
const button = await page.getByRole('button', {name: 'Published', exact: true})
await expect(button).toBeDisabled()
await expect(documentStatus).toContainText('Unpublished just now')
})

Unchanged files with check annotations Beta

)
const debounceSelectionChange = useMemo(
() => debounce(handleSelectionChange, 200),

Check warning on line 262 in packages/sanity/src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
[handleSelectionChange],
)
const currentSelectionIsOverlapping = useMemo(() => {
if (!currentSelection || addedCommentsDecorations.length === 0) return false
return addedCommentsDecorations.some((d) => {

Check warning on line 441 in packages/sanity/src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
if (!editorRef.current) return false
const testA = PortableTextEditor.isSelectionsOverlapping(
}, [handleBuildRangeDecorations, textComments])
const showFloatingButton = Boolean(
currentSelection && canSubmit && selectionReferenceElement && !mouseDownRef.current,

Check warning on line 528 in packages/sanity/src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
)
const showFloatingInput = Boolean(nextCommentSelection && popoverAuthoringReferenceElement)
</BoundaryElementProvider>
<Stack ref={setRootElement} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp}>
{props.renderDefault({

Check warning on line 561 in packages/sanity/src/core/comments/plugin/input/components/CommentsPortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
...props,
onEditorChange,
editorRef,
const disabled = getItemDisabled?.(index) ?? false
const selected = getItemSelected?.(index) ?? false
if (!disabled) {
i += 1

Check warning on line 185 in packages/sanity/src/core/components/commandList/CommandList.tsx

GitHub Actions / lint

Reassigning a variable after render has completed can cause inconsistent behavior on subsequent renders. Consider using state instead
}
acc[index] = {
activeIndex: disabled ? null : i,
const rangeDecorations = useMemo((): RangeDecoration[] => {
const result = [...(rangeDecorationsProp || []), ...presenceCursorDecorations]
const reconciled = immutableReconcile(previousRangeDecorations.current, result)

Check warning on line 295 in packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
previousRangeDecorations.current = reconciled

Check warning on line 296 in packages/sanity/src/core/form/inputs/PortableText/PortableTextInput.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
return reconciled
}, [presenceCursorDecorations, rangeDecorationsProp])
[validation],
)
const reconciled = immutableReconcile(prev.current, validation)

Check warning on line 36 in packages/sanity/src/core/form/inputs/PortableText/hooks/useMemberValidation.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
prev.current = reconciled

Check warning on line 37 in packages/sanity/src/core/form/inputs/PortableText/hooks/useMemberValidation.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
return useMemo(() => {
return {
}
}
const items: PortableTextMemberItem[] = result.map((item) => {

Check warning on line 121 in packages/sanity/src/core/form/inputs/PortableText/hooks/usePortableTextMembers.tsx

GitHub Actions / lint

Ref values (the `current` property) may not be accessed during render. (https://react.dev/reference/react/useRef)
const key = pathToString(item.node.path)
const existingItem = portableTextMemberItemsRef.current.find((refItem) => refItem.key === key)
const isObject = item.kind !== 'textBlock'
export const BrandLogo = () => (

Check warning on line 1 in examples/movies-studio/components/BrandLogo.tsx

GitHub Actions / lint

Missing return type on function.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 530">
<g>
<path
return str.replace(/^drafts\./, '')
}
export function resolveProductionUrl(document, rev) {

Check warning on line 7 in examples/movies-studio/resolveProductionUrl.ts

GitHub Actions / lint

Missing return type on function.

Check warning on line 7 in examples/movies-studio/resolveProductionUrl.ts

GitHub Actions / lint

Argument 'document' should be typed.

Check warning on line 7 in examples/movies-studio/resolveProductionUrl.ts

GitHub Actions / lint

Argument 'rev' should be typed.
const id = stripDraftId(document._id)
if (rev) {
],
document: {
// @todo

Check warning on line 34 in examples/movies-studio/sanity.config.ts

GitHub Actions / lint

Unexpected 'todo' comment: '@todo'.
//productionUrl: resolveProductionUrl,
},
})
export function diffNumber<A>(
fromInput: NumberInput<A>,
toInput: NumberInput<A>,
options: DiffOptions,

Check warning on line 12 in packages/@sanity/diff/src/calculate/diffSimple.ts

GitHub Actions / lint

'options' is defined but never used.

Check warning on line 12 in packages/@sanity/diff/src/calculate/diffSimple.ts

GitHub Actions / lint

'options' is defined but never used.
): NumberDiff<A> {
const fromValue = fromInput.value
const toValue = toInput.value
export function diffBoolean<A>(
fromInput: BooleanInput<A>,
toInput: BooleanInput<A>,
options: DiffOptions,

Check warning on line 40 in packages/@sanity/diff/src/calculate/diffSimple.ts

GitHub Actions / lint

'options' is defined but never used.

Check warning on line 40 in packages/@sanity/diff/src/calculate/diffSimple.ts

GitHub Actions / lint

'options' is defined but never used.
): BooleanDiff<A> {
const fromValue = fromInput.value
const toValue = toInput.value
export function diffString<A>(
fromInput: StringInput<A>,
toInput: StringInput<A>,
options: DiffOptions,

Check warning on line 15 in packages/@sanity/diff/src/calculate/diffString.ts

GitHub Actions / lint

'options' is defined but never used.
): StringDiff<A> {
const fromValue = fromInput.value
const toValue = toInput.value