Skip to content

Commit

Permalink
Updated Project tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalis committed May 21, 2024
1 parent 08f663b commit 1bac575
Show file tree
Hide file tree
Showing 4 changed files with 265 additions and 2 deletions.
112 changes: 112 additions & 0 deletions cypress/fixtures/edaProjectOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"name": "Project Instance",
"description": "",
"renders": ["application/json", "text/html"],
"parses": ["application/json", "application/x-www-form-urlencoded", "multipart/form-data"],
"actions": {
"PATCH": {
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name"
},
"description": {
"type": "string",
"required": false,
"read_only": false,
"label": "Description"
},
"organization_id": {
"type": "field",
"required": false,
"read_only": true,
"label": "Organization id"
},
"eda_credential_id": {
"type": "integer",
"required": false,
"read_only": false,
"label": "Eda credential id"
},
"signature_validation_credential_id": {
"type": "field",
"required": false,
"read_only": true,
"label": "Signature validation credential id"
},
"scm_branch": {
"type": "string",
"required": false,
"read_only": false,
"label": "Scm branch"
},
"scm_refspec": {
"type": "string",
"required": false,
"read_only": false,
"label": "Scm refspec"
},
"verify_ssl": {
"type": "boolean",
"required": false,
"read_only": false,
"label": "Verify ssl"
},
"proxy": {
"type": "field",
"required": false,
"read_only": true,
"label": "Proxy"
},
"id": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"url": {
"type": "string",
"required": false,
"read_only": true,
"label": "Url"
},
"scm_type": {
"type": "choice",
"required": false,
"read_only": true,
"label": "Scm type"
},
"git_hash": {
"type": "string",
"required": false,
"read_only": true,
"label": "Git hash"
},
"import_state": {
"type": "choice",
"required": false,
"read_only": true,
"label": "Import state"
},
"import_error": {
"type": "string",
"required": false,
"read_only": true,
"label": "Import error"
},
"created_at": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Created at"
},
"modified_at": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Modified at"
}
}
}
}
112 changes: 112 additions & 0 deletions cypress/fixtures/edaProjectsOptions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"name": "Project List",
"description": "",
"renders": ["application/json", "text/html"],
"parses": ["application/json", "application/x-www-form-urlencoded", "multipart/form-data"],
"actions": {
"POST": {
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name"
},
"description": {
"type": "string",
"required": false,
"read_only": false,
"label": "Description"
},
"organization_id": {
"type": "field",
"required": false,
"read_only": true,
"label": "Organization id"
},
"eda_credential_id": {
"type": "integer",
"required": false,
"read_only": false,
"label": "Eda credential id"
},
"signature_validation_credential_id": {
"type": "field",
"required": false,
"read_only": true,
"label": "Signature validation credential id"
},
"scm_branch": {
"type": "string",
"required": false,
"read_only": false,
"label": "Scm branch"
},
"scm_refspec": {
"type": "string",
"required": false,
"read_only": false,
"label": "Scm refspec"
},
"verify_ssl": {
"type": "boolean",
"required": false,
"read_only": false,
"label": "Verify ssl"
},
"proxy": {
"type": "field",
"required": false,
"read_only": true,
"label": "Proxy"
},
"id": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"url": {
"type": "string",
"required": false,
"read_only": true,
"label": "Url"
},
"scm_type": {
"type": "choice",
"required": false,
"read_only": true,
"label": "Scm type"
},
"git_hash": {
"type": "string",
"required": false,
"read_only": true,
"label": "Git hash"
},
"import_state": {
"type": "choice",
"required": false,
"read_only": true,
"label": "Import state"
},
"import_error": {
"type": "string",
"required": false,
"read_only": true,
"label": "Import error"
},
"created_at": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Created at"
},
"modified_at": {
"type": "datetime",
"required": false,
"read_only": true,
"label": "Modified at"
}
}
}
}
41 changes: 40 additions & 1 deletion frontend/eda/projects/Projects.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { Projects } from './Projects';

describe('Projects.cy.ts', () => {
beforeEach(() => {
cy.intercept(
{
method: 'OPTIONS',
url: '/api/v2/projects/',
},
{
fixture: 'edaProjectsOptions.json',
}
).as('getOptions');
cy.intercept(
{ method: 'GET', url: edaAPI`/projects/?page=1&page_size=10` },
{
Expand Down Expand Up @@ -60,7 +69,7 @@ describe('Projects.cy.ts', () => {
});
});

describe('Empty list', () => {
describe('Empty list without POST permission', () => {
beforeEach(() => {
cy.intercept(
{
Expand All @@ -72,6 +81,36 @@ describe('Empty list', () => {
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<Projects />);
cy.contains(/^You do not have permission to create a project.$/);
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`/projects/`,
},
{
fixture: 'edaProjectsOptions.json',
}
).as('getOptions');
cy.intercept(
{
method: 'GET',
url: edaAPI`/projects/*`,
},
{
fixture: 'emptyList.json',
}
).as('emptyList');
});
it('Empty state is displayed correctly', () => {
cy.mount(<Projects />);
cy.contains(/^There are currently no projects created for your organization.$/);
Expand Down
2 changes: 1 addition & 1 deletion frontend/eda/projects/Projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function Projects() {
emptyStateTitle={
canCreateProject
? t('There are currently no projects created for your organization.')
: t('You do not have permission to create a project')
: t('You do not have permission to create a project.')
}
emptyStateDescription={
canCreateProject
Expand Down

0 comments on commit 1bac575

Please sign in to comment.