Skip to content

Commit

Permalink
tests: Modify Cypress error attribute checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Sep 13, 2024
1 parent 6832d7d commit 46a8938
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
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
4 changes: 2 additions & 2 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 @@ -182,7 +182,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}';
'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
4 changes: 2 additions & 2 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 @@ -182,7 +182,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}';
'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"'
);
}
}
8 changes: 4 additions & 4 deletions cypress/support/actions/tasks/TasksAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class TasksAction {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushSqlDump:production" on "task": {"project":18}';
'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 @@ -57,7 +57,7 @@ export default class TasksAction {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushArchiveDump:production" on "task": {"project":18}';
'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 @@ -78,7 +78,7 @@ export default class TasksAction {
expect(interception.response?.statusCode).to.eq(200);

const errorMessage =
'Unauthorized: You don\'t have permission to "drushUserLogin:production" on "task": {"project":18}';
'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 +106,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

0 comments on commit 46a8938

Please sign in to comment.