Skip to content

Commit

Permalink
Added explicit test failures if a rejection is handled
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkobori committed May 14, 2024
1 parent 8d58f26 commit 1706c68
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions cypress/component/unit/ajax/User.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ describe('User', () => {
cy.intercept('GET', 'api/user/me', { statusCode: 404 }).as('getMe');
try {
await User.getMe();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -144,6 +145,7 @@ describe('User', () => {
cy.intercept('GET', 'api/user/*', { statusCode: 404 }).as('getById');
try {
await User.getById(testUser1.userId);
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -186,14 +188,14 @@ describe('User', () => {
cy.intercept('GET', 'api/user/role/*', { statusCode: 404 }).as('list');
try {
await User.list('Admin');
assert(false, 'Rejection handled or not thrown');
} catch (err) {
assert(true);
assert(true, 'Rejection not handled');
}
});
});
});

//TODO
describe('create', () => {
beforeEach(() => {
cy.intercept('POST', 'api/dacuser', testUser1).as('create');
Expand Down Expand Up @@ -376,8 +378,9 @@ describe('User', () => {
);
try {
await User.registerUser();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
assert(true);
assert(true, 'Rejection not handled');
}
});
});
Expand Down Expand Up @@ -424,8 +427,9 @@ describe('User', () => {
}).as('getSOsForCurrentUser');
try {
await User.getSOsForCurrentUser();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
assert(true);
assert(true, 'Rejection not handled');
}
});
});
Expand Down Expand Up @@ -472,6 +476,7 @@ describe('User', () => {
}).as('getUnassignedUsers');
try {
await User.getUnassignedUsers();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -517,8 +522,9 @@ describe('User', () => {
);
try {
await User.addRoleToUser(testUser1.userId, newRoleId);
assert(false, 'Rejection handled or not thrown');
} catch (err) {
assert(true);
assert(true, 'Rejection not handled');
}
});
});
Expand Down Expand Up @@ -563,8 +569,9 @@ describe('User', () => {
);
try {
await User.deleteRoleFromUser(testUser1.userId, roleIdToDelete);
assert(false, 'Rejection handled or not thrown');
} catch (err) {
assert(true);
assert(true, 'Rejection not handled');
}
});
});
Expand Down Expand Up @@ -610,6 +617,7 @@ describe('User', () => {
);
try {
await User.getUserRelevantDatasets();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -652,6 +660,7 @@ describe('User', () => {
}).as('getAcknowledgements');
try {
await User.getAcknowledgements();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -734,6 +743,7 @@ describe('User', () => {
acknowledgements.testAck1,
acknowledgements.testAck2
);
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down Expand Up @@ -786,6 +796,7 @@ describe('User', () => {
}).as('getApprovedDatasets');
try {
await User.getApprovedDatasets();
assert(false, 'Rejection handled or not thrown');
} catch (err) {
expect(err.response.status).to.eq(404);
}
Expand Down

0 comments on commit 1706c68

Please sign in to comment.