Skip to content

Commit

Permalink
Merge pull request #2758 from target/tests-fix
Browse files Browse the repository at this point in the history
ui: update failing cypress tests
  • Loading branch information
m17ch authored Dec 21, 2022
2 parents af765c2 + d6ddfe9 commit 4cc91ed
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 8 deletions.
1 change: 1 addition & 0 deletions web/src/app/services/HeartbeatMonitorList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export default function HeartbeatMonitorList(props: {
variant='contained'
onClick={() => setShowCreateDialog(true)}
startIcon={<Add />}
data-testid='create-monitor'
>
Create Heartbeat Monitor
</Button>
Expand Down
1 change: 1 addition & 0 deletions web/src/app/services/IntegrationKeyList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default function IntegrationKeyList(props: {
variant='contained'
onClick={(): void => setCreate(true)}
startIcon={<Add />}
data-testid='create-key'
>
Create Integration Key
</Button>
Expand Down
1 change: 1 addition & 0 deletions web/src/app/services/ServiceLabelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function ServiceLabelList(props: {
variant='contained'
onClick={() => setCreate(true)}
startIcon={<Add />}
data-testid='create-label'
>
Create Label
</Button>
Expand Down
48 changes: 40 additions & 8 deletions web/src/cypress/e2e/services.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,11 @@ function testServices(screen: ScreenFormat): void {
const timeoutMinutes = (Math.trunc(Math.random() * 10) + 5).toString()
const invalidName = 'a'

cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-monitor"]').click()
}

cy.dialogForm({ name: invalidName, timeoutMinutes })
cy.dialogClick('Submit')
Expand Down Expand Up @@ -417,7 +421,11 @@ function testServices(screen: ScreenFormat): void {

it('should handle canceling', () => {
// cancel out of create
cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-monitor"]').click()
}
cy.dialogTitle('Create New Heartbeat Monitor')
cy.dialogFinish('Cancel')

Expand Down Expand Up @@ -449,7 +457,11 @@ function testServices(screen: ScreenFormat): void {
)

const createKey = (type: string, name: string): void => {
cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-key"]').click()
}
cy.dialogForm({ name, type })
cy.dialogFinish('Submit')
}
Expand Down Expand Up @@ -506,7 +518,11 @@ function testServices(screen: ScreenFormat): void {
)

// check that dropdown type is hidden
cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-key"]').click()
}
cy.get('input[name=type]').findByLabel('Email').should('not.exist')
})
})
Expand Down Expand Up @@ -570,7 +586,11 @@ function testServices(screen: ScreenFormat): void {
const key = label.key
const value = c.word({ length: 10 })

cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-label"]').click()
}
cy.dialogForm({ key, value })
cy.dialogFinish('Submit')
cy.get('li').should('contain', key)
Expand All @@ -584,7 +604,11 @@ function testServices(screen: ScreenFormat): void {
cy.visit(`/services/${svc.id}/labels`)
})

cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-label"]').click()
}
cy.dialogForm({ key, value })
cy.dialogFinish('Submit')

Expand Down Expand Up @@ -644,7 +668,11 @@ function testServices(screen: ScreenFormat): void {
const randomWord = c.word({
length: 7,
})
cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-label"]').click()
}
cy.get('input[name=key]').findByLabel(`Create "${randomWord}"`)

cy.updateConfig({
Expand All @@ -654,7 +682,11 @@ function testServices(screen: ScreenFormat): void {
})
cy.reload()

cy.pageFab()
if (screen === 'mobile') {
cy.pageFab()
} else {
cy.get('button[data-testid="create-label"]').click()
}
cy.get('input[name=key]').type(`Create "${randomWord}"`)
cy.get('[data-cy="select-dropdown"]').should('contain', 'No options')
})
Expand Down

0 comments on commit 4cc91ed

Please sign in to comment.