Skip to content

Commit 7e86fe7

Browse files
document viewport support
1 parent 90410d6 commit 7e86fe7

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

docs/api/commands/prompt.mdx

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ If Cypress cannot interpret a step, you'll see a dialog prompting you to refine
282282
'confirm that the code frame includes HTML "<span class="token">'
283283
```
284284

285+
### Change the viewport
286+
287+
```javascript
288+
'set the viewport to 400x600'
289+
```
290+
285291
### Wait
286292

287293
```javascript
@@ -671,49 +677,65 @@ cy.origin('https://cloud.cypress.io/login', () => {
671677
### Mixed with traditional Cypress
672678

673679
```javascript
674-
const electronicsCount = 25
680+
const electronicsCount = Cypress.env('staging') === true ? 5 : 25
675681

676-
// Confirm the UI works in desktop view
677-
cy.viewport(1024, 768)
682+
// Confirm the UI works in staging environment
683+
cy.task('seedStagingDB')
678684
cy.visit(`${Cypress.env('stagingUrl')}/products`)
679685
cy.prompt([
680686
'filter by category "Electronics"',
681687
'sort by price high to low',
682-
`verify the product count is ${electronicsCount}`,
688+
`verify the product count is {{electronicsCount}}`,
683689
'verify the sort indicator is "Price: High to Low"',
684-
])
690+
], {
691+
placeholders: {
692+
electronicsCount,
693+
},
694+
})
685695

686-
// Confirm the UI works in mobile view
687-
cy.viewport(400, 600)
688-
cy.visit(`${Cypress.env('stagingUrl')}/products`)
696+
// Confirm the UI works in production environment
697+
cy.task('seedProductionDB')
698+
cy.visit(`${Cypress.env('productionUrl')}/products`)
689699
cy.prompt([
690700
'filter by category "Electronics"',
691701
'sort by price high to low',
692-
`verify the product count is ${electronicsCount}`,
702+
`verify the product count is {{electronicsCount}}`,
693703
'verify the sort indicator is "Price: High to Low"',
694-
])
704+
], {
705+
placeholders: {
706+
electronicsCount,
707+
},
708+
})
695709
```
696710

697711
Or to further clean up the `cy.prompt` call:
698712

699713
```javascript
700-
const electronicsCount = 25
714+
const electronicsCount = Cypress.env('staging') === true ? 5 : 25
701715
const electronicsFilterPrompt = [
702716
'filter by category "Electronics"',
703717
'sort by price high to low',
704-
`verify the product count is ${electronicsCount}`,
718+
`verify the product count is {{electronicsCount}}`,
705719
'verify the sort indicator is "Price: High to Low"',
706720
]
707721

708-
// Confirm the UI works in desktop view
709-
cy.viewport(1024, 768)
722+
// Confirm the UI works in staging environment
723+
cy.task('seedStagingDB')
710724
cy.visit(`${Cypress.env('stagingUrl')}/products`)
711-
cy.prompt(electronicsFilterPrompt)
725+
cy.prompt(electronicsFilterPrompt, {
726+
placeholders: {
727+
electronicsCount,
728+
},
729+
})
712730

713-
// Confirm the UI works in mobile view
714-
cy.viewport(400, 600)
731+
// Confirm the UI works in production environment
732+
cy.task('seedProductionDB')
715733
cy.visit(`${Cypress.env('stagingUrl')}/products`)
716-
cy.prompt(electronicsFilterPrompt)
734+
cy.prompt(electronicsFilterPrompt, {
735+
placeholders: {
736+
electronicsCount,
737+
},
738+
})
717739
```
718740

719741
## Limitations

0 commit comments

Comments
 (0)