Skip to content

Commit

Permalink
Add an e2e test conditional buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
kavics committed Nov 17, 2023
1 parent c9f5440 commit 29f8860
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
23 changes: 20 additions & 3 deletions apps/sensenet/cypress/e2e/setup/setup.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ describe('Setup', () => {
it('should open a binary editor with the content of the "settings item" if Edit button is clicked', () => {
cy.get('[data-test="content-card-documentpreview.settings"]')
.within(() => {
cy.get('[data-test="documentpreview.settings-edit-button"]').click()
cy.get('[data-test="documentpreview-edit-button"]').click()
})
.get('[data-test="editor-title"]')
.should('have.text', 'DocumentPreview.settings')
})

it('should open the document of the selected "settings item" if "Learn more" button is clicked', () => {
cy.get('[data-test="content-card-documentpreview.settings"]').within(() => {
cy.get('[data-test="content-card-learnmore-button"]')
.get('a[href="https://docs.sensenet.com/concepts/basics/07-settings#documentpreview-settings"]')
cy.get('[data-test="documentpreview-learnmore-button"]')
.get('a[href="https://docs.sensenet.com/guides/settings/setup#documentpreview-settings"]')
.should('have.attr', 'target', '_blank')
})
})
Expand Down Expand Up @@ -86,6 +86,23 @@ describe('Setup', () => {
})
})

it('check white- and blacklisted buttons', () => {
// custom settings can be deleted and never hasn't documentation
cy.get(`[data-test="testsettings-delete-button"]`).should('exist')
cy.get(`[data-test="testsettings-edit-button"]`).should('exist')
cy.get(`[data-test="testsettings-learnmore-button"]`).should('not.exist')

// indexing is system and documented
cy.get(`[data-test="indexing-delete-button"]`).should('not.exist')
cy.get(`[data-test="indexing-edit-button"]`).should('exist')
cy.get(`[data-test="indexing-learnmore-button"]`).should('exist')

// logging is system and not documented
cy.get(`[data-test="logging-delete-button"]`).should('not.exist')
cy.get(`[data-test="logging-edit-button"]`).should('exist')
cy.get(`[data-test="logging-learnmore-button"]`).should('not.exist')
})

it('should delete a setup file', () => {
cy.get('[data-test="settings-container"]').then((grid) => {
cy.scrollToItem({
Expand Down
11 changes: 6 additions & 5 deletions apps/sensenet/src/components/settings/content-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type ContentCardProps = {

const hasDocumentation = ['Portal', 'OAuth', 'DocumentPreview', 'OfficeOnline', 'Indexing', 'Sharing']
const isSystemSettings = [
'DocumentPreview',
'OAuth',
'OfficeOnline',
'Indexing',
Expand All @@ -75,9 +76,10 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
const uiSettings = useContext(ResponsivePersonalSettings)
const history = useHistory()
const classes = useStyles()
const { openDialog } = useDialog()
const settingsName = settings.DisplayName || settings.Name
const settingsTitle = settingsName.replace(/\.settings/gi, '')
const { openDialog } = useDialog()
const dataTestName = settingsTitle.replace(/\s+/g, '-').toLowerCase()

return (
<Card
Expand All @@ -102,7 +104,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
<CardActions style={{ justifyContent: 'flex-end' }}>
{!isSystemSettings.includes(settingsTitle) && (
<IconButton
data-test="batch-delete"
data-test={`${dataTestName}-delete-button`}
aria-label="delete"
onClick={() => {
openDialog({
Expand All @@ -121,8 +123,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
aria-label={localization.edit}
size="small"
className={classes.button}
//style={{ marginRight: '35px' }}
data-test={`${settings.Name.replace(/\s+/g, '-').toLowerCase()}-edit-button`}>
data-test={`${dataTestName}-edit-button`}>
{localization.edit}
</Button>
</Link>
Expand All @@ -136,7 +137,7 @@ export const ContentCard = ({ settings, onContextMenu }: ContentCardProps) => {
aria-label={localization.learnMore}
size="small"
className={classes.button}
data-test="content-card-learnmore-button">
data-test={`${dataTestName}-learnmore-button`}>
{localization.learnMore}
</Button>
</a>
Expand Down

0 comments on commit 29f8860

Please sign in to comment.