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

Corel UI tests #7091

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
f902607
feat(sanity): add support for sticky query params
bjoerge May 6, 2024
0687d25
feat(sanity): add 'perspective' dropdown
bjoerge May 6, 2024
b2391a4
feat(sanity): include `_version` field in search results
juice49 Jun 21, 2024
088c2df
feat(types): add `_version` field to `SanityDocument` and `SanityDocu…
juice49 Jun 21, 2024
4059a1b
fix(sanity): global perspective state restoration
juice49 Jun 24, 2024
9e5f76d
feat(sanity): hardcode `summerDrop` and `autumnDrop` bundles
juice49 Jun 24, 2024
4e569ef
wip: allow pairs to include multiple drafts
juice49 May 22, 2024
ddc12ce
feat(sanity): support versioned document ids in `getPublishedId` func…
juice49 Jun 24, 2024
d828598
feat(sanity): add `_version` field to preview observation
juice49 Jun 26, 2024
3b97171
feat(sanity): reflect checked out bundle in document lists and list p…
juice49 Jun 26, 2024
b32fbaa
debug(sanity): add version debug output to list previews
juice49 Jun 26, 2024
71701d9
feat(sanity): add action to create new version based on an doc id
RitaDias Jun 25, 2024
243be24
feat(sanity): update document title + version popover - add new and f…
RitaDias Jun 26, 2024
4083bc2
chore(sanity): move versions menu to versions folder
RitaDias Jun 26, 2024
8a6eff1
chore(sanity): update check for checking version
RitaDias Jun 26, 2024
0e93dcf
fix(sanity): ability to add new versions to doc
RitaDias Jun 26, 2024
75ea1fa
feat(sanity): add dumb bundle and version data, add icons and hues
RitaDias Jun 26, 2024
b516055
feat(sanity): update styles and don't rely on random
RitaDias Jun 26, 2024
c34020e
update isVersion
RitaDias Jun 26, 2024
7dd612a
docs(sanity): update comments
RitaDias Jun 26, 2024
a27be0f
feat(sanity): add "latest version" menu button
RitaDias Jun 26, 2024
81b4166
refactor(sanity): update comments
RitaDias Jun 26, 2024
671054d
chore(sanity): remove import from format date. will use something else
RitaDias Jun 26, 2024
7f4ceb9
fix(sanity): allow uppercase characters in version identifiers
juice49 Jun 26, 2024
c071441
feat(sanity): add tag to list document versions request
juice49 Jun 27, 2024
0622e9d
feat(corel): integrate bundles store (#7040)
pedrobonamin Jul 1, 2024
1c90eb5
feat(corel): doc and structure updates (#7039)
RitaDias Jul 1, 2024
d045a3a
feat(releases): initialising releases plugin (#7048)
jordanl17 Jul 2, 2024
6259c8e
refactor(releases): removing shortRelativeDate (#7051)
jordanl17 Jul 2, 2024
3fb2c50
chore(corel): add bundles provider (#7054)
pedrobonamin Jul 3, 2024
6650623
feat(COREL): update types to bundle + add create bundle functionality…
RitaDias Jul 5, 2024
3705d9c
refactor(COREL): refactor version context & renaming (#7071)
RitaDias Jul 5, 2024
6bdaa63
fix(corel): update uses of collate, add typeguard for bundles and add…
pedrobonamin Jul 8, 2024
89bd857
feat(releases): archive and unarchive releases (#7072)
jordanl17 Jul 8, 2024
f241d33
refactor(sanity): move bundle metadata store to resource cache
juice49 Jul 7, 2024
291fb9b
test(sanity): try to find solution for test
RitaDias Jul 8, 2024
c694573
wip: add theme provider to test
juice49 Jul 8, 2024
6a84ee0
test(sanity): add test to bundleForm & add createWrapper in core
RitaDias Jul 8, 2024
e056703
test(sanity): add test to BundleIconEditorPicker
RitaDias Jul 8, 2024
d621870
chore(sanity): update createWrapper
RitaDias Jul 8, 2024
f71c357
test(sanity): update bundleForm test
RitaDias Jul 8, 2024
89d6d4b
test(sanity) add createBundleDialog tests
RitaDias Jul 8, 2024
f0bf1a5
test(sanity) add BundleMenu tests
RitaDias Jul 9, 2024
e31e8db
refactor(sanity): add prop to createWrapper to access TestProviderOpt…
RitaDias Jul 9, 2024
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
10 changes: 10 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ const config = {
},
},

// Ignore i18n in releases files. TODO: Remove this before moving releases to GA.
{
files: ['**/*/core/releases/**/*', '**/*/core/bundles/**/*'],
rules: {
'i18next/no-literal-string': 'off',
'@sanity/i18n/no-attribute-string-literals': 'off',
'@sanity/i18n/no-attribute-template-literals': 'off',
},
},

// Files to disable i18n literals,
{
files: ['./**/*/__workshop__/**/*', './dev/**/*', './examples/**/*', '**/*/debug/**/*'],
Expand Down
2 changes: 2 additions & 0 deletions packages/@sanity/types/src/documents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface SanityDocument {
_createdAt: string
_updatedAt: string
_rev: string
_version?: Record<string, never>
[key: string]: unknown
}

Expand All @@ -21,6 +22,7 @@ export interface SanityDocumentLike {
_createdAt?: string
_updatedAt?: string
_rev?: string
_version?: Record<string, never>
[key: string]: unknown
}

Expand Down
53 changes: 53 additions & 0 deletions packages/sanity/src/core/bundles/components/BundleBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {hues} from '@sanity/color'
import {ChevronDownIcon, Icon} from '@sanity/icons'
// eslint-disable-next-line camelcase
import {Box, Flex, rgba, Text, useTheme_v2} from '@sanity/ui'
import {type CSSProperties} from 'react'

import {type BundleDocument} from '../../store/bundles/types'

/**
* @internal
*/
export function BundleBadge(
props: Partial<BundleDocument> & {openButton?: boolean; padding?: number; title?: string},
): JSX.Element {
const {hue = 'gray', icon, openButton, padding = 3, title} = props
const {color} = useTheme_v2()

return (
<Flex
gap={padding}
padding={padding}
style={
{
'--card-bg-color': rgba(hues[hue][color._dark ? 700 : 300].hex, 0.2),
'--card-fg-color': hues[hue][color._dark ? 400 : 600].hex,
'--card-icon-color': hues[hue][color._dark ? 400 : 600].hex,
'backgroundColor': 'var(--card-bg-color)',
'borderRadius': '9999px',
} as CSSProperties
}
>
{icon && (
<Box flex="none">
<Text size={1}>
<Icon symbol={icon} />
</Text>
</Box>
)}
{title && (
<Box flex="none">
<Text size={1}>{title}</Text>
</Box>
)}
{openButton && (
<Box flex="none">
<Text size={1}>
<ChevronDownIcon />
</Text>
</Box>
)}
</Flex>
)
}
138 changes: 138 additions & 0 deletions packages/sanity/src/core/bundles/components/BundleMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import {CheckmarkIcon} from '@sanity/icons'
import {Box, Flex, Menu, MenuButton, MenuDivider, MenuItem, Spinner, Text} from '@sanity/ui'
import {type ReactElement, useCallback} from 'react'
import {RelativeTime} from 'sanity'
import {styled} from 'styled-components'

import {type BundleDocument} from '../../store/bundles/types'
import {usePerspective} from '../hooks/usePerspective'
import {LATEST} from '../util/const'
import {isDraftOrPublished} from '../util/dummyGetters'
import {BundleBadge} from './BundleBadge'

const StyledMenu = styled(Menu)`
min-width: 200px;
`

const StyledBox = styled(Box)`
overflow: auto;
max-height: 200px;
`

interface BundleListProps {
button: ReactElement
bundles: BundleDocument[] | null
loading: boolean
actions?: ReactElement
}

/**
* @internal
*/
export function BundleMenu(props: BundleListProps): JSX.Element {
const {bundles, loading, actions, button} = props
const hasBundles = bundles && bundles.filter((b) => !isDraftOrPublished(b.name)).length > 0

const {currentGlobalBundle, setPerspective} = usePerspective()

const handleBundleChange = useCallback(
(bundle: Partial<BundleDocument>) => () => {
if (bundle.name) {
setPerspective(bundle.name)
}
},
[setPerspective],
)

return (
<>
<MenuButton
button={button}
id="bundle-menu"
menu={
<StyledMenu data-testid="bundle-menu">
{loading ? (
<Flex padding={4} justify="center" data-testid="spinner">
<Spinner muted />
</Flex>
) : (
<>
<MenuItem
iconRight={
currentGlobalBundle.name === LATEST.name ? (
<CheckmarkIcon data-testid="latest-checkmark-icon" />
) : undefined
}
onClick={handleBundleChange(LATEST)}
pressed={false}
text={LATEST.title}
data-testid="latest-menu-item"
/>
{hasBundles && (
<>
<MenuDivider />
<StyledBox data-testid="bundles-list">
{bundles
.filter((b) => !isDraftOrPublished(b.name) && !b.archivedAt)
.map((b) => (
<MenuItem
key={b.name}
onClick={handleBundleChange(b)}
padding={1}
pressed={false}
data-testid={`bundle-${b.name}`}
>
<Flex>
<BundleBadge hue={b.hue} icon={b.icon} padding={2} />

<Box flex={1} padding={2} style={{minWidth: 100}}>
<Text size={1} weight="medium">
{b.title}
</Text>
</Box>

<Box padding={2}>
<Text muted size={1}>
{b.publishAt ? (
<RelativeTime time={b.publishAt as Date} useTemporalPhrase />
) : (
/* localize text */
'No target date'
)}
</Text>
</Box>

<Box padding={2}>
<Text size={1}>
<CheckmarkIcon
style={{opacity: currentGlobalBundle.name === b.name ? 1 : 0}}
data-testid={`${b.name}-checkmark-icon`}
/>
</Text>
</Box>
</Flex>
</MenuItem>
))}
</StyledBox>
</>
)}

{actions && (
<>
<MenuDivider />
{actions}
</>
)}
</>
)}
</StyledMenu>
}
popover={{
placement: 'bottom-start',
portal: true,
zOffset: 3000,
}}
/>
</>
)
}
Loading
Loading