Skip to content

Commit

Permalink
Updated tests for empty lists
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed May 23, 2024
1 parent cc19963 commit 21d6abb
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 5 deletions.
51 changes: 51 additions & 0 deletions frontend/eda/access/credential-types/CredentialTypes.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { edaAPI } from '../../common/eda-utils';
import { CredentialTypes } from './CredentialTypes';
import { Projects } from '../../projects/Projects';

describe('CredentialTypes.cy.ts', () => {
beforeEach(() => {
Expand Down Expand Up @@ -289,3 +290,53 @@ describe('CredentialTypes.cy.ts', () => {
cy.contains('th', 'Name');
});
});

describe('Empty list without POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'GET',
url: edaAPI`/credential-types/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<CredentialTypes />);
cy.contains(/^You do not have permission to create a credential type.$/);
cy.contains(
/^Please contact your organization administrator if there is an issue with your access.$/
);
});
});

describe('Empty list with POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'OPTIONS',
url: edaAPI`/credential-types/`,
},
{
fixture: 'edaCredentialTypesOptions.json',
}
).as('getOptions');
cy.intercept(
{
method: 'GET',
url: edaAPI`/credential-types/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<Projects />);
cy.contains(/^There are currently no credential types created for your organization.$/);
cy.contains(/^Please create a credential type by using the button below.$/);
cy.contains('button', /^Create credential type$/).should('be.visible');
});
});
32 changes: 31 additions & 1 deletion frontend/eda/access/credentials/Credentials.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe('Credentials.cy.ts', () => {
});
});

describe('Empty list', () => {
describe('Empty list without POST permission', () => {
beforeEach(() => {
cy.intercept(
{
Expand All @@ -205,6 +205,36 @@ describe('Empty list', () => {
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<Credentials />);
cy.contains(/^You do not have permission to create a credential.$/);
cy.contains(
/^Please contact your organization administrator if there is an issue with your access.$/
);
});
});

describe('Empty list with POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'OPTIONS',
url: edaAPI`/eda-credentials/`,
},
{
fixture: 'edaCredentialsOptions.json',
}
).as('getOptions');
cy.intercept(
{
method: 'GET',
url: edaAPI`/eda-credentials/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<Credentials />);
cy.contains(/^There are currently no credentials created for your organization.$/);
Expand Down
34 changes: 32 additions & 2 deletions frontend/eda/decision-environments/DecisionEnvironments.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,42 @@ describe('DecisionEnvironments.cy.ts', () => {
});
});

describe('Empty list', () => {
describe('Empty list without POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'GET',
url: '/api/eda/v1/decision-environments/*',
url: edaAPI`/decision-environments/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<DecisionEnvironments />);
cy.contains(/^You do not have permission to create a decision environment.$/);
cy.contains(
/^Please contact your organization administrator if there is an issue with your access.$/
);
});
});

describe('Empty list with POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'OPTIONS',
url: edaAPI`/decision-environments/`,
},
{
fixture: 'edaDecisionEnvironmentsOptions.json',
}
).as('getOptions');
cy.intercept(
{
method: 'GET',
url: edaAPI`/decision-environments/*`,
},
{
fixture: 'emptyList.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function DecisionEnvironments() {
emptyStateTitle={
canCreateDE
? t('There are currently no decision environments created for your organization.')
: t('You do not have permission to create a decision environment')
: t('You do not have permission to create a decision environment.')
}
emptyStateDescription={
canCreateDE
Expand Down
32 changes: 31 additions & 1 deletion frontend/eda/rulebook-activations/RulebookActivations.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('RulebookActivations.cy.ts', () => {
});
});

describe('Empty list', () => {
describe('Empty list without POST permission', () => {
beforeEach(() => {
cy.intercept(
{
Expand All @@ -187,6 +187,36 @@ describe('Empty list', () => {
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<RulebookActivations />);
cy.contains(/^You do not have permission to create a rulebook activation.$/);
cy.contains(
/^Please contact your organization administrator if there is an issue with your access.$/
);
});
});

describe('Empty list with POST permission', () => {
beforeEach(() => {
cy.intercept(
{
method: 'OPTIONS',
url: edaAPI`/activations/`,
},
{
fixture: 'edaActivationsOptions.json',
}
).as('getOptions');
cy.intercept(
{
method: 'GET',
url: edaAPI`/activations/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<RulebookActivations />);
cy.contains(/^There are currently no rulebook activations created for your organization.$/);
Expand Down

0 comments on commit 21d6abb

Please sign in to comment.