|
| 1 | +/* global cy */ |
| 2 | +import { ResourceDetails } from '../ResourceDetails'; |
| 3 | +import { authDataState } from 'state/authDataAtom'; |
| 4 | +import '@ui5/webcomponents-icons/dist/AllIcons.js'; |
| 5 | + |
| 6 | +describe('ResourceDetails visibility', () => { |
| 7 | + it('Column visibility', () => { |
| 8 | + cy.intercept('GET', '**test-resource-url**', { |
| 9 | + statusCode: 200, |
| 10 | + body: { |
| 11 | + kind: 'TestKind', |
| 12 | + metadata: { |
| 13 | + name: 'test-resource-name', |
| 14 | + namespace: 'test-resource-namespace', |
| 15 | + }, |
| 16 | + }, |
| 17 | + }); |
| 18 | + |
| 19 | + const initializeRecoil = ({ set }) => { |
| 20 | + set(authDataState, { |
| 21 | + token: 'test-token', |
| 22 | + }); |
| 23 | + }; |
| 24 | + |
| 25 | + cy.mount( |
| 26 | + <ResourceDetails |
| 27 | + resourceUrl="test-resource-url" |
| 28 | + resourceType="test-resource-type" |
| 29 | + customColumns={[ |
| 30 | + { |
| 31 | + header: 'some-header--hidden', |
| 32 | + value: () => 'should not be visible', |
| 33 | + visibility: () => ({ visible: false }), |
| 34 | + }, |
| 35 | + { |
| 36 | + header: 'some-header--visible', |
| 37 | + value: () => 'should be visible', |
| 38 | + visibility: () => ({ visible: true }), |
| 39 | + }, |
| 40 | + { |
| 41 | + header: 'some-header--with-error', |
| 42 | + value: () => 'will be ignored', |
| 43 | + visibility: () => ({ error: 'error!' }), |
| 44 | + }, |
| 45 | + ]} |
| 46 | + />, |
| 47 | + { |
| 48 | + initializeRecoil, |
| 49 | + }, |
| 50 | + ); |
| 51 | + |
| 52 | + cy.contains('some-header--hidden:', { timeout: 10000 }).should('not.exist'); |
| 53 | + cy.contains('should not be visible', { timeout: 10000 }).should( |
| 54 | + 'not.exist', |
| 55 | + ); |
| 56 | + |
| 57 | + cy.contains('some-header--visible:', { timeout: 10000 }).should('exist'); |
| 58 | + cy.contains('should be visible', { timeout: 10000 }).should('exist'); |
| 59 | + |
| 60 | + cy.contains('some-header--with-error:', { timeout: 10000 }).should('exist'); |
| 61 | + cy.contains('will be ignored', { timeout: 10000 }).should('not.exist'); |
| 62 | + cy.contains('common.messages.error', { timeout: 10000 }).should('exist'); |
| 63 | + }); |
| 64 | +}); |
0 commit comments