Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Modify Cypress error attribute checks #296

Merged
merged 4 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/e2e/rbac/developer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('DEVELOPER permission test suites', () => {
cy.wait('@gqladdEnvVariableMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/rbac/guest.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('GUEST permission test suites', () => {
cy.wait('@gqladdEnvVariableMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down Expand Up @@ -181,8 +181,7 @@ describe('GUEST permission test suites', () => {

cy.waitForNetworkIdle('@idle', 500);

const errMessage =
'Error: GraphQL error: Unauthorized: You don\'t have permission to "view" on "backup": {"project":18}';
const errMessage = 'Error: GraphQL error: Unauthorized: You don\'t have permission to "view" on "backup"';

cy.get('main').should('exist').find('p').should('exist').and('have.text', errMessage);
});
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/rbac/organizations/orgViewer.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe(`Organizations ORGVIEWER journey`, () => {

cy.wait('@gqladdProjectToGroupMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);
const errorMessage = `Unauthorized: You don't have permission to "addGroup" on "organization": {"organization":1}`;
const errorMessage = `Unauthorized: You don't have permission to "addGroup" on "organization"`;
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand All @@ -121,7 +121,7 @@ describe(`Organizations ORGVIEWER journey`, () => {

cy.wait('@gqladdNotificationToProjectMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);
const errorMessage = `Unauthorized: You don't have permission to "addNotification" on "organization": {"organization":1}`;
const errorMessage = `Unauthorized: You don't have permission to "addNotification" on "organization"`;

expect(interception.response?.body).to.have.property('errors');

Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/rbac/reporter.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('REPORTER permission test suites', () => {
cy.wait('@gqladdEnvVariableMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "project:add" on "env_var"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down Expand Up @@ -181,8 +181,7 @@ describe('REPORTER permission test suites', () => {

cy.waitForNetworkIdle('@idle', 500);

const errMessage =
'Error: GraphQL error: Unauthorized: You don\'t have permission to "view" on "backup": {"project":18}';
const errMessage = 'Error: GraphQL error: Unauthorized: You don\'t have permission to "view" on "backup"';

cy.get('main').should('exist').find('p').should('exist').and('have.text', errMessage);
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/actions/envOverview/EnvOverviewAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class EnvOverviewAction {

const errorMessage = `Unauthorized: You don\'t have permission to "delete:${
branch === 'main' ? 'production' : 'development'
}" on "environment": {"project":18}`;
}" on "environment"`;

cy.wait('@gqldeleteEnvironmentMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/actions/organizations/GroupsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class GroupAction {
cy.wait('@gqladdGroupToOrganizationMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = `Unauthorized: You don't have permission to "addGroup" on "organization": {"organization":1}`;
const errorMessage = `Unauthorized: You don't have permission to "addGroup" on "organization"`;
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class NotificationsAction {
cy.wait(`@gqladdNotification${getMutationName(notifType)}Mutation`).then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = `Unauthorized: You don't have permission to "addNotification" on "organization": {"organization":1}`;
const errorMessage = `Unauthorized: You don't have permission to "addNotification" on "organization"`;

expect(interception.response?.body).to.have.property('errors');

Expand Down
4 changes: 2 additions & 2 deletions cypress/support/actions/organizations/OverviewAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default class OverviewAction {
cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "updateOrganization" on "organization": 1';
const errorMessage = 'Unauthorized: You don\'t have permission to "updateOrganization" on "organization"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down Expand Up @@ -92,7 +92,7 @@ export default class OverviewAction {
cy.wait('@gqlupdateOrganizationFriendlyNameMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "updateOrganization" on "organization": 1';
const errorMessage = 'Unauthorized: You don\'t have permission to "updateOrganization" on "organization"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/actions/organizations/ProjectsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class ProjectsActions {
cy.wait('@gqladdProjectToOrganizationMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = `Unauthorized: You don't have permission to "addProject" on "organization": {"organization":1}`;
const errorMessage = `Unauthorized: You don't have permission to "addProject" on "organization"`;
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down
2 changes: 1 addition & 1 deletion cypress/support/actions/project/ProjectAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default class ProjectAction {
.should('exist')
.should(
'include.text',
'GraphQL error: Unauthorized: You don\'t have permission to "deploy:development" on "environment": {"project":18}'
'GraphQL error: Unauthorized: You don\'t have permission to "deploy:development" on "environment"'
);
}
}
11 changes: 4 additions & 7 deletions cypress/support/actions/tasks/TasksAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default class TasksAction {
cy.wait('@gqltaskDrushSqlDumpMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushSqlDump:production" on "task": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "drushSqlDump:production" on "task"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand All @@ -56,8 +55,7 @@ export default class TasksAction {
cy.wait('@gqltaskDrushArchiveDumpMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushArchiveDump:production" on "task": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "drushArchiveDump:production" on "task"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand All @@ -77,8 +75,7 @@ export default class TasksAction {
cy.wait('@gqltaskDrushUserLoginMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushUserLogin:production" on "task": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "drushUserLogin:production" on "task"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down Expand Up @@ -106,7 +103,7 @@ export default class TasksAction {
cy.wait('@gqlcancelTaskMutation').then(interception => {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage = 'Unauthorized: You don\'t have permission to "cancel:production" on "task": {"project":18}';
const errorMessage = 'Unauthorized: You don\'t have permission to "cancel:production" on "task"';
expect(interception.response?.body).to.have.property('errors');

cy.wrap(interception.response?.body.errors[0]).should('deep.include', { message: errorMessage });
Expand Down
8 changes: 3 additions & 5 deletions test/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.2'

name: lagoon-minimal

services:
Expand Down Expand Up @@ -41,12 +39,12 @@ services:
networks:
- default
environment:
- KEYCLOAK_URL=http://172.17.0.1:38088
- KEYCLOAK_FRONTEND_URL=http://172.17.0.1:38088
- NODE_ENV=development
- OPENSEARCH_INTEGRATION_ENABLED=false
- DISABLE_CORE_HARBOR=true
- CI=${CI:-true}
- S3_FILES_HOST=http://0.0.0.0:39000
- S3_FILES_HOST=http://172.17.0.1:39000
- S3_BAAS_ACCESS_KEY_ID=minio
- S3_BAAS_SECRET_ACCESS_KEY=minio123
- CONSOLE_LOGGING_LEVEL=trace
Expand Down Expand Up @@ -89,4 +87,4 @@ services:
command: ["bash", "-c", "
wait-for api:3000 -t 600;
/home/data-init-push.sh;
"]
"]
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"suppressImplicitAnyIndexErrors": true,
"ignoreDeprecations": "5.0",
"noEmit": true,
"incremental": true,
Expand Down