mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
✅ Adding more unit tests
This commit is contained in:
parent
93a118cc67
commit
218ac8bcee
|
@ -133,14 +133,56 @@ describe('ResourceLocator', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('renders permission error correctly', async () => {
|
||||
const TEST_401_ERROR = {
|
||||
message: 'Failed to load resources',
|
||||
// Testing error message deduplication
|
||||
describe('ResourceLocator credentials error handling', () => {
|
||||
it.each([
|
||||
{
|
||||
testName: 'period-separated credential message',
|
||||
error: {
|
||||
message: 'Authentication failed. Please check your credentials.',
|
||||
httpCode: '401',
|
||||
description: 'Authentication failed. Please check your credentials.',
|
||||
};
|
||||
|
||||
nodeTypesStore.getResourceLocatorResults.mockRejectedValue(TEST_401_ERROR);
|
||||
},
|
||||
expectedMessage: 'Authentication failed.',
|
||||
},
|
||||
{
|
||||
testName: 'dash-separated credential message',
|
||||
error: {
|
||||
message: 'Authentication failed - Please check your credentials.',
|
||||
httpCode: '401',
|
||||
description: 'Authentication failed. Please check your credentials.',
|
||||
},
|
||||
expectedMessage: 'Authentication failed',
|
||||
},
|
||||
{
|
||||
testName: 'credential message with "Perhaps" phrasing',
|
||||
error: {
|
||||
message: 'Authentication failed - Perhaps check your credentials?',
|
||||
httpCode: '401',
|
||||
description: 'Authentication failed. Please check your credentials.',
|
||||
},
|
||||
expectedMessage: 'Authentication failed',
|
||||
},
|
||||
{
|
||||
testName: 'singular credential phrasing',
|
||||
error: {
|
||||
message: 'Authentication failed. You should check your credential.',
|
||||
httpCode: '401',
|
||||
description: 'Authentication failed.',
|
||||
},
|
||||
expectedMessage: 'Authentication failed.',
|
||||
},
|
||||
{
|
||||
testName: 'verify credentials phrasing',
|
||||
error: {
|
||||
message: 'Authentication failed - Please verify your credentials.',
|
||||
httpCode: '401',
|
||||
description: 'Authentication failed.',
|
||||
},
|
||||
expectedMessage: 'Authentication failed',
|
||||
},
|
||||
])('$testName', async ({ error, expectedMessage }) => {
|
||||
nodeTypesStore.getResourceLocatorResults.mockRejectedValue(error);
|
||||
|
||||
const { getByTestId, findByTestId } = renderComponent();
|
||||
|
||||
|
@ -154,8 +196,8 @@ describe('ResourceLocator', () => {
|
|||
const errorContainer = await findByTestId('rlc-error-container');
|
||||
expect(errorContainer).toBeInTheDocument();
|
||||
|
||||
expect(errorContainer).toHaveTextContent(TEST_401_ERROR.httpCode);
|
||||
expect(errorContainer).toHaveTextContent(TEST_401_ERROR.message);
|
||||
expect(getByTestId('rlc-error-code')).toHaveTextContent(error.httpCode);
|
||||
expect(getByTestId('rlc-error-message')).toHaveTextContent(expectedMessage);
|
||||
|
||||
expect(getByTestId('permission-error-link')).toBeInTheDocument();
|
||||
});
|
||||
|
@ -187,3 +229,4 @@ describe('ResourceLocator', () => {
|
|||
expect(queryByTestId('permission-error-link')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -849,10 +849,12 @@ function removeOverride() {
|
|||
</n8n-text>
|
||||
<div v-if="currentResponse.errorDetails" :class="$style.errorDetails">
|
||||
<n8n-text size="small">
|
||||
<span v-if="currentResponse.errorDetails.httpCode">
|
||||
<span v-if="currentResponse.errorDetails.httpCode" data-test-id="rlc-error-code">
|
||||
{{ currentResponse.errorDetails.httpCode }} -
|
||||
</span>
|
||||
{{ currentResponse.errorDetails.message }}
|
||||
<span data-test-id="rlc-error-message">{{
|
||||
currentResponse.errorDetails.message
|
||||
}}</span>
|
||||
</n8n-text>
|
||||
<N8nNotice
|
||||
v-if="currentResponse.errorDetails.description"
|
||||
|
|
Loading…
Reference in a new issue