|
1 | 1 | /* eslint-disable no-undef */ |
2 | 2 |
|
3 | | -describe('Configuration tab', () => { |
4 | | - before(() => { |
5 | | - // Set the token in local storage |
6 | | - cy.window().then((win) => { |
7 | | - if (!win.localStorage.getItem('token')) { |
8 | | - win.localStorage.setItem('token', 'demo-token') |
9 | | - } |
10 | | - }) |
| 3 | +Cypress.on('uncaught:exception', () => { |
| 4 | + return false |
| 5 | +}) |
| 6 | + |
| 7 | +// Function to set up intercepts for the requests |
| 8 | +function setupIntercepts() { |
| 9 | + cy.intercept('GET', '/healthz*', { |
| 10 | + statusCode: 200, |
| 11 | + body: { |
| 12 | + edition: 'standard', |
| 13 | + }, |
11 | 14 | }) |
12 | 15 |
|
13 | | - it('should have token in local storage', ()=> { |
14 | | - // Check if the token exists in local storage |
15 | | - cy.window() |
16 | | - .should('have.property','localStorage') |
17 | | - .and('have.property','token','demo-token') |
| 16 | + cy.intercept('GET', '/instance/retrieval*', { |
| 17 | + statusCode: 200, |
| 18 | + body: { |
| 19 | + status: 'inactive', |
| 20 | + }, |
18 | 21 | }) |
19 | 22 |
|
20 | | - it('should have "Configuration" tab with form inputs', () => { |
21 | | - // Visit the page |
22 | | - cy.visit('/', { |
23 | | - retryOnStatusCodeFailure: true, |
24 | | - onLoad: () => { |
25 | | - // Click on the "Configuration" tab |
26 | | - cy.get('.MuiTabs-flexContainer').contains('Configuration').click({ |
27 | | - force: true, |
28 | | - }) |
29 | | - |
30 | | - // Check for elements on the "Configuration" tab |
31 | | - cy.get('input[type="text"]').should('exist') |
32 | | - cy.get('input[type="checkbox"]').should('exist') |
33 | | - cy.get('button[type="button"]').should('exist') |
34 | | - |
35 | | - // Click on the "Cancel" button within the "Configuration" tab |
36 | | - cy.get('button').contains('Cancel').click({ |
37 | | - force: true, |
38 | | - }) |
39 | | - |
40 | | - // Check if the URL has changed to "/instance" |
41 | | - cy.url().should('eq', Cypress.config().baseUrl + '/instance') |
| 23 | + cy.intercept('GET', '/status*', { |
| 24 | + statusCode: 200, |
| 25 | + body: { |
| 26 | + status: { |
| 27 | + code: 'OK', |
| 28 | + message: 'Instance is ready', |
| 29 | + }, |
| 30 | + pools: [], |
| 31 | + cloning: { |
| 32 | + clones: [], |
42 | 33 | }, |
| 34 | + retrieving: { |
| 35 | + status: 'inactive', |
| 36 | + }, |
| 37 | + }, |
| 38 | + }) |
| 39 | +} |
| 40 | + |
| 41 | +describe('Configuration tab', () => { |
| 42 | + beforeEach(() => { |
| 43 | + cy.visit('/') |
| 44 | + setupIntercepts() |
| 45 | + }) |
| 46 | + |
| 47 | + it('should have "Configuration" tab with form inputs', () => { |
| 48 | + cy.get('.MuiTabs-flexContainer').contains('Configuration').click({ |
| 49 | + force: true, |
| 50 | + }) |
| 51 | + |
| 52 | + cy.get('input[type="text"]').should('exist') |
| 53 | + cy.get('input[type="checkbox"]').should('exist') |
| 54 | + cy.get('button[type="button"]').should('exist') |
| 55 | + |
| 56 | + cy.get('button').contains('Cancel').click({ |
| 57 | + force: true, |
43 | 58 | }) |
| 59 | + cy.url().should('eq', Cypress.config().baseUrl + '/instance') |
44 | 60 | }) |
45 | 61 | }) |
0 commit comments