|
1 | 1 | describe('Vite React Typescript Template Test Suite', () => { |
2 | 2 | it('should navigate to about page', () => { |
3 | 3 | cy.visit('/'); |
4 | | - cy.get('.MuiCardHeader-content > .MuiTypography-root').should('contain.text', 'Home Page'); |
| 4 | + cy.findByRole('heading', { level: 5 }).should('contain.text', 'Home Page'); |
5 | 5 | cy.get('button>a:contains("About")').click(); |
6 | | - cy.get('.MuiCardHeader-content > .MuiTypography-root').should('contain.text', 'About Page'); |
| 6 | + cy.findByRole('heading', { level: 5 }).should('contain.text', 'About Page'); |
7 | 7 | }); |
8 | 8 |
|
9 | 9 | it('should perform counter operations', () => { |
10 | 10 | cy.visit('/'); |
11 | 11 |
|
12 | | - cy.contains('Decrement By 1').click(); |
| 12 | + cy.findByRole('button', { name: 'Decrement' }).click(); |
13 | 13 | cy.get('.Counter [role="note"]').should('contain.text', 'count is -1'); |
14 | 14 |
|
15 | | - cy.contains('Increment By 1').click(); |
| 15 | + cy.findByRole('button', { name: 'Increment' }).click(); |
16 | 16 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 0'); |
17 | 17 |
|
18 | 18 | cy.get('input.MuiInput-input').clear().type('5'); |
19 | | - cy.contains('Increment By Value').click(); |
| 19 | + cy.findByRole('button', { name: 'Increment By Value' }).click(); |
20 | 20 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 5'); |
21 | 21 |
|
22 | 22 | cy.get('input.MuiInput-input').clear().type('-5'); |
23 | | - cy.contains('Increment By Value').click(); |
| 23 | + cy.findByRole('button', { name: 'Increment By Value' }).click(); |
24 | 24 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 0'); |
25 | 25 |
|
26 | | - cy.contains('Decrement Async By 1').click(); |
| 26 | + cy.findByRole('button', { name: 'Decrement Async' }).click(); |
27 | 27 | cy.get('.Counter [role="note"]').should('contain.text', 'count is -1'); |
28 | 28 |
|
29 | | - cy.contains('Increment Async By 1').click(); |
| 29 | + cy.findByRole('button', { name: 'Increment Async' }).click(); |
30 | 30 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 0'); |
31 | 31 |
|
32 | 32 | cy.get('input.MuiInput-input').clear().type('5'); |
33 | | - cy.contains('Increment Async By Value').click(); |
| 33 | + cy.findByRole('button', { name: 'Increment Async By Value' }).click(); |
34 | 34 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 5'); |
35 | 35 |
|
36 | 36 | cy.get('input.MuiInput-input').clear().type('-5'); |
37 | | - cy.contains('Increment Async By Value').click(); |
| 37 | + cy.findByRole('button', { name: 'Increment Async By Value' }).click(); |
38 | 38 | cy.get('.Counter [role="note"]').should('contain.text', 'count is 0'); |
39 | 39 | }); |
40 | 40 |
|
41 | 41 | it('should count value persist on routing', () => { |
42 | 42 | cy.visit('/'); |
43 | 43 |
|
44 | | - cy.contains('Decrement By 1').click(); |
| 44 | + cy.contains('Decrement').click(); |
45 | 45 | cy.get('.Counter [role="note"]').should('contain.text', 'count is -1'); |
46 | 46 |
|
47 | 47 | cy.get('button>a:contains("About")').click(); |
48 | | - cy.get('.MuiCardHeader-content > .MuiTypography-root').should('contain.text', 'About Page'); |
| 48 | + cy.findByRole('heading', { level: 5 }).should('contain.text', 'About Page'); |
49 | 49 |
|
50 | 50 | cy.get('.Counter [role="note"]').should('contain.text', 'count is -1'); |
51 | 51 | }); |
|
0 commit comments