Merge pull request #13426 from backstage/freben/fix-lint-errors
Fix linting errors after #13392
This commit is contained in:
@@ -8,3 +8,6 @@ Note that this major update to the Jest plugin contains some breaking changes.
|
||||
This means that some of your tests may start seeing some new lint errors. [Read
|
||||
about them
|
||||
here](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md#2700-2022-08-28).
|
||||
|
||||
These are mostly possible to fix automatically. You can try to run `yarn backstage-cli repo lint --fix` in your repo root to have most or all of them
|
||||
corrected.
|
||||
|
||||
+2
-2
@@ -65,7 +65,7 @@ describe('CacheManager', () => {
|
||||
const config = new ConfigReader({ backend: {} });
|
||||
expect(() => {
|
||||
CacheManager.fromConfig(config);
|
||||
}).not.toThrowError();
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it('throws on unknown cache store', () => {
|
||||
@@ -74,7 +74,7 @@ describe('CacheManager', () => {
|
||||
});
|
||||
expect(() => {
|
||||
CacheManager.fromConfig(config);
|
||||
}).toThrowError();
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(Math.abs(+child.deadline! - deadline)).toBeLessThan(50);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
jest.advanceTimersByTime(timeout + 1);
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('results in minimum deadline when parent triggers sooner', async () => {
|
||||
@@ -66,15 +66,15 @@ describe('AbortContext', () => {
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50);
|
||||
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
jest.advanceTimersByTime(parentTimeout + 1);
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(1);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(1);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('results in minimum deadline when child triggers sooner', async () => {
|
||||
@@ -98,22 +98,22 @@ describe('AbortContext', () => {
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(Math.abs(+parent.deadline! - parentDeadline)).toBeLessThan(50);
|
||||
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
jest.advanceTimersByTime(childTimeout + 1);
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
|
||||
jest.advanceTimersByTime(parentTimeout - childTimeout + 1);
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(1);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(1);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('child carries over parent signal state if parent was already aborted and had no deadline', async () => {
|
||||
@@ -133,13 +133,13 @@ describe('AbortContext', () => {
|
||||
child.abortSignal.addEventListener('abort', childListener);
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
expect(Math.abs(+child.deadline! - childDeadline)).toBeLessThan(50);
|
||||
|
||||
jest.advanceTimersByTime(childTimeout + 1);
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0); // still
|
||||
expect(childListener).toHaveBeenCalledTimes(0); // still
|
||||
});
|
||||
|
||||
it('child carries over parent signal state if parent was already aborted and had a deadline', async () => {
|
||||
@@ -175,15 +175,15 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
parentController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(1);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(1);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not signal parent when child is aborted', async () => {
|
||||
@@ -201,15 +201,15 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
childController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('child carries over parent signal state if parent was already aborted', async () => {
|
||||
@@ -227,13 +227,13 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
childController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('child carries over given signal state if it was already aborted', async () => {
|
||||
@@ -247,7 +247,7 @@ describe('AbortContext', () => {
|
||||
child.abortSignal.addEventListener('abort', childListener);
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -267,15 +267,15 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
parentController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(1);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(1);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not signal parent when child is aborted', async () => {
|
||||
@@ -293,15 +293,15 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(false);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
childController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(false);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(parentListener).toBeCalledTimes(0);
|
||||
expect(childListener).toBeCalledTimes(1);
|
||||
expect(parentListener).toHaveBeenCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('child carries over parent signal state if parent was already aborted', async () => {
|
||||
@@ -319,13 +319,13 @@ describe('AbortContext', () => {
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
|
||||
childController.abort();
|
||||
|
||||
expect(parent.abortSignal.aborted).toBe(true);
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('child carries over given signal state if it was already aborted', async () => {
|
||||
@@ -339,7 +339,7 @@ describe('AbortContext', () => {
|
||||
child.abortSignal.addEventListener('abort', childListener);
|
||||
|
||||
expect(child.abortSignal.aborted).toBe(true);
|
||||
expect(childListener).toBeCalledTimes(0);
|
||||
expect(childListener).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('database connection', () => {
|
||||
connection: '',
|
||||
}),
|
||||
),
|
||||
).toThrowError();
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('throws an error without a connection', () => {
|
||||
@@ -120,7 +120,7 @@ describe('database connection', () => {
|
||||
client: 'pg',
|
||||
}),
|
||||
),
|
||||
).toThrowError();
|
||||
).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('database connection', () => {
|
||||
});
|
||||
|
||||
it('throws an error for unknown connection', () => {
|
||||
expect(() => createNameOverride('unknown', 'testname')).toThrowError();
|
||||
expect(() => createNameOverride('unknown', 'testname')).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ describe('postgres', () => {
|
||||
'postgresql://postgres:pass@localhost:5432/dbname?sslrootcert=/path/to/file',
|
||||
),
|
||||
),
|
||||
).toThrowError(/no such file or directory/);
|
||||
).toThrow(/no such file or directory/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -551,7 +551,7 @@ describe('GithubUrlReader', () => {
|
||||
credentialsProvider: mockCredentialsProvider,
|
||||
},
|
||||
);
|
||||
}).toThrowError('must configure an explicit apiBaseUrl');
|
||||
}).toThrow('must configure an explicit apiBaseUrl');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ describe('GcsUrlReader', () => {
|
||||
|
||||
it('throws if search url looks truly glob-y', async () => {
|
||||
const glob = 'https://storage.cloud.google.com/bucket/**/path*';
|
||||
await expect(() => reader.search(glob)).rejects.toThrowError(
|
||||
await expect(() => reader.search(glob)).rejects.toThrow(
|
||||
'GcsUrlReader only supports prefix-based searches',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -55,7 +55,7 @@ describe('ReadUrlResponseFactory', () => {
|
||||
it('buffer cannot be called after stream is called', async () => {
|
||||
const response = await ReadUrlResponseFactory.fromReadable(readable);
|
||||
response.stream!();
|
||||
expect(() => response.buffer()).toThrowError(ConflictError);
|
||||
expect(() => response.buffer()).toThrow(ConflictError);
|
||||
});
|
||||
|
||||
it('stream returns expected data', async () => {
|
||||
@@ -68,7 +68,7 @@ describe('ReadUrlResponseFactory', () => {
|
||||
it('stream cannot be called after buffer is called', async () => {
|
||||
const response = await ReadUrlResponseFactory.fromReadable(readable);
|
||||
response.buffer();
|
||||
expect(() => response.stream!()).toThrowError(ConflictError);
|
||||
expect(() => response.stream!()).toThrow(ConflictError);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('UrlReaderPredicateMux', () => {
|
||||
it('throws an error if no predicate matches', async () => {
|
||||
const mux = new UrlReaderPredicateMux(getVoidLogger());
|
||||
|
||||
await expect(mux.readUrl('http://foo/1')).rejects.toThrowError(
|
||||
await expect(mux.readUrl('http://foo/1')).rejects.toThrow(
|
||||
/^Reading from 'http:\/\/foo\/1' is not allowed. You may/,
|
||||
);
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('UrlReaderPredicateMux', () => {
|
||||
|
||||
await expect(mux.readUrl('http://foo/1')).resolves.toBeUndefined();
|
||||
|
||||
await expect(mux.readUrl('http://bar/1')).rejects.toThrowError(
|
||||
await expect(mux.readUrl('http://bar/1')).rejects.toThrow(
|
||||
/^Reading from 'http:\/\/bar\/1' is not allowed. You may/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -66,9 +66,9 @@ describe('ServerTokenManager', () => {
|
||||
const tokenManager = ServerTokenManager.fromConfig(configWithSecret, {
|
||||
logger,
|
||||
});
|
||||
await expect(
|
||||
tokenManager.authenticate('random-string'),
|
||||
).rejects.toThrowError(/invalid server token/i);
|
||||
await expect(tokenManager.authenticate('random-string')).rejects.toThrow(
|
||||
/invalid server token/i,
|
||||
);
|
||||
});
|
||||
|
||||
it('should validate server tokens created by a different instance using the same secret', async () => {
|
||||
@@ -129,7 +129,7 @@ describe('ServerTokenManager', () => {
|
||||
|
||||
const { token } = await tokenManager1.getToken();
|
||||
|
||||
await expect(tokenManager2.authenticate(token)).rejects.toThrowError(
|
||||
await expect(tokenManager2.authenticate(token)).rejects.toThrow(
|
||||
/invalid server token/i,
|
||||
);
|
||||
});
|
||||
@@ -145,7 +145,7 @@ describe('ServerTokenManager', () => {
|
||||
|
||||
const { token } = await noopTokenManager.getToken();
|
||||
|
||||
await expect(tokenManager.authenticate(token)).rejects.toThrowError(
|
||||
await expect(tokenManager.authenticate(token)).rejects.toThrow(
|
||||
/invalid server token/i,
|
||||
);
|
||||
});
|
||||
@@ -164,7 +164,7 @@ describe('ServerTokenManager', () => {
|
||||
|
||||
const { token } = await tokenManager2.getToken();
|
||||
|
||||
await expect(tokenManager1.authenticate(token)).rejects.toThrowError(
|
||||
await expect(tokenManager1.authenticate(token)).rejects.toThrow(
|
||||
/invalid server token/i,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -37,16 +37,16 @@ describe('LocalTaskWorker', () => {
|
||||
);
|
||||
|
||||
// TODO(freben): Rewrite to fake timers - tried, but it wouldn't work
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
controller.abort();
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('runs the happy path (with a cron expression) and handles cancellation', async () => {
|
||||
@@ -69,16 +69,16 @@ describe('LocalTaskWorker', () => {
|
||||
);
|
||||
|
||||
// TODO(freben): Rewrite to fake timers - tried, but it wouldn't work
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
controller.abort();
|
||||
await new Promise(r => setTimeout(r, 1000));
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('can trigger to abort wait', async () => {
|
||||
@@ -93,13 +93,13 @@ describe('LocalTaskWorker', () => {
|
||||
});
|
||||
|
||||
// TODO(freben): Rewrite to fake timers - tried, but it wouldn't work
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
expect(fn).toBeCalledTimes(0);
|
||||
expect(fn).toHaveBeenCalledTimes(0);
|
||||
await new Promise(r => setTimeout(r, 200));
|
||||
expect(fn).toBeCalledTimes(1);
|
||||
expect(fn).toHaveBeenCalledTimes(1);
|
||||
worker.trigger();
|
||||
await new Promise(r => setTimeout(r, 10));
|
||||
expect(fn).toBeCalledTimes(2);
|
||||
expect(fn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ describe('TaskScheduler', () => {
|
||||
});
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(fn).toBeCalled();
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
},
|
||||
60_000,
|
||||
@@ -74,7 +74,7 @@ describe('TaskScheduler', () => {
|
||||
});
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(fn).toBeCalled();
|
||||
expect(fn).toHaveBeenCalled();
|
||||
});
|
||||
},
|
||||
60_000,
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('TaskWorker', () => {
|
||||
worker.start(settings);
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(logger.error).toBeCalled();
|
||||
expect(logger.error).toHaveBeenCalled();
|
||||
});
|
||||
},
|
||||
60_000,
|
||||
@@ -162,7 +162,7 @@ describe('TaskWorker', () => {
|
||||
worker.start(settings);
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(fn).toBeCalledTimes(3);
|
||||
expect(fn).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
},
|
||||
60_000,
|
||||
@@ -309,9 +309,9 @@ describe('TaskWorker', () => {
|
||||
);
|
||||
await worker1.start(settings, { signal: abortFirst.signal });
|
||||
|
||||
expect(fn1).toBeCalledTimes(0);
|
||||
expect(fn1).toHaveBeenCalledTimes(0);
|
||||
await new Promise(resolve => setTimeout(resolve, 250));
|
||||
expect(fn1).toBeCalledTimes(0);
|
||||
expect(fn1).toHaveBeenCalledTimes(0);
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
expect(fn1.mock.calls.length).toBeGreaterThan(0);
|
||||
|
||||
|
||||
@@ -92,6 +92,6 @@ describe('TestBackend', () => {
|
||||
features: [testModule({})],
|
||||
});
|
||||
|
||||
expect(testFn).toBeCalledWith('winning');
|
||||
expect(testFn).toHaveBeenCalledWith('winning');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -67,8 +67,8 @@ describe('EntityPolicies', () => {
|
||||
p2.enforce.mockResolvedValue(entity2);
|
||||
const policy = EntityPolicies.allOf([p1, p2]);
|
||||
await expect(policy.enforce(entity1)).resolves.toBe(entity2);
|
||||
expect(p1.enforce).toBeCalledWith(entity1);
|
||||
expect(p2.enforce).toBeCalledWith(entity2);
|
||||
expect(p1.enforce).toHaveBeenCalledWith(entity1);
|
||||
expect(p2.enforce).toHaveBeenCalledWith(entity2);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ describe('PluginProtocolResolverFetchMiddleware', () => {
|
||||
|
||||
await outer(url);
|
||||
expect(inner.mock.calls[0][0]).toBe(url);
|
||||
expect(resolve).not.toBeCalled();
|
||||
expect(resolve).not.toHaveBeenCalled();
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+8
-8
@@ -27,7 +27,7 @@ describe('OAuthPendingRequests', () => {
|
||||
target.pending().subscribe({ next, error });
|
||||
target.request(input);
|
||||
|
||||
await waitFor(() => expect(next).toBeCalledTimes(2));
|
||||
await waitFor(() => expect(next).toHaveBeenCalledTimes(2));
|
||||
expect(next.mock.calls[0][0].scopes).toBeUndefined();
|
||||
expect(next.mock.calls[1][0].scopes.toString()).toBe(input.toString());
|
||||
expect(error.mock.calls.length).toBe(0);
|
||||
@@ -46,8 +46,8 @@ describe('OAuthPendingRequests', () => {
|
||||
|
||||
await expect(request1).resolves.toBe('session1');
|
||||
await expect(request2).resolves.toBe('session1');
|
||||
expect(next).toBeCalledTimes(3); // once on subscription, twice on resolve
|
||||
expect(error).toBeCalledTimes(0);
|
||||
expect(next).toHaveBeenCalledTimes(3); // once on subscription, twice on resolve
|
||||
expect(error).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('can resolve through the observable', async () => {
|
||||
@@ -59,8 +59,8 @@ describe('OAuthPendingRequests', () => {
|
||||
target.pending().subscribe({ next, error });
|
||||
|
||||
await expect(request1).resolves.toBe('done');
|
||||
expect(next).toBeCalledTimes(2); // once with data on subscription, once empty after resolution
|
||||
expect(error).toBeCalledTimes(0);
|
||||
expect(next).toHaveBeenCalledTimes(2); // once with data on subscription, once empty after resolution
|
||||
expect(error).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('rejects requests and notifies observers only once', async () => {
|
||||
@@ -77,8 +77,8 @@ describe('OAuthPendingRequests', () => {
|
||||
|
||||
await expect(request1).rejects.toBe(rejection);
|
||||
await expect(request2).rejects.toBe(rejection);
|
||||
expect(next).toBeCalledTimes(3); // once on subscription, once or reject, once on resolve
|
||||
expect(error).toBeCalledTimes(0);
|
||||
expect(next).toHaveBeenCalledTimes(3); // once on subscription, once or reject, once on resolve
|
||||
expect(error).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('can reject through the observable', async () => {
|
||||
@@ -91,6 +91,6 @@ describe('OAuthPendingRequests', () => {
|
||||
target.pending().subscribe({ next, error });
|
||||
|
||||
await expect(request1).rejects.toBe(rejection);
|
||||
expect(next).toBeCalledTimes(2);
|
||||
expect(next).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('OAuth2', () => {
|
||||
expect(await oauth2.getAccessToken('my-scope my-scope2')).toBe(
|
||||
'access-token',
|
||||
);
|
||||
expect(getSession).toBeCalledTimes(1);
|
||||
expect(getSession).toHaveBeenCalledTimes(1);
|
||||
expect(getSession.mock.calls[0][0].scopes).toEqual(
|
||||
new Set(['my-scope', 'my-scope2']),
|
||||
);
|
||||
@@ -65,7 +65,7 @@ describe('OAuth2', () => {
|
||||
});
|
||||
|
||||
expect(await oauth2.getAccessToken('my-scope')).toBe('access-token');
|
||||
expect(getSession).toBeCalledTimes(1);
|
||||
expect(getSession).toHaveBeenCalledTimes(1);
|
||||
expect(getSession.mock.calls[0][0].scopes).toEqual(
|
||||
new Set(['my-prefix/my-scope']),
|
||||
);
|
||||
@@ -82,7 +82,7 @@ describe('OAuth2', () => {
|
||||
});
|
||||
|
||||
expect(await oauth2.getIdToken()).toBe('id-token');
|
||||
expect(getSession).toBeCalledTimes(1);
|
||||
expect(getSession).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should get optional id token', async () => {
|
||||
@@ -96,7 +96,7 @@ describe('OAuth2', () => {
|
||||
});
|
||||
|
||||
expect(await oauth2.getIdToken({ optional: true })).toBe('id-token');
|
||||
expect(getSession).toBeCalledTimes(1);
|
||||
expect(getSession).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should share popup closed errors', async () => {
|
||||
@@ -125,7 +125,7 @@ describe('OAuth2', () => {
|
||||
const promise2 = oauth2.getAccessToken('more');
|
||||
await expect(promise1).rejects.toBe(error);
|
||||
await expect(promise2).rejects.toBe(error);
|
||||
expect(getSession).toBeCalledTimes(3);
|
||||
expect(getSession).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('should wait for all session refreshes', async () => {
|
||||
@@ -154,7 +154,7 @@ describe('OAuth2', () => {
|
||||
|
||||
// Grab the expired session first
|
||||
await expect(oauth2.getIdToken()).resolves.toBe('token1');
|
||||
expect(getSession).toBeCalledTimes(1);
|
||||
expect(getSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
initialSession.providerInfo.expiresAt = thePast;
|
||||
|
||||
@@ -164,6 +164,6 @@ describe('OAuth2', () => {
|
||||
await expect(promise1).resolves.toBe('token2');
|
||||
await expect(promise2).resolves.toBe('token2');
|
||||
await expect(promise3).resolves.toBe('token2');
|
||||
expect(getSession).toBeCalledTimes(4); // De-duping of session requests happens in client
|
||||
expect(getSession).toHaveBeenCalledTimes(4); // De-duping of session requests happens in client
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ describe('DefaultAuthConnector', () => {
|
||||
|
||||
await mockOauth.triggerAll();
|
||||
|
||||
expect(popupSpy).toBeCalledTimes(1);
|
||||
expect(popupSpy).toHaveBeenCalledTimes(1);
|
||||
expect(popupSpy.mock.calls[0][0]).toMatchObject({
|
||||
url: 'http://my-host/api/auth/my-provider/start?scope=a%20b&origin=http%3A%2F%2Flocalhost&env=production',
|
||||
});
|
||||
@@ -159,7 +159,7 @@ describe('DefaultAuthConnector', () => {
|
||||
|
||||
await expect(sessionPromise).resolves.toBe('my-session');
|
||||
|
||||
expect(popupSpy).toBeCalledTimes(1);
|
||||
expect(popupSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should use join func to join scopes', async () => {
|
||||
@@ -177,7 +177,7 @@ describe('DefaultAuthConnector', () => {
|
||||
|
||||
await mockOauth.triggerAll();
|
||||
|
||||
expect(popupSpy).toBeCalledTimes(1);
|
||||
expect(popupSpy).toHaveBeenCalledTimes(1);
|
||||
expect(popupSpy.mock.calls[0][0]).toMatchObject({
|
||||
url: 'http://my-host/api/auth/my-provider/start?scope=-ab-&origin=http%3A%2F%2Flocalhost&env=production',
|
||||
});
|
||||
|
||||
+14
-14
@@ -38,16 +38,16 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
|
||||
expect(stateSubscriber.mock.calls).toEqual([[SessionState.SignedOut]]);
|
||||
await manager.getSession({});
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(stateSubscriber.mock.calls).toEqual([
|
||||
[SessionState.SignedOut],
|
||||
[SessionState.SignedIn],
|
||||
]);
|
||||
await manager.getSession({});
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(refreshSession).toBeCalledTimes(1);
|
||||
expect(refreshSession).toHaveBeenCalledTimes(1);
|
||||
expect(stateSubscriber.mock.calls).toEqual([
|
||||
[SessionState.SignedOut],
|
||||
[SessionState.SignedIn],
|
||||
@@ -76,13 +76,13 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
expired: false,
|
||||
});
|
||||
await manager.getSession({ scopes: new Set(['a']) });
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
await manager.getSession({ scopes: new Set(['a']) });
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
await manager.getSession({ scopes: new Set(['b']) });
|
||||
expect(createSession).toBeCalledTimes(2);
|
||||
expect(createSession).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should check for session expiry', async () => {
|
||||
@@ -102,12 +102,12 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
});
|
||||
|
||||
await manager.getSession({ scopes: new Set(['a']) });
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(refreshSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
expect(refreshSession).toHaveBeenCalledTimes(1);
|
||||
|
||||
await manager.getSession({ scopes: new Set(['a']) });
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(refreshSession).toBeCalledTimes(2);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
expect(refreshSession).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should handle user closed popup', async () => {
|
||||
@@ -133,8 +133,8 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
} as any);
|
||||
|
||||
expect(await manager.getSession({ optional: true })).toBe(undefined);
|
||||
expect(createSession).toBeCalledTimes(0);
|
||||
expect(refreshSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(0);
|
||||
expect(refreshSession).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should forward option to instantly show auth popup and not attempt refresh', async () => {
|
||||
@@ -146,12 +146,12 @@ describe('RefreshingAuthSessionManager', () => {
|
||||
} as any);
|
||||
|
||||
expect(await manager.getSession({ instantPopup: true })).toBe(undefined);
|
||||
expect(createSession).toBeCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledTimes(1);
|
||||
expect(createSession).toHaveBeenCalledWith({
|
||||
scopes: new Set(),
|
||||
instantPopup: true,
|
||||
});
|
||||
expect(refreshSession).toBeCalledTimes(0);
|
||||
expect(refreshSession).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should remove session straight away', async () => {
|
||||
|
||||
@@ -35,13 +35,13 @@ describe('showLoginPopup', () => {
|
||||
origin: 'my-origin',
|
||||
});
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(openSpy.mock.calls[0][0]).toBe(
|
||||
'my-origin/api/backend/auth/start?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fa%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fb',
|
||||
);
|
||||
expect(openSpy.mock.calls[0][1]).toBe('test-popup');
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(0);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(0);
|
||||
|
||||
const listener = addEventListenerSpy.mock.calls[0][1] as EventListener;
|
||||
|
||||
@@ -88,9 +88,9 @@ describe('showLoginPopup', () => {
|
||||
|
||||
await expect(payloadPromise).resolves.toBe(myResponse);
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should fail if popup returns error', async () => {
|
||||
@@ -107,9 +107,9 @@ describe('showLoginPopup', () => {
|
||||
origin: 'my-origin',
|
||||
});
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(0);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(0);
|
||||
|
||||
const listener = addEventListenerSpy.mock.calls[0][1] as EventListener;
|
||||
|
||||
@@ -130,9 +130,9 @@ describe('showLoginPopup', () => {
|
||||
message: 'NOPE',
|
||||
});
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should fail if popup is closed', async () => {
|
||||
@@ -151,9 +151,9 @@ describe('showLoginPopup', () => {
|
||||
origin: 'origin',
|
||||
});
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(0);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(0);
|
||||
|
||||
const listener = addEventListenerSpy.mock.calls[0][1] as EventListener;
|
||||
listener({
|
||||
@@ -172,9 +172,9 @@ describe('showLoginPopup', () => {
|
||||
'Login failed, popup was closed',
|
||||
);
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should indicate if origin does not match', async () => {
|
||||
@@ -210,8 +210,8 @@ describe('showLoginPopup', () => {
|
||||
'Login failed, Incorrect app origin, expected http://differenthost',
|
||||
);
|
||||
|
||||
expect(openSpy).toBeCalledTimes(1);
|
||||
expect(addEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toBeCalledTimes(1);
|
||||
expect(openSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(removeEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,9 +121,9 @@ describe('ProxiedSignInIdentity', () => {
|
||||
getBaseUrl.mockResolvedValue('http://example.com/api/auth');
|
||||
|
||||
await identity.start(); // should not throw
|
||||
expect(getBaseUrl).toBeCalledTimes(1);
|
||||
expect(getBaseUrl).lastCalledWith('auth');
|
||||
expect(serverCalled).toBeCalledTimes(1);
|
||||
expect(getBaseUrl).toHaveBeenCalledTimes(1);
|
||||
expect(getBaseUrl).toHaveBeenLastCalledWith('auth');
|
||||
expect(serverCalled).toHaveBeenCalledTimes(1);
|
||||
|
||||
// All information should now be available
|
||||
await expect(identity.getBackstageIdentity()).resolves.toEqual({
|
||||
@@ -148,7 +148,7 @@ describe('ProxiedSignInIdentity', () => {
|
||||
});
|
||||
|
||||
await identity.getSessionAsync(); // no need to fetch again just yet
|
||||
expect(serverCalled).toBeCalledTimes(1);
|
||||
expect(serverCalled).toHaveBeenCalledTimes(1);
|
||||
|
||||
// Use a fairly large margin (1000) since the iat and exp are clamped to
|
||||
// full seconds, but the "local current time" isn't
|
||||
@@ -156,11 +156,11 @@ describe('ProxiedSignInIdentity', () => {
|
||||
3600 * 1000 - DEFAULTS.tokenExpiryMarginMillis - 1000,
|
||||
);
|
||||
await identity.getSessionAsync(); // still no need to fetch again
|
||||
expect(serverCalled).toBeCalledTimes(1);
|
||||
expect(serverCalled).toHaveBeenCalledTimes(1);
|
||||
|
||||
jest.advanceTimersByTime(1001);
|
||||
await identity.getSessionAsync(); // now the expiry has passed
|
||||
expect(serverCalled).toBeCalledTimes(2);
|
||||
expect(serverCalled).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -130,10 +130,10 @@ describe('buildAppTask', () => {
|
||||
|
||||
const appDir = 'projects/dir';
|
||||
await expect(buildAppTask(appDir)).resolves.not.toThrow();
|
||||
expect(mockChdir).toBeCalledTimes(2);
|
||||
expect(mockChdir).toHaveBeenCalledTimes(2);
|
||||
expect(mockChdir).toHaveBeenNthCalledWith(1, appDir);
|
||||
expect(mockChdir).toHaveBeenNthCalledWith(2, appDir);
|
||||
expect(mockExec).toBeCalledTimes(2);
|
||||
expect(mockExec).toHaveBeenCalledTimes(2);
|
||||
expect(mockExec).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'yarn install',
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('getValidPublisherConfig', () => {
|
||||
publisherType: 'unknown publisher',
|
||||
} as unknown as OptionValues;
|
||||
|
||||
expect(() => PublisherConfig.getValidConfig(invalidConfig)).toThrowError(
|
||||
expect(() => PublisherConfig.getValidConfig(invalidConfig)).toThrow(
|
||||
`Unknown publisher type ${invalidConfig.publisherType}`,
|
||||
);
|
||||
});
|
||||
@@ -34,7 +34,7 @@ describe('getValidPublisherConfig', () => {
|
||||
publisherType: 'azureBlobStorage',
|
||||
} as unknown as OptionValues;
|
||||
|
||||
expect(() => PublisherConfig.getValidConfig(config)).toThrowError(
|
||||
expect(() => PublisherConfig.getValidConfig(config)).toThrow(
|
||||
'azureBlobStorage requires --azureAccountName to be specified',
|
||||
);
|
||||
});
|
||||
@@ -104,7 +104,7 @@ describe('getValidPublisherConfig', () => {
|
||||
osSecret: 'someSecret',
|
||||
} as unknown as OptionValues;
|
||||
|
||||
expect(() => PublisherConfig.getValidConfig(config)).toThrowError(
|
||||
expect(() => PublisherConfig.getValidConfig(config)).toThrow(
|
||||
`openStackSwift requires the following params to be specified: ${[
|
||||
'osAuthUrl',
|
||||
'osSwiftUrl',
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('MockFetchApi', () => {
|
||||
const inner = jest.fn();
|
||||
const m = new MockFetchApi({ baseImplementation: inner });
|
||||
await m.fetch('http://example.com/data.json');
|
||||
expect(inner).lastCalledWith('http://example.com/data.json');
|
||||
expect(inner).toHaveBeenLastCalledWith('http://example.com/data.json');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ describe('GoogleAnalytics', () => {
|
||||
describe('fromConfig', () => {
|
||||
it('throws when missing trackingId', () => {
|
||||
const config = new ConfigReader({ app: { analytics: { ga: {} } } });
|
||||
expect(() => GoogleAnalytics.fromConfig(config)).toThrowError(
|
||||
expect(() => GoogleAnalytics.fromConfig(config)).toThrow(
|
||||
/Missing required config value/,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -109,8 +109,13 @@ describe('FirestoreKeyStore', () => {
|
||||
const keyStore = await FirestoreKeyStore.create();
|
||||
await keyStore.addKey(key);
|
||||
|
||||
expect(setTimeout).toBeCalledWith(expect.any(Function), DEFAULT_TIMEOUT_MS);
|
||||
expect(firestoreMock.collection).toBeCalledWith(DEFAULT_DOCUMENT_PATH);
|
||||
expect(setTimeout).toHaveBeenCalledWith(
|
||||
expect.any(Function),
|
||||
DEFAULT_TIMEOUT_MS,
|
||||
);
|
||||
expect(firestoreMock.collection).toHaveBeenCalledWith(
|
||||
DEFAULT_DOCUMENT_PATH,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle a timeout', async () => {
|
||||
@@ -135,9 +140,9 @@ describe('FirestoreKeyStore', () => {
|
||||
const keyStore = await FirestoreKeyStore.create(firestoreSettings);
|
||||
await keyStore.addKey(key);
|
||||
|
||||
expect(setTimeout).toBeCalledTimes(1);
|
||||
expect(firestoreMock.collection).toBeCalledWith(path);
|
||||
expect(firestoreMock.doc).toBeCalledWith(key.kid);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(firestoreMock.collection).toHaveBeenCalledWith(path);
|
||||
expect(firestoreMock.doc).toHaveBeenCalledWith(key.kid);
|
||||
expect(firestoreMock.set).toHaveBeenCalledWith({
|
||||
kid: key.kid,
|
||||
key: JSON.stringify(key),
|
||||
@@ -148,32 +153,32 @@ describe('FirestoreKeyStore', () => {
|
||||
const keyStore = await FirestoreKeyStore.create(firestoreSettings);
|
||||
await keyStore.removeKeys(['123']);
|
||||
|
||||
expect(setTimeout).toBeCalledTimes(1);
|
||||
expect(firestoreMock.collection).toBeCalledWith(path);
|
||||
expect(firestoreMock.doc).toBeCalledWith('123');
|
||||
expect(firestoreMock.delete).toBeCalledTimes(1);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(firestoreMock.collection).toHaveBeenCalledWith(path);
|
||||
expect(firestoreMock.doc).toHaveBeenCalledWith('123');
|
||||
expect(firestoreMock.delete).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('can delete a multiple keys', async () => {
|
||||
const keyStore = await FirestoreKeyStore.create(firestoreSettings);
|
||||
await keyStore.removeKeys(['123', '456']);
|
||||
|
||||
expect(setTimeout).toBeCalledTimes(2);
|
||||
expect(firestoreMock.collection).toBeCalledWith(path);
|
||||
expect(firestoreMock.doc).toBeCalledWith('123');
|
||||
expect(firestoreMock.doc).toBeCalledWith('456');
|
||||
expect(firestoreMock.delete).toBeCalledTimes(2);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(2);
|
||||
expect(firestoreMock.collection).toHaveBeenCalledWith(path);
|
||||
expect(firestoreMock.doc).toHaveBeenCalledWith('123');
|
||||
expect(firestoreMock.doc).toHaveBeenCalledWith('456');
|
||||
expect(firestoreMock.delete).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('can list keys', async () => {
|
||||
const keyStore = await FirestoreKeyStore.create(firestoreSettings);
|
||||
const items = await keyStore.listKeys();
|
||||
|
||||
expect(setTimeout).toBeCalledTimes(1);
|
||||
expect(firestoreMock.collection).toBeCalledWith(path);
|
||||
expect(firestoreMock.get).toBeCalledTimes(1);
|
||||
expect(data).toBeCalledTimes(1);
|
||||
expect(toDate).toBeCalledTimes(1);
|
||||
expect(setTimeout).toHaveBeenCalledTimes(1);
|
||||
expect(firestoreMock.collection).toHaveBeenCalledWith(path);
|
||||
expect(firestoreMock.get).toHaveBeenCalledTimes(1);
|
||||
expect(data).toHaveBeenCalledTimes(1);
|
||||
expect(toDate).toHaveBeenCalledTimes(1);
|
||||
expect(items).toMatchObject({
|
||||
items: [{ key: 'data', createdAt: 'date' }],
|
||||
});
|
||||
|
||||
@@ -128,7 +128,7 @@ describe('TokenFactory', () => {
|
||||
return factory.issueToken({
|
||||
claims: { sub: 'UserId' },
|
||||
});
|
||||
}).rejects.toThrowError();
|
||||
}).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('should throw error on empty algorithm string', async () => {
|
||||
@@ -145,7 +145,7 @@ describe('TokenFactory', () => {
|
||||
return factory.issueToken({
|
||||
claims: { sub: 'UserId' },
|
||||
});
|
||||
}).rejects.toThrowError();
|
||||
}).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('should defaults to ES256 when no algorithm string is supplied', async () => {
|
||||
|
||||
@@ -62,9 +62,11 @@ describe('oauth helpers', () => {
|
||||
const encoded = safelyEncodeURIComponent(JSON.stringify(data));
|
||||
|
||||
postMessageResponse(mockResponse, appOrigin, data);
|
||||
expect(mockResponse.setHeader).toBeCalledTimes(3);
|
||||
expect(mockResponse.end).toBeCalledTimes(1);
|
||||
expect(mockResponse.end).toBeCalledWith(expect.stringContaining(encoded));
|
||||
expect(mockResponse.setHeader).toHaveBeenCalledTimes(3);
|
||||
expect(mockResponse.end).toHaveBeenCalledTimes(1);
|
||||
expect(mockResponse.end).toHaveBeenCalledWith(
|
||||
expect.stringContaining(encoded),
|
||||
);
|
||||
});
|
||||
|
||||
it('should post a message back with payload error', () => {
|
||||
@@ -80,9 +82,11 @@ describe('oauth helpers', () => {
|
||||
const encoded = safelyEncodeURIComponent(JSON.stringify(data));
|
||||
|
||||
postMessageResponse(mockResponse, appOrigin, data);
|
||||
expect(mockResponse.setHeader).toBeCalledTimes(3);
|
||||
expect(mockResponse.end).toBeCalledTimes(1);
|
||||
expect(mockResponse.end).toBeCalledWith(expect.stringContaining(encoded));
|
||||
expect(mockResponse.setHeader).toHaveBeenCalledTimes(3);
|
||||
expect(mockResponse.end).toHaveBeenCalledTimes(1);
|
||||
expect(mockResponse.end).toHaveBeenCalledWith(
|
||||
expect.stringContaining(encoded),
|
||||
);
|
||||
});
|
||||
|
||||
it('should call postMessage twice but only one of them with target *', () => {
|
||||
@@ -166,9 +170,9 @@ describe('oauth helpers', () => {
|
||||
};
|
||||
|
||||
postMessageResponse(mockResponse, appOrigin, data);
|
||||
expect(mockResponse.setHeader).toBeCalledTimes(3);
|
||||
expect(mockResponse.end).toBeCalledTimes(1);
|
||||
expect(mockResponse.end).toBeCalledWith(
|
||||
expect(mockResponse.setHeader).toHaveBeenCalledTimes(3);
|
||||
expect(mockResponse.end).toHaveBeenCalledTimes(1);
|
||||
expect(mockResponse.end).toHaveBeenCalledWith(
|
||||
expect.stringContaining('Adam%20l%27H%C3%B4pital'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -92,8 +92,8 @@ describe('OAuthAdapter', () => {
|
||||
|
||||
await oauthProvider.start(mockRequest, mockResponse);
|
||||
// nonce cookie checks
|
||||
expect(mockResponse.cookie).toBeCalledTimes(1);
|
||||
expect(mockResponse.cookie).toBeCalledWith(
|
||||
expect(mockResponse.cookie).toHaveBeenCalledTimes(1);
|
||||
expect(mockResponse.cookie).toHaveBeenCalledWith(
|
||||
`${oAuthProviderOptions.providerId}-nonce`,
|
||||
expect.any(String),
|
||||
expect.objectContaining({ maxAge: TEN_MINUTES_MS }),
|
||||
@@ -323,8 +323,8 @@ describe('OAuthAdapter', () => {
|
||||
|
||||
await oauthProvider.start(mockRequest, mockResponse);
|
||||
|
||||
expect(mockResponse.cookie).toBeCalledTimes(1);
|
||||
expect(mockResponse.cookie).toBeCalledWith(
|
||||
expect(mockResponse.cookie).toHaveBeenCalledTimes(1);
|
||||
expect(mockResponse.cookie).toHaveBeenCalledWith(
|
||||
`${oAuthProviderOptions.providerId}-nonce`,
|
||||
expect.any(String),
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('OAuthProvider Utils', () => {
|
||||
} as unknown as express.Request;
|
||||
expect(() => {
|
||||
verifyNonce(mockRequest, 'providera');
|
||||
}).toThrowError('Auth response is missing cookie nonce');
|
||||
}).toThrow('Auth response is missing cookie nonce');
|
||||
});
|
||||
|
||||
it('should throw error if state nonce missing', () => {
|
||||
@@ -76,7 +76,7 @@ describe('OAuthProvider Utils', () => {
|
||||
} as unknown as express.Request;
|
||||
expect(() => {
|
||||
verifyNonce(mockRequest, 'providera');
|
||||
}).toThrowError('Invalid state passed via request');
|
||||
}).toThrow('Invalid state passed via request');
|
||||
});
|
||||
|
||||
it('should throw error if nonce mismatch', () => {
|
||||
@@ -91,7 +91,7 @@ describe('OAuthProvider Utils', () => {
|
||||
} as unknown as express.Request;
|
||||
expect(() => {
|
||||
verifyNonce(mockRequest, 'providera');
|
||||
}).toThrowError('Invalid nonce');
|
||||
}).toThrow('Invalid nonce');
|
||||
});
|
||||
|
||||
it('should not throw any error if nonce matches', () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('PassportStrategyHelper', () => {
|
||||
mockStrategy,
|
||||
{},
|
||||
);
|
||||
expect(spyAuthenticate).toBeCalledTimes(1);
|
||||
expect(spyAuthenticate).toHaveBeenCalledTimes(1);
|
||||
await expect(redirectStrategyPromise).resolves.toStrictEqual(
|
||||
expect.objectContaining({ url: 'a', status: 302 }),
|
||||
);
|
||||
@@ -84,7 +84,7 @@ describe('PassportStrategyHelper', () => {
|
||||
mockRequest,
|
||||
mockStrategy,
|
||||
);
|
||||
expect(spyAuthenticate).toBeCalledTimes(1);
|
||||
expect(spyAuthenticate).toHaveBeenCalledTimes(1);
|
||||
await expect(frameHandlerStrategyPromise).resolves.toStrictEqual(
|
||||
expect.objectContaining({
|
||||
result: { accessToken: 'ACCESS_TOKEN' },
|
||||
@@ -100,7 +100,7 @@ describe('PassportStrategyHelper', () => {
|
||||
mockRequest,
|
||||
mockStrategy,
|
||||
);
|
||||
expect(spyAuthenticate).toBeCalledTimes(1);
|
||||
expect(spyAuthenticate).toHaveBeenCalledTimes(1);
|
||||
await expect(frameHandlerStrategyPromise).rejects.toThrow(
|
||||
'Authentication failed, MyCustomAuth error - Custom message',
|
||||
);
|
||||
@@ -113,7 +113,7 @@ describe('PassportStrategyHelper', () => {
|
||||
mockRequest,
|
||||
mockStrategy,
|
||||
);
|
||||
expect(spyAuthenticate).toBeCalledTimes(1);
|
||||
expect(spyAuthenticate).toHaveBeenCalledTimes(1);
|
||||
await expect(frameHandlerStrategyPromise).rejects.toThrow(
|
||||
'Unexpected redirect',
|
||||
);
|
||||
@@ -126,7 +126,7 @@ describe('PassportStrategyHelper', () => {
|
||||
mockRequest,
|
||||
mockStrategy,
|
||||
);
|
||||
expect(spyAuthenticate).toBeCalledTimes(1);
|
||||
expect(spyAuthenticate).toHaveBeenCalledTimes(1);
|
||||
await expect(frameHandlerStrategyPromise).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -233,7 +233,7 @@ describe('CloudflareAccessAuthProvider', () => {
|
||||
mockFetch.mockReturnValue(Promise.reject());
|
||||
await expect(
|
||||
provider.refresh(mockRequestWithJwtCookie, mockResponse),
|
||||
).rejects.toThrowError();
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('helpers', () => {
|
||||
'a',
|
||||
mockClient as unknown as OAuth2Client,
|
||||
);
|
||||
await expect(validator(validJwt)).rejects.toThrowError(TypeError);
|
||||
await expect(validator(validJwt)).rejects.toThrow(TypeError);
|
||||
});
|
||||
|
||||
it('rejects empty payload', async () => {
|
||||
|
||||
@@ -122,7 +122,7 @@ describe('Oauth2ProxyAuthProvider', () => {
|
||||
|
||||
await provider.refresh(mockRequest, mockResponse);
|
||||
|
||||
expect(mockRequest.header).toBeCalledWith(OAUTH2_PROXY_JWT_HEADER);
|
||||
expect(mockRequest.header).toHaveBeenCalledWith(OAUTH2_PROXY_JWT_HEADER);
|
||||
expect(mockJwtDecode).toHaveBeenCalledWith('token');
|
||||
expect(mockResponse.json).toHaveBeenCalled();
|
||||
});
|
||||
@@ -197,7 +197,7 @@ describe('Oauth2ProxyAuthProvider', () => {
|
||||
} as any);
|
||||
await handler.refresh!(mockRequest, mockResponse);
|
||||
|
||||
expect(mockRequest.header).toBeCalledWith(OAUTH2_PROXY_JWT_HEADER);
|
||||
expect(mockRequest.header).toHaveBeenCalledWith(OAUTH2_PROXY_JWT_HEADER);
|
||||
expect(mockJwtDecode).toHaveBeenCalledWith('token');
|
||||
expect(mockResponse.json).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -83,7 +83,7 @@ describe('OidcAuthProvider', () => {
|
||||
};
|
||||
};
|
||||
// Assert that the expected request to the metadaurl was made.
|
||||
expect(handler).toBeCalledTimes(1);
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
const { _client, _issuer } = strategy;
|
||||
expect(_client.client_id).toBe(clientMetadata.clientId);
|
||||
expect(_issuer.token_endpoint).toBe(issuerMetadata.token_endpoint);
|
||||
@@ -183,6 +183,6 @@ describe('OidcAuthProvider', () => {
|
||||
// Cast provider as any here to be able to inspect private members
|
||||
await (provider as any).handlers.get('testEnv').handlers.implementation;
|
||||
// Assert that the expected request to the metadaurl was made.
|
||||
expect(handler).toBeCalledTimes(1);
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -45,7 +45,7 @@ describe('AwsEKSClusterProcessor', () => {
|
||||
AWSMock.mock('EKS', 'describeCluster', cluster);
|
||||
|
||||
await processor.readLocation(location, false, emit);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'entity',
|
||||
location,
|
||||
entity: {
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
};
|
||||
});
|
||||
await processor.readLocation(location, false, emit);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'entity',
|
||||
location,
|
||||
entity: {
|
||||
@@ -94,8 +94,8 @@ describe('AwsOrganizationCloudAccountProcessor', () => {
|
||||
};
|
||||
});
|
||||
await processor.readLocation(locationTest, false, emit);
|
||||
expect(emit).toBeCalledTimes(1);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(1);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'entity',
|
||||
location: locationTest,
|
||||
entity: {
|
||||
|
||||
@@ -137,7 +137,7 @@ describe('AwsS3EntityProvider', () => {
|
||||
};
|
||||
});
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ describe('AzureDevOpsEntityProvider', () => {
|
||||
};
|
||||
});
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
|
||||
+2
-2
@@ -272,8 +272,8 @@ describe('BitbucketCloudEntityProvider', () => {
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
|
||||
+4
-4
@@ -266,8 +266,8 @@ describe('BitbucketServerEntityProvider', () => {
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
@@ -359,8 +359,8 @@ describe('BitbucketServerEntityProvider', () => {
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
|
||||
@@ -573,7 +573,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -615,7 +615,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -657,7 +657,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -698,7 +698,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -734,7 +734,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -762,7 +762,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -772,7 +772,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
presence: 'optional',
|
||||
},
|
||||
});
|
||||
expect(mockCall).toBeCalledTimes(1);
|
||||
expect(mockCall).toHaveBeenCalledTimes(1);
|
||||
// it should be possible to do this via an `expect.objectContaining` check but seems to fail with some encoding issue.
|
||||
expect(mockCall.mock.calls[0][0].url).toMatchInlineSnapshot(
|
||||
`"https://api.bitbucket.org/2.0/repositories/myworkspace?page=1&pagelen=100&q=project.key+%7E+%22prj-one%22"`,
|
||||
@@ -875,7 +875,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -921,7 +921,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -967,7 +967,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledTimes(2);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -1012,7 +1012,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
@@ -1052,7 +1052,7 @@ describe('BitbucketDiscoveryProcessor', () => {
|
||||
const emitter = jest.fn();
|
||||
await processor.readLocation(location, false, emitter);
|
||||
|
||||
expect(emitter).toBeCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledTimes(1);
|
||||
expect(emitter).toHaveBeenCalledWith({
|
||||
type: 'location',
|
||||
location: {
|
||||
|
||||
@@ -115,7 +115,9 @@ describe('GerritEntityProvider', () => {
|
||||
expect(taskDef.id).toEqual('gerrit-provider:active-training:refresh');
|
||||
await (taskDef.fn as () => Promise<void>)();
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith(expected);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith(
|
||||
expected,
|
||||
);
|
||||
});
|
||||
|
||||
it('handles api errors.', async () => {
|
||||
|
||||
@@ -93,9 +93,7 @@ describe('GitHubEntityProvider', () => {
|
||||
logger,
|
||||
schedule,
|
||||
}),
|
||||
).toThrowError(
|
||||
/There is no GitHub config that matches host ghe.internal.com/,
|
||||
);
|
||||
).toThrow(/There is no GitHub config that matches host ghe.internal.com/);
|
||||
});
|
||||
|
||||
it('multiple provider configs', () => {
|
||||
@@ -204,8 +202,8 @@ describe('GitHubEntityProvider', () => {
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ describe('GitHubOrgEntityProvider', () => {
|
||||
|
||||
await entityProvider.read();
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
entities: [
|
||||
{
|
||||
entity: {
|
||||
|
||||
@@ -214,7 +214,7 @@ describe('GitLabClient', () => {
|
||||
logger: getVoidLogger(),
|
||||
});
|
||||
// non-200 status code should throw
|
||||
await expect(() => client.pagedRequest(endpoint)).rejects.toThrowError();
|
||||
await expect(() => client.pagedRequest(endpoint)).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+3
-3
@@ -221,8 +221,8 @@ describe('GitlabDiscoveryEntityProvider', () => {
|
||||
},
|
||||
];
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledTimes(1);
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: expectedEntities,
|
||||
});
|
||||
@@ -308,7 +308,7 @@ describe('GitlabDiscoveryEntityProvider', () => {
|
||||
|
||||
await provider.refresh(logger);
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
type: 'full',
|
||||
entities: [
|
||||
{
|
||||
|
||||
@@ -51,8 +51,8 @@ describe('MicrosoftGraphClient', () => {
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(await response.json()).toEqual({ value: 'example' });
|
||||
expect(tokenCredential.getToken).toBeCalledTimes(1);
|
||||
expect(tokenCredential.getToken).toBeCalledWith(
|
||||
expect(tokenCredential.getToken).toHaveBeenCalledTimes(1);
|
||||
expect(tokenCredential.getToken).toHaveBeenCalledWith(
|
||||
'https://graph.microsoft.com/.default',
|
||||
);
|
||||
});
|
||||
@@ -158,7 +158,7 @@ describe('MicrosoftGraphClient', () => {
|
||||
),
|
||||
);
|
||||
|
||||
await expect(() => client.getUserProfile('user-id')).rejects.toThrowError();
|
||||
await expect(() => client.getUserProfile('user-id')).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('should load user profile photo with max size of 120', async () => {
|
||||
|
||||
@@ -111,15 +111,18 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(1);
|
||||
expect(client.getUsers).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUsers).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'accountEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
|
||||
it('should read users with advanced query mode', async () => {
|
||||
@@ -162,15 +165,18 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(1);
|
||||
expect(client.getUsers).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUsers).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'accountEnabled eq true',
|
||||
},
|
||||
'advanced',
|
||||
);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
|
||||
it('should read users with userExpand and custom transformer', async () => {
|
||||
@@ -208,16 +214,19 @@ describe('read microsoft graph', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(1);
|
||||
expect(client.getUsers).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUsers).toHaveBeenCalledWith(
|
||||
{
|
||||
expand: 'manager',
|
||||
filter: 'accountEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -280,22 +289,25 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
|
||||
expect(client.getUserProfile).toBeCalledTimes(1);
|
||||
expect(client.getUserProfile).toBeCalledWith('userid', {
|
||||
expect(client.getUserProfile).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserProfile).toHaveBeenCalledWith('userid', {
|
||||
expand: undefined,
|
||||
});
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
|
||||
it('should read users from Groups with advanced query mode', async () => {
|
||||
@@ -357,22 +369,25 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
]);
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq true',
|
||||
},
|
||||
'advanced',
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
|
||||
expect(client.getUserProfile).toBeCalledTimes(1);
|
||||
expect(client.getUserProfile).toBeCalledWith('userid', {
|
||||
expect(client.getUserProfile).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserProfile).toHaveBeenCalledWith('userid', {
|
||||
expand: undefined,
|
||||
});
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
|
||||
it('should read users with userExpand, groupExpand and custom transformer', async () => {
|
||||
@@ -430,23 +445,26 @@ describe('read microsoft graph', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
expand: 'member',
|
||||
filter: 'securityEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
|
||||
expect(client.getUserProfile).toBeCalledTimes(1);
|
||||
expect(client.getUserProfile).toBeCalledWith('userid', {
|
||||
expect(client.getUserProfile).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserProfile).toHaveBeenCalledWith('userid', {
|
||||
expand: 'manager',
|
||||
});
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledWith('userid', 120);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledWith(
|
||||
'userid',
|
||||
120,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -481,8 +499,8 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
);
|
||||
|
||||
expect(client.getOrganization).toBeCalledTimes(1);
|
||||
expect(client.getOrganization).toBeCalledWith('tenantid');
|
||||
expect(client.getOrganization).toHaveBeenCalledTimes(1);
|
||||
expect(client.getOrganization).toHaveBeenCalledWith('tenantid');
|
||||
});
|
||||
|
||||
it('should read organization with custom transformer', async () => {
|
||||
@@ -499,8 +517,8 @@ describe('read microsoft graph', () => {
|
||||
|
||||
expect(rootGroup).toEqual(undefined);
|
||||
|
||||
expect(client.getOrganization).toBeCalledTimes(1);
|
||||
expect(client.getOrganization).toBeCalledWith('tenantid');
|
||||
expect(client.getOrganization).toHaveBeenCalledTimes(1);
|
||||
expect(client.getOrganization).toHaveBeenCalledWith('tenantid');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -585,15 +603,15 @@ describe('read microsoft graph', () => {
|
||||
expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid']));
|
||||
expect(groupMember.get('organization_name')).toEqual(new Set());
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
// TODO: Loading groups photos doesn't work right now as Microsoft Graph
|
||||
// doesn't allows this yet
|
||||
// expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
@@ -681,15 +699,15 @@ describe('read microsoft graph', () => {
|
||||
expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid']));
|
||||
expect(groupMember.get('organization_name')).toEqual(new Set());
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
'advanced',
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
// TODO: Loading groups photos doesn't work right now as Microsoft Graph
|
||||
// doesn't allows this yet
|
||||
// expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
@@ -777,16 +795,16 @@ describe('read microsoft graph', () => {
|
||||
expect(groupMemberOf.get('userid')).toEqual(new Set(['groupid']));
|
||||
expect(groupMember.get('organization_name')).toEqual(new Set());
|
||||
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
expand: 'member',
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
// TODO: Loading groups photos doesn't work right now as Microsoft Graph
|
||||
// doesn't allows this yet
|
||||
// expect(client.getGroupPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
@@ -872,14 +890,14 @@ describe('read microsoft graph', () => {
|
||||
}),
|
||||
]);
|
||||
expect(rootGroup).toEqual(expectedRootGroup);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroupMembers).toBeCalledTimes(1);
|
||||
expect(client.getGroupMembers).toBeCalledWith('groupid');
|
||||
expect(client.getGroupMembers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroupMembers).toHaveBeenCalledWith('groupid');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1034,15 +1052,15 @@ describe('read microsoft graph', () => {
|
||||
groupFilter: 'securityEnabled eq false',
|
||||
});
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(1);
|
||||
expect(client.getUsers).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUsers).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: undefined,
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
@@ -1074,16 +1092,16 @@ describe('read microsoft graph', () => {
|
||||
groupFilter: 'securityEnabled eq false',
|
||||
});
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(1);
|
||||
expect(client.getUsers).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUsers).toHaveBeenCalledWith(
|
||||
{
|
||||
expand: 'manager',
|
||||
filter: 'accountEnabled eq true',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroups).toBeCalledTimes(1);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(1);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
@@ -1115,22 +1133,22 @@ describe('read microsoft graph', () => {
|
||||
groupFilter: 'securityEnabled eq false',
|
||||
});
|
||||
|
||||
expect(client.getUsers).toBeCalledTimes(0);
|
||||
expect(client.getGroups).toBeCalledTimes(2);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getUsers).toHaveBeenCalledTimes(0);
|
||||
expect(client.getGroups).toHaveBeenCalledTimes(2);
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'name eq backstage-group',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getGroups).toBeCalledWith(
|
||||
expect(client.getGroups).toHaveBeenCalledWith(
|
||||
{
|
||||
filter: 'securityEnabled eq false',
|
||||
},
|
||||
undefined,
|
||||
);
|
||||
expect(client.getUserProfile).toBeCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toBeCalledTimes(1);
|
||||
expect(client.getUserProfile).toHaveBeenCalledTimes(1);
|
||||
expect(client.getUserPhotoWithSizeLimit).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ describe('MicrosoftGraphOrgEntityProvider', () => {
|
||||
|
||||
await provider.read();
|
||||
|
||||
expect(entityProviderConnection.applyMutation).toBeCalledWith({
|
||||
expect(entityProviderConnection.applyMutation).toHaveBeenCalledWith({
|
||||
entities: [
|
||||
{
|
||||
entity: {
|
||||
|
||||
+4
-4
@@ -92,8 +92,8 @@ describe('MicrosoftGraphOrgReaderProcessor', () => {
|
||||
const processed = await processor.readLocation(location, false, emit);
|
||||
|
||||
expect(processed).toBe(true);
|
||||
expect(emit).toBeCalledTimes(2);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(2);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Group',
|
||||
@@ -111,7 +111,7 @@ describe('MicrosoftGraphOrgReaderProcessor', () => {
|
||||
},
|
||||
type: 'entity',
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'User',
|
||||
@@ -139,6 +139,6 @@ describe('MicrosoftGraphOrgReaderProcessor', () => {
|
||||
const processed = await processor.readLocation(location, false, emit);
|
||||
|
||||
expect(processed).toBe(false);
|
||||
expect(emit).toBeCalledTimes(0);
|
||||
expect(emit).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1225,7 +1225,7 @@ describe('Default Processing Database', () => {
|
||||
],
|
||||
});
|
||||
});
|
||||
expect(fakeLogger.debug).toBeCalledWith(
|
||||
expect(fakeLogger.debug).toHaveBeenCalledWith(
|
||||
expect.stringMatching(
|
||||
/Fast insert path failed, falling back to slow path/,
|
||||
),
|
||||
|
||||
@@ -52,8 +52,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(14);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(14);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
@@ -61,7 +61,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -69,7 +69,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'API', namespace: 'default', name: 'b' },
|
||||
@@ -77,7 +77,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -85,7 +85,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'API', namespace: 'default', name: 'b' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'API', namespace: 'default', name: 'c' },
|
||||
@@ -93,7 +93,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -101,7 +101,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'API', namespace: 'default', name: 'c' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -109,7 +109,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Resource', namespace: 'default', name: 'r' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'r' },
|
||||
@@ -117,7 +117,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -125,7 +125,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'd' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'd' },
|
||||
@@ -133,7 +133,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 's' },
|
||||
@@ -141,7 +141,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -149,7 +149,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 's' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'System', namespace: 'default', name: 's' },
|
||||
@@ -157,7 +157,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'n' },
|
||||
@@ -185,7 +185,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
};
|
||||
await expect(
|
||||
processor.postProcessEntity(entity, location, emit),
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
'Entity reference "r" had missing or empty kind (e.g. did not start with "component:" or similar)',
|
||||
);
|
||||
});
|
||||
@@ -206,8 +206,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(4);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(4);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
@@ -215,7 +215,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'API', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'API', namespace: 'default', name: 'n' },
|
||||
@@ -223,7 +223,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'System', namespace: 'default', name: 's' },
|
||||
@@ -231,7 +231,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'API', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'API', namespace: 'default', name: 'n' },
|
||||
@@ -257,8 +257,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(10);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(10);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
@@ -266,7 +266,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
@@ -275,7 +275,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
@@ -283,7 +283,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'c' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'c' },
|
||||
@@ -292,7 +292,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
@@ -300,7 +300,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Resource', namespace: 'default', name: 'r' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'r' },
|
||||
@@ -309,7 +309,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'System', namespace: 'default', name: 's' },
|
||||
@@ -317,7 +317,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
@@ -326,7 +326,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Resource', namespace: 'default', name: 'n' },
|
||||
@@ -334,7 +334,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Component', namespace: 'default', name: 'd' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Component', namespace: 'default', name: 'd' },
|
||||
@@ -358,7 +358,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
};
|
||||
await expect(
|
||||
processor.postProcessEntity(entity, location, emit),
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
'Entity reference "c" had missing or empty kind (e.g. did not start with "component:" or similar)',
|
||||
);
|
||||
});
|
||||
@@ -376,8 +376,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(4);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(4);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
@@ -385,7 +385,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'System', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'System', namespace: 'default', name: 'n' },
|
||||
@@ -393,7 +393,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Domain', namespace: 'default', name: 'd' },
|
||||
@@ -401,7 +401,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'System', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'System', namespace: 'default', name: 'n' },
|
||||
@@ -423,8 +423,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(2);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(2);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'o' },
|
||||
@@ -432,7 +432,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Domain', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Domain', namespace: 'default', name: 'n' },
|
||||
@@ -454,8 +454,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(2);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(2);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'User', namespace: 'default', name: 'n' },
|
||||
@@ -463,7 +463,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'g' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'g' },
|
||||
@@ -488,8 +488,8 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
|
||||
await processor.postProcessEntity(entity, location, emit);
|
||||
|
||||
expect(emit).toBeCalledTimes(6);
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledTimes(6);
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
@@ -497,7 +497,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'p' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'p' },
|
||||
@@ -505,7 +505,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'c' },
|
||||
@@ -513,7 +513,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
@@ -521,7 +521,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'c' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'User', namespace: 'default', name: 'm' },
|
||||
@@ -529,7 +529,7 @@ describe('BuiltinKindsEntityProcessor', () => {
|
||||
target: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
},
|
||||
});
|
||||
expect(emit).toBeCalledWith({
|
||||
expect(emit).toHaveBeenCalledWith({
|
||||
type: 'relation',
|
||||
relation: {
|
||||
source: { kind: 'Group', namespace: 'default', name: 'n' },
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('FileReaderProcessor', () => {
|
||||
defaultEntityDataParser,
|
||||
);
|
||||
|
||||
expect(emit).toBeCalledTimes(4);
|
||||
expect(emit).toHaveBeenCalledTimes(4);
|
||||
expect(emit.mock.calls[0][0].entity).toEqual({
|
||||
kind: 'Component',
|
||||
metadata: { name: 'component-test' },
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('LocationEntityProcessor', () => {
|
||||
'http://b.com/z',
|
||||
);
|
||||
|
||||
expect(integrations.resolveUrl).toBeCalledTimes(3);
|
||||
expect(integrations.resolveUrl).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('handles azure urls specifically', () => {
|
||||
|
||||
@@ -86,8 +86,8 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { a: [{ b: 'TEXT' }] },
|
||||
});
|
||||
|
||||
expect(read).not.toBeCalled();
|
||||
expect(upperResolver).toBeCalledWith(
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
expect(upperResolver).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
key: 'upper',
|
||||
value: 'text',
|
||||
@@ -115,7 +115,7 @@ describe('PlaceholderProcessor', () => {
|
||||
processor.preProcessEntity(entity, { type: 'a', target: 'b' }, () => {}),
|
||||
).resolves.toEqual(entity);
|
||||
|
||||
expect(read).not.toBeCalled();
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ignores unknown placeholders', async () => {
|
||||
@@ -136,7 +136,7 @@ describe('PlaceholderProcessor', () => {
|
||||
processor.preProcessEntity(entity, { type: 'a', target: 'b' }, () => {}),
|
||||
).resolves.toEqual(entity);
|
||||
|
||||
expect(read).not.toBeCalled();
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('works with the text resolver', async () => {
|
||||
@@ -169,7 +169,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: 'TEXT' },
|
||||
});
|
||||
|
||||
expect(read).toBeCalledWith(
|
||||
expect(read).toHaveBeenCalledWith(
|
||||
'https://github.com/backstage/backstage/a/file.txt',
|
||||
);
|
||||
});
|
||||
@@ -206,7 +206,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: { a: ['b', 7] } },
|
||||
});
|
||||
|
||||
expect(read).toBeCalledWith(
|
||||
expect(read).toHaveBeenCalledWith(
|
||||
'https://github.com/backstage/backstage/a/b/file.json',
|
||||
);
|
||||
});
|
||||
@@ -241,7 +241,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: { foo: [{ bar: 7 }] } },
|
||||
});
|
||||
|
||||
expect(read).toBeCalledWith(
|
||||
expect(read).toHaveBeenCalledWith(
|
||||
'https://github.com/backstage/backstage/a/file.yaml',
|
||||
);
|
||||
});
|
||||
@@ -280,7 +280,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: 'TEXT' },
|
||||
});
|
||||
|
||||
expect(read).toBeCalledWith(
|
||||
expect(read).toHaveBeenCalledWith(
|
||||
'https://github.com/backstage/backstage/catalog-info.yaml',
|
||||
);
|
||||
});
|
||||
@@ -318,7 +318,7 @@ describe('PlaceholderProcessor', () => {
|
||||
spec: { data: 'TEXT' },
|
||||
});
|
||||
|
||||
expect(read).toBeCalledWith(
|
||||
expect(read).toHaveBeenCalledWith(
|
||||
'https://github.com/backstage/backstage/catalog-info.yaml',
|
||||
);
|
||||
});
|
||||
@@ -356,7 +356,7 @@ describe('PlaceholderProcessor', () => {
|
||||
/^Placeholder \$text could not form a URL out of \.\/a\/b\/catalog-info\.yaml and \.\.\/c\/catalog-info\.yaml, TypeError \[ERR_INVALID_URL\]/,
|
||||
);
|
||||
|
||||
expect(read).not.toBeCalled();
|
||||
expect(read).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should emit the resolverValue as a refreshKey', async () => {
|
||||
read.mockResolvedValue(
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('UrlReaderProcessor', () => {
|
||||
type: 'refresh',
|
||||
key: 'url:http://localhost/component.yaml',
|
||||
});
|
||||
expect(mockCache.set).toBeCalledWith('v1', {
|
||||
expect(mockCache.set).toHaveBeenCalledWith('v1', {
|
||||
etag: 'my-etag',
|
||||
value: [
|
||||
{
|
||||
@@ -101,7 +101,7 @@ describe('UrlReaderProcessor', () => {
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(mockCache.set).toBeCalledTimes(1);
|
||||
expect(mockCache.set).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should use cached data when available', async () => {
|
||||
@@ -147,9 +147,9 @@ describe('UrlReaderProcessor', () => {
|
||||
expect(refresh.type).toBe('refresh');
|
||||
expect(refresh.key).toBe('url:http://localhost/component.yaml');
|
||||
|
||||
expect(mockCache.get).toBeCalledWith('v1');
|
||||
expect(mockCache.get).toBeCalledTimes(1);
|
||||
expect(mockCache.set).toBeCalledTimes(0);
|
||||
expect(mockCache.get).toHaveBeenCalledWith('v1');
|
||||
expect(mockCache.get).toHaveBeenCalledTimes(1);
|
||||
expect(mockCache.set).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should fail load from url with error', async () => {
|
||||
@@ -211,6 +211,6 @@ describe('UrlReaderProcessor', () => {
|
||||
mockCache,
|
||||
);
|
||||
|
||||
expect(reader.search).toBeCalledTimes(1);
|
||||
expect(reader.search).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,8 +100,8 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
|
||||
await engine.start();
|
||||
await waitForExpect(() => {
|
||||
expect(orchestrator.process).toBeCalledTimes(1);
|
||||
expect(orchestrator.process).toBeCalledWith({
|
||||
expect(orchestrator.process).toHaveBeenCalledTimes(1);
|
||||
expect(orchestrator.process).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: '1',
|
||||
kind: 'Location',
|
||||
@@ -167,8 +167,8 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
|
||||
await engine.start();
|
||||
await waitForExpect(() => {
|
||||
expect(orchestrator.process).toBeCalledTimes(1);
|
||||
expect(orchestrator.process).toBeCalledWith({
|
||||
expect(orchestrator.process).toHaveBeenCalledTimes(1);
|
||||
expect(orchestrator.process).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: '1',
|
||||
kind: 'Location',
|
||||
@@ -232,10 +232,10 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
await engine.start();
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(orchestrator.process).toBeCalledTimes(1);
|
||||
expect(hash.digest).toBeCalledTimes(1);
|
||||
expect(db.updateProcessedEntity).toBeCalledTimes(1);
|
||||
expect(db.listParents).toBeCalledTimes(1);
|
||||
expect(orchestrator.process).toHaveBeenCalledTimes(1);
|
||||
expect(hash.digest).toHaveBeenCalledTimes(1);
|
||||
expect(db.updateProcessedEntity).toHaveBeenCalledTimes(1);
|
||||
expect(db.listParents).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
expect(db.updateEntityCache).not.toHaveBeenCalled();
|
||||
|
||||
@@ -247,11 +247,11 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
.mockResolvedValue({ items: [] });
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(orchestrator.process).toBeCalledTimes(2);
|
||||
expect(hash.digest).toBeCalledTimes(2);
|
||||
expect(db.updateProcessedEntity).toBeCalledTimes(1);
|
||||
expect(db.updateEntityCache).toBeCalledTimes(1);
|
||||
expect(db.listParents).toBeCalledTimes(2);
|
||||
expect(orchestrator.process).toHaveBeenCalledTimes(2);
|
||||
expect(hash.digest).toHaveBeenCalledTimes(2);
|
||||
expect(db.updateProcessedEntity).toHaveBeenCalledTimes(1);
|
||||
expect(db.updateEntityCache).toHaveBeenCalledTimes(1);
|
||||
expect(db.listParents).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), {
|
||||
id: '',
|
||||
@@ -307,7 +307,7 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
}));
|
||||
|
||||
await waitForExpect(() => {
|
||||
expect(db.updateEntityCache).toBeCalledTimes(1);
|
||||
expect(db.updateEntityCache).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), {
|
||||
@@ -329,7 +329,7 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
|
||||
db.updateEntityCache.mockReset();
|
||||
await waitForExpect(() => {
|
||||
expect(db.updateEntityCache).toBeCalledTimes(1);
|
||||
expect(db.updateEntityCache).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
expect(db.updateEntityCache).toHaveBeenCalledWith(expect.anything(), {
|
||||
@@ -442,7 +442,7 @@ describe('DefaultCatalogProcessingEngine', () => {
|
||||
|
||||
await engine.start();
|
||||
await waitForExpect(() => {
|
||||
expect(stitcher.stitch).toBeCalledTimes(2);
|
||||
expect(stitcher.stitch).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
expect([...stitcher.stitch.mock.calls[0][0]]).toEqual(
|
||||
expect.arrayContaining(['k:ns/me', 'k:ns/other1', 'k:ns/other2']),
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('AuthorizedEntitiesCatalog', () => {
|
||||
|
||||
await expect(() =>
|
||||
catalog.removeEntityByUid('uid', { authorizationToken: 'abcd' }),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
|
||||
it('throws error on CONDITIONAL authorization that evaluates to 0 entities', async () => {
|
||||
@@ -129,7 +129,7 @@ describe('AuthorizedEntitiesCatalog', () => {
|
||||
|
||||
await expect(() =>
|
||||
catalog.removeEntityByUid('uid', { authorizationToken: 'abcd' }),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
|
||||
it('calls underlying catalog method on CONDITIONAL authorization that evaluates to nonzero entities', async () => {
|
||||
@@ -185,7 +185,7 @@ describe('AuthorizedEntitiesCatalog', () => {
|
||||
catalog.entityAncestry('backstage:default/component', {
|
||||
authorizationToken: 'Bearer abcd',
|
||||
}),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
|
||||
it('filters out unauthorized entities and their parents', async () => {
|
||||
|
||||
@@ -73,7 +73,7 @@ describe('AuthorizedLocationService', () => {
|
||||
service.createLocation(spec, false, {
|
||||
authorizationToken: 'Bearer authtoken',
|
||||
}),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -117,7 +117,7 @@ describe('AuthorizedLocationService', () => {
|
||||
|
||||
await expect(() =>
|
||||
service.getLocation('id', { authorizationToken: 'Bearer authtoken' }),
|
||||
).rejects.toThrowError(NotFoundError);
|
||||
).rejects.toThrow(NotFoundError);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -141,7 +141,7 @@ describe('AuthorizedLocationService', () => {
|
||||
service.deleteLocation('id', {
|
||||
authorizationToken: 'Bearer authtoken',
|
||||
}),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -48,7 +48,7 @@ describe('AuthorizedRefreshService', () => {
|
||||
entityRef: 'some entity ref',
|
||||
authorizationToken: 'some auth token',
|
||||
}),
|
||||
).rejects.toThrowError(NotAllowedError);
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
|
||||
it('calls refresh on allow', async () => {
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('DefaultLocationServiceTest', () => {
|
||||
true,
|
||||
);
|
||||
|
||||
expect(orchestrator.process).toBeCalledWith({
|
||||
expect(orchestrator.process).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Location',
|
||||
@@ -108,7 +108,7 @@ describe('DefaultLocationServiceTest', () => {
|
||||
state: expect.anything(),
|
||||
});
|
||||
|
||||
expect(orchestrator.process).toBeCalledWith({
|
||||
expect(orchestrator.process).toHaveBeenCalledWith({
|
||||
entity: {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
kind: 'Component',
|
||||
@@ -116,8 +116,8 @@ describe('DefaultLocationServiceTest', () => {
|
||||
},
|
||||
state: expect.anything(),
|
||||
});
|
||||
expect(orchestrator.process).toBeCalledTimes(2);
|
||||
expect(store.createLocation).not.toBeCalled();
|
||||
expect(orchestrator.process).toHaveBeenCalledTimes(2);
|
||||
expect(store.createLocation).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should check for location existence when running in dry run', async () => {
|
||||
@@ -255,7 +255,7 @@ describe('DefaultLocationServiceTest', () => {
|
||||
type: 'url',
|
||||
},
|
||||
});
|
||||
expect(store.createLocation).toBeCalledWith({
|
||||
expect(store.createLocation).toHaveBeenCalledWith({
|
||||
target: 'https://backstage.io/catalog-info.yaml',
|
||||
type: 'url',
|
||||
});
|
||||
@@ -289,7 +289,7 @@ describe('DefaultLocationServiceTest', () => {
|
||||
type: 'unknown',
|
||||
},
|
||||
});
|
||||
expect(store.createLocation).toBeCalledWith({
|
||||
expect(store.createLocation).toHaveBeenCalledWith({
|
||||
target: 'https://backstage.io/catalog-info.yaml',
|
||||
type: 'unknown',
|
||||
});
|
||||
@@ -330,21 +330,21 @@ describe('DefaultLocationServiceTest', () => {
|
||||
describe('listLocations', () => {
|
||||
it('should call locationStore.deleteLocation', async () => {
|
||||
await locationService.listLocations();
|
||||
expect(store.listLocations).toBeCalled();
|
||||
expect(store.listLocations).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteLocation', () => {
|
||||
it('should call locationStore.deleteLocation', async () => {
|
||||
await locationService.deleteLocation('123');
|
||||
expect(store.deleteLocation).toBeCalledWith('123');
|
||||
expect(store.deleteLocation).toHaveBeenCalledWith('123');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getLocation', () => {
|
||||
it('should call locationStore.getLocation', async () => {
|
||||
await locationService.getLocation('123');
|
||||
expect(store.getLocation).toBeCalledWith('123');
|
||||
expect(store.getLocation).toHaveBeenCalledWith('123');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('<CatalogGraphCard/>', () => {
|
||||
|
||||
expect(await findByText('b:d/c')).toBeInTheDocument();
|
||||
expect(await findAllByTestId('node')).toHaveLength(1);
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(1);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('renders with custom title', async () => {
|
||||
|
||||
@@ -123,7 +123,7 @@ describe('<CatalogGraphPage/>', () => {
|
||||
expect(await findByText('b:d/c')).toBeInTheDocument();
|
||||
expect(await findByText('b:d/e')).toBeInTheDocument();
|
||||
expect(await findAllByTestId('node')).toHaveLength(2);
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(2);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('should toggle filters', async () => {
|
||||
@@ -169,7 +169,7 @@ describe('<CatalogGraphPage/>', () => {
|
||||
const user = userEvent.setup();
|
||||
await user.keyboard('{Shift>}');
|
||||
await user.click(getByText('b:d/e'));
|
||||
expect(navigate).toBeCalledWith('/entity/{kind}/{namespace}/{name}');
|
||||
expect(navigate).toHaveBeenCalledWith('/entity/{kind}/{namespace}/{name}');
|
||||
});
|
||||
|
||||
test('should capture analytics event when selecting other entity', async () => {
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('<DirectionFilter/>', () => {
|
||||
|
||||
await waitFor(() => {
|
||||
expect(getByText('Top to bottom')).toBeInTheDocument();
|
||||
expect(onChange).toBeCalledWith(Direction.TOP_BOTTOM);
|
||||
expect(onChange).toHaveBeenCalledWith(Direction.TOP_BOTTOM);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('<MaxDepthFilter/>', () => {
|
||||
);
|
||||
|
||||
await userEvent.click(getByLabelText('clear max depth'));
|
||||
expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY);
|
||||
expect(onChange).toHaveBeenCalledWith(Number.POSITIVE_INFINITY);
|
||||
});
|
||||
|
||||
test('should set max depth to undefined if below one', async () => {
|
||||
@@ -56,7 +56,7 @@ describe('<MaxDepthFilter/>', () => {
|
||||
await userEvent.clear(getByLabelText('maxp'));
|
||||
await userEvent.type(getByLabelText('maxp'), '0');
|
||||
|
||||
expect(onChange).toBeCalledWith(Number.POSITIVE_INFINITY);
|
||||
expect(onChange).toHaveBeenCalledWith(Number.POSITIVE_INFINITY);
|
||||
});
|
||||
|
||||
test('should select direction', async () => {
|
||||
@@ -70,7 +70,7 @@ describe('<MaxDepthFilter/>', () => {
|
||||
await userEvent.clear(getByLabelText('maxp'));
|
||||
await userEvent.type(getByLabelText('maxp'), '10');
|
||||
waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(10);
|
||||
expect(onChange).toHaveBeenCalledWith(10);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('<SelectedKindsFilter/>', () => {
|
||||
await userEvent.click(getByText('System'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(['api', 'component', 'system']);
|
||||
expect(onChange).toHaveBeenCalledWith(['api', 'component', 'system']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -96,7 +96,7 @@ describe('<SelectedKindsFilter/>', () => {
|
||||
await userEvent.click(getByText('Resource'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(undefined);
|
||||
expect(onChange).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -112,7 +112,7 @@ describe('<SelectedKindsFilter/>', () => {
|
||||
await userEvent.tab();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(undefined);
|
||||
expect(onChange).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ describe('<SelectedRelationsFilter/>', () => {
|
||||
await userEvent.click(getByText(RELATION_HAS_MEMBER));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith([
|
||||
expect(onChange).toHaveBeenCalledWith([
|
||||
RELATION_OWNED_BY,
|
||||
RELATION_CHILD_OF,
|
||||
RELATION_HAS_MEMBER,
|
||||
@@ -86,7 +86,7 @@ describe('<SelectedRelationsFilter/>', () => {
|
||||
await userEvent.click(getByText(RELATION_HAS_MEMBER));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(undefined);
|
||||
expect(onChange).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('<SelectedRelationsFilter/>', () => {
|
||||
await userEvent.tab();
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onChange).toBeCalledWith(undefined);
|
||||
expect(onChange).toHaveBeenCalledWith(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,6 +39,6 @@ describe('<SwitchFilter/>', () => {
|
||||
|
||||
await userEvent.click(getByLabelText('My label'));
|
||||
|
||||
expect(onChange).toBeCalledWith(false);
|
||||
expect(onChange).toHaveBeenCalledWith(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('useCatalogGraphPage', () => {
|
||||
|
||||
act(() => result.current.setMaxDepth(5));
|
||||
|
||||
expect(windowHistoryReplaceState).toBeCalledWith(
|
||||
expect(windowHistoryReplaceState).toHaveBeenCalledWith(
|
||||
null,
|
||||
'',
|
||||
'/?maxDepth=5&unidirectional=true&mergeRelations=true&direction=LR&showFilters=true',
|
||||
@@ -114,7 +114,7 @@ describe('useCatalogGraphPage', () => {
|
||||
|
||||
act(() => result.current.setUnidirectional(false));
|
||||
|
||||
expect(windowHistoryReplaceState).toBeCalledWith(
|
||||
expect(windowHistoryReplaceState).toHaveBeenCalledWith(
|
||||
null,
|
||||
'',
|
||||
'/?maxDepth=5&unidirectional=false&mergeRelations=true&direction=LR&showFilters=true',
|
||||
@@ -138,7 +138,7 @@ describe('useCatalogGraphPage', () => {
|
||||
|
||||
rerender();
|
||||
|
||||
expect(windowHistoryPushState).toBeCalledWith(
|
||||
expect(windowHistoryPushState).toHaveBeenCalledWith(
|
||||
null,
|
||||
'',
|
||||
'/?rootEntityRefs%5B%5D=component%3Adefault%2Fmy&maxDepth=%E2%88%9E&unidirectional=true&mergeRelations=true&direction=LR&showFilters=true',
|
||||
|
||||
@@ -75,7 +75,7 @@ describe('<CustomNode />', () => {
|
||||
|
||||
expect(getByText('kind:namespace/name')).toBeInTheDocument();
|
||||
await userEvent.click(getByText('kind:namespace/name'));
|
||||
expect(onClick).toBeCalledTimes(1);
|
||||
expect(onClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('renders title if entity has one', async () => {
|
||||
|
||||
+10
-10
@@ -153,7 +153,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
|
||||
expect(await findByText('b:d/c')).toBeInTheDocument();
|
||||
expect(await findAllByTestId('node')).toHaveLength(1);
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(1);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('renders a progress indicator while loading', async () => {
|
||||
@@ -168,7 +168,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
);
|
||||
|
||||
expect(await findByRole('progressbar')).toBeInTheDocument();
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(1);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('does not explode if an entity is missing', async () => {
|
||||
@@ -208,7 +208,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
|
||||
expect(await findByText('b:d/c')).toBeInTheDocument();
|
||||
expect(await findAllByTestId('node')).toHaveLength(1);
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(2);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('renders at max depth of one', async () => {
|
||||
@@ -231,7 +231,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('hasPart')).toHaveLength(1);
|
||||
expect(await findAllByTestId('label')).toHaveLength(2);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(3);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
test('renders simplied graph at full depth', async () => {
|
||||
@@ -256,7 +256,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('hasPart')).toHaveLength(2);
|
||||
expect(await findAllByTestId('label')).toHaveLength(3);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(4);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
test('renders full graph at full depth', async () => {
|
||||
@@ -283,7 +283,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('partOf')).toHaveLength(2);
|
||||
expect(await findAllByTestId('label')).toHaveLength(8);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(4);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
test('renders full graph at full depth with merged relations', async () => {
|
||||
@@ -308,7 +308,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('hasPart')).toHaveLength(2);
|
||||
expect(await findAllByTestId('label')).toHaveLength(4);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(4);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
test('renders a graph with multiple root nodes', async () => {
|
||||
@@ -334,7 +334,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('partOf')).toHaveLength(2);
|
||||
expect(await findAllByTestId('label')).toHaveLength(3);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(4);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
test('renders a graph with filtered kinds and relations', async () => {
|
||||
@@ -356,7 +356,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
expect(await findAllByText('ownerOf')).toHaveLength(1);
|
||||
expect(await findAllByTestId('label')).toHaveLength(1);
|
||||
|
||||
expect(catalog.getEntityByRef).toBeCalledTimes(2);
|
||||
expect(catalog.getEntityByRef).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
test('handle clicks on a node', async () => {
|
||||
@@ -371,7 +371,7 @@ describe('<EntityRelationsGraph/>', () => {
|
||||
);
|
||||
|
||||
await userEvent.click(await findByText('k:d/a1'));
|
||||
expect(onNodeClick).toBeCalledTimes(1);
|
||||
expect(onNodeClick).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('render custom node', async () => {
|
||||
|
||||
@@ -233,6 +233,6 @@ describe('useEntityStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
expect(catalogApi.getEntityByRef).toBeCalledTimes(2);
|
||||
expect(catalogApi.getEntityByRef).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -164,7 +164,7 @@ describe('CatalogImportClient', () => {
|
||||
type: 'locations',
|
||||
});
|
||||
|
||||
expect(catalogApi.addLocation).toBeCalledTimes(1);
|
||||
expect(catalogApi.addLocation).toHaveBeenCalledTimes(1);
|
||||
expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({
|
||||
type: 'url',
|
||||
target: 'http://example.com/folder/catalog-info.yaml',
|
||||
@@ -213,7 +213,7 @@ describe('CatalogImportClient', () => {
|
||||
type: 'locations',
|
||||
});
|
||||
|
||||
expect(catalogApi.addLocation).toBeCalledTimes(1);
|
||||
expect(catalogApi.addLocation).toHaveBeenCalledTimes(1);
|
||||
expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({
|
||||
type: 'url',
|
||||
target:
|
||||
@@ -261,7 +261,7 @@ describe('CatalogImportClient', () => {
|
||||
type: 'locations',
|
||||
});
|
||||
|
||||
expect(catalogApi.addLocation).toBeCalledTimes(1);
|
||||
expect(catalogApi.addLocation).toHaveBeenCalledTimes(1);
|
||||
expect(catalogApi.addLocation.mock.calls[0][0]).toEqual({
|
||||
type: 'url',
|
||||
target: 'http://example.com/folder/catalog-info.yaml?branch=test',
|
||||
|
||||
+20
-20
@@ -106,9 +106,9 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
}
|
||||
});
|
||||
|
||||
expect(catalogImportApi.analyzeUrl).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(catalogImportApi.analyzeUrl).toHaveBeenCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should not analyze invalid value', async () => {
|
||||
@@ -129,9 +129,9 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(catalogImportApi.analyzeUrl).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(catalogImportApi.analyzeUrl).toHaveBeenCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
expect(
|
||||
getByText('Must start with http:// or https://.'),
|
||||
).toBeInTheDocument();
|
||||
@@ -164,14 +164,14 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(1);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(1);
|
||||
expect(onAnalysisFn.mock.calls[0]).toMatchObject([
|
||||
'single-location',
|
||||
'https://my-repository',
|
||||
analyzeResult,
|
||||
{ prepareResult: analyzeResult },
|
||||
]);
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should analyze multiple locations', async () => {
|
||||
@@ -201,13 +201,13 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(1);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(1);
|
||||
expect(onAnalysisFn.mock.calls[0]).toMatchObject([
|
||||
'multiple-locations',
|
||||
'https://my-repository-1',
|
||||
analyzeResult,
|
||||
]);
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should not analyze with no locations', async () => {
|
||||
@@ -237,11 +237,11 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(
|
||||
getByText('There are no entities at this location'),
|
||||
).toBeInTheDocument();
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should analyze repository', async () => {
|
||||
@@ -281,13 +281,13 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(1);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(1);
|
||||
expect(onAnalysisFn.mock.calls[0]).toMatchObject([
|
||||
'no-location',
|
||||
'https://my-repository-2',
|
||||
analyzeResult,
|
||||
]);
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should not analyze repository without entities', async () => {
|
||||
@@ -319,11 +319,11 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(
|
||||
getByText("Couldn't generate entities for your repository"),
|
||||
).toBeInTheDocument();
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should not analyze repository if disabled', async () => {
|
||||
@@ -363,11 +363,11 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(
|
||||
getByText("Couldn't generate entities for your repository"),
|
||||
).toBeInTheDocument();
|
||||
expect(errorApi.post).toBeCalledTimes(0);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should report unknown type to the errorapi', async () => {
|
||||
@@ -392,13 +392,13 @@ describe('<StepInitAnalyzeUrl />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Analyze/i }));
|
||||
});
|
||||
|
||||
expect(onAnalysisFn).toBeCalledTimes(0);
|
||||
expect(onAnalysisFn).toHaveBeenCalledTimes(0);
|
||||
expect(
|
||||
getByText(
|
||||
'Received unknown analysis result of type unknown. Please contact the support team.',
|
||||
),
|
||||
).toBeInTheDocument();
|
||||
expect(errorApi.post).toBeCalledTimes(1);
|
||||
expect(errorApi.post).toHaveBeenCalledTimes(1);
|
||||
expect(errorApi.post.mock.calls[0][0]).toMatchObject(
|
||||
new Error(
|
||||
'Received unknown analysis result of type unknown. Please contact the support team.',
|
||||
|
||||
+3
-3
@@ -42,7 +42,7 @@ describe('<PreparePullRequestForm />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /submit/i }));
|
||||
});
|
||||
|
||||
expect(onSubmitFn).toBeCalledTimes(1);
|
||||
expect(onSubmitFn).toHaveBeenCalledTimes(1);
|
||||
expect(onSubmitFn.mock.calls[0][0]).toMatchObject({ main: 'default' });
|
||||
});
|
||||
|
||||
@@ -72,7 +72,7 @@ describe('<PreparePullRequestForm />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /submit/i }));
|
||||
});
|
||||
|
||||
expect(onSubmitFn).toBeCalledTimes(1);
|
||||
expect(onSubmitFn).toHaveBeenCalledTimes(1);
|
||||
expect(onSubmitFn.mock.calls[0][0]).toMatchObject({ main: 'My Text' });
|
||||
});
|
||||
|
||||
@@ -107,7 +107,7 @@ describe('<PreparePullRequestForm />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /submit/i }));
|
||||
});
|
||||
|
||||
expect(onSubmitFn).not.toBeCalled();
|
||||
expect(onSubmitFn).not.toHaveBeenCalled();
|
||||
expect(queryByText('Error in required main field')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
+6
-6
@@ -173,7 +173,7 @@ describe('<StepPrepareCreatePullRequest />', () => {
|
||||
await userEvent.click(screen.getByRole('button', { name: /Create PR/i }));
|
||||
});
|
||||
|
||||
expect(catalogImportApi.submitPullRequest).toBeCalledTimes(1);
|
||||
expect(catalogImportApi.submitPullRequest).toHaveBeenCalledTimes(1);
|
||||
expect(catalogImportApi.submitPullRequest.mock.calls[0]).toMatchObject([
|
||||
{
|
||||
body: 'My **body**',
|
||||
@@ -189,7 +189,7 @@ spec:
|
||||
title: 'My title',
|
||||
},
|
||||
]);
|
||||
expect(onPrepareFn).toBeCalledTimes(1);
|
||||
expect(onPrepareFn).toHaveBeenCalledTimes(1);
|
||||
expect(onPrepareFn.mock.calls[0]).toMatchObject([
|
||||
{
|
||||
type: 'repository',
|
||||
@@ -250,8 +250,8 @@ spec:
|
||||
});
|
||||
|
||||
expect(screen.getByText('some error')).toBeInTheDocument();
|
||||
expect(catalogImportApi.submitPullRequest).toBeCalledTimes(1);
|
||||
expect(onPrepareFn).toBeCalledTimes(0);
|
||||
expect(catalogImportApi.submitPullRequest).toHaveBeenCalledTimes(1);
|
||||
expect(onPrepareFn).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
it('should load groups', async () => {
|
||||
@@ -283,8 +283,8 @@ spec:
|
||||
);
|
||||
});
|
||||
|
||||
expect(catalogApi.getEntities).toBeCalledTimes(1);
|
||||
expect(renderFormFieldsFn).toBeCalled();
|
||||
expect(catalogApi.getEntities).toHaveBeenCalledTimes(1);
|
||||
expect(renderFormFieldsFn).toHaveBeenCalled();
|
||||
expect(renderFormFieldsFn.mock.calls[0][0]).toMatchObject({
|
||||
groups: [],
|
||||
groupsLoading: true,
|
||||
|
||||
+2
-2
@@ -200,7 +200,7 @@ describe('<StepPrepareSelectLocations />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Back/i }));
|
||||
});
|
||||
|
||||
expect(onGoBack).toBeCalledTimes(1);
|
||||
expect(onGoBack).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should submit', async () => {
|
||||
@@ -224,7 +224,7 @@ describe('<StepPrepareSelectLocations />', () => {
|
||||
await userEvent.click(getByRole('button', { name: /Review/i }));
|
||||
});
|
||||
|
||||
expect(onPrepare).toBeCalledTimes(1);
|
||||
expect(onPrepare).toHaveBeenCalledTimes(1);
|
||||
expect(onPrepare.mock.calls[0][0]).toMatchObject({
|
||||
type: 'locations',
|
||||
locations: [
|
||||
|
||||
+9
-9
@@ -101,7 +101,7 @@ describe('UnregisterEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Cancel'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onClose).toBeCalled();
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -196,8 +196,8 @@ describe('UnregisterEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Delete Entity'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(deleteEntity).toBeCalled();
|
||||
expect(onConfirm).toBeCalled();
|
||||
expect(deleteEntity).toHaveBeenCalled();
|
||||
expect(onConfirm).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -236,8 +236,8 @@ describe('UnregisterEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Delete Entity'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(deleteEntity).toBeCalled();
|
||||
expect(onConfirm).toBeCalled();
|
||||
expect(deleteEntity).toHaveBeenCalled();
|
||||
expect(onConfirm).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -284,8 +284,8 @@ describe('UnregisterEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Unregister Location'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(unregisterLocation).toBeCalled();
|
||||
expect(onConfirm).toBeCalled();
|
||||
expect(unregisterLocation).toHaveBeenCalled();
|
||||
expect(onConfirm).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -340,8 +340,8 @@ describe('UnregisterEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Delete Entity'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(deleteEntity).toBeCalled();
|
||||
expect(onConfirm).toBeCalled();
|
||||
expect(deleteEntity).toHaveBeenCalled();
|
||||
expect(onConfirm).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,8 +58,8 @@ describe('useStarredEntity', () => {
|
||||
|
||||
result.current.toggleStarredEntity();
|
||||
|
||||
expect(mockStarredEntitiesApi.toggleStarred).toBeCalledTimes(1);
|
||||
expect(mockStarredEntitiesApi.toggleStarred).toBeCalledWith(
|
||||
expect(mockStarredEntitiesApi.toggleStarred).toHaveBeenCalledTimes(1);
|
||||
expect(mockStarredEntitiesApi.toggleStarred).toHaveBeenCalledWith(
|
||||
'component:default/mock',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('DefaultStarredEntitiesApi', () => {
|
||||
const api = new DefaultStarredEntitiesApi({
|
||||
storageApi: MockStorageApi.create(),
|
||||
});
|
||||
expect(performMigrationToTheNewBucket).toBeCalledTimes(1);
|
||||
expect(performMigrationToTheNewBucket).toHaveBeenCalledTimes(1);
|
||||
expect(api).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('ComponentContextMenu', () => {
|
||||
expect(unregister).toBeInTheDocument();
|
||||
fireEvent.click(unregister);
|
||||
|
||||
expect(mockCallback).toBeCalled();
|
||||
expect(mockCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('check Unregister entity button is disabled', async () => {
|
||||
@@ -102,7 +102,7 @@ describe('ComponentContextMenu', () => {
|
||||
expect(unregister).toBeInTheDocument();
|
||||
fireEvent.click(unregister);
|
||||
|
||||
expect(mockCallback).toBeCalled();
|
||||
expect(mockCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('supports extra items', async () => {
|
||||
@@ -128,6 +128,6 @@ describe('ComponentContextMenu', () => {
|
||||
expect(item).toBeInTheDocument();
|
||||
fireEvent.click(item);
|
||||
|
||||
expect(extra.onClick).toBeCalled();
|
||||
expect(extra.onClick).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('ComponentContextMenu', () => {
|
||||
expect(unregister).toBeInTheDocument();
|
||||
fireEvent.click(unregister);
|
||||
|
||||
expect(mockCallback).toBeCalled();
|
||||
expect(mockCallback).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('check Unregister entity button is disabled', async () => {
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('DeleteEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Cancel'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(onClose).toBeCalled();
|
||||
expect(onClose).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,8 +101,8 @@ describe('DeleteEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Delete'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(catalogClient.removeEntityByUid).toBeCalledWith('123');
|
||||
expect(onConfirm).toBeCalled();
|
||||
expect(catalogClient.removeEntityByUid).toHaveBeenCalledWith('123');
|
||||
expect(onConfirm).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -124,8 +124,8 @@ describe('DeleteEntityDialog', () => {
|
||||
await userEvent.click(screen.getByText('Delete'));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(catalogClient.removeEntityByUid).toBeCalledWith('123');
|
||||
expect(alertApi.post).toBeCalledWith({ message: 'no no no' });
|
||||
expect(catalogClient.removeEntityByUid).toHaveBeenCalledWith('123');
|
||||
expect(alertApi.post).toHaveBeenCalledWith({ message: 'no no no' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -170,7 +170,7 @@ describe('<FossaPage />', () => {
|
||||
},
|
||||
);
|
||||
|
||||
expect(catalogApi.getEntities).toBeCalledWith(
|
||||
expect(catalogApi.getEntities).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
filter: { kind: 'API' },
|
||||
}),
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: jenkinsInfo.jobFullName,
|
||||
tree: expect.anything(),
|
||||
});
|
||||
@@ -127,7 +127,7 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: `${jenkinsInfo.jobFullName}/testBranchName`,
|
||||
tree: expect.anything(),
|
||||
});
|
||||
@@ -148,15 +148,15 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: `${jenkinsInfo.jobFullName}/foo`,
|
||||
tree: expect.anything(),
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: `${jenkinsInfo.jobFullName}/bar`,
|
||||
tree: expect.anything(),
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: `${jenkinsInfo.jobFullName}/catpants`,
|
||||
tree: expect.anything(),
|
||||
});
|
||||
@@ -643,11 +643,11 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.get).toBeCalledWith({
|
||||
expect(mockedJenkinsClient.job.get).toHaveBeenCalledWith({
|
||||
name: jobFullName,
|
||||
depth: 1,
|
||||
});
|
||||
expect(mockedJenkinsClient.build.get).toBeCalledWith(
|
||||
expect(mockedJenkinsClient.build.get).toHaveBeenCalledWith(
|
||||
jobFullName,
|
||||
buildNumber,
|
||||
);
|
||||
@@ -660,7 +660,7 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
|
||||
expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName);
|
||||
});
|
||||
|
||||
it('buildProject should fail if it does not have required permissions', async () => {
|
||||
@@ -688,7 +688,7 @@ describe('JenkinsApi', () => {
|
||||
headers: jenkinsInfo.headers,
|
||||
promisify: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
|
||||
expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName);
|
||||
});
|
||||
|
||||
it('buildProject with crumbIssuer option', async () => {
|
||||
@@ -701,6 +701,6 @@ describe('JenkinsApi', () => {
|
||||
promisify: true,
|
||||
crumbIssuer: true,
|
||||
});
|
||||
expect(mockedJenkinsClient.job.build).toBeCalledWith(jobFullName);
|
||||
expect(mockedJenkinsClient.job.build).toHaveBeenCalledWith(jobFullName);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -183,9 +183,9 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
|
||||
it('Handles entity not found', async () => {
|
||||
const provider = configureProvider({ jenkins: {} }, undefined);
|
||||
await expect(provider.getInstance({ entityRef })).rejects.toThrowError();
|
||||
await expect(provider.getInstance({ entityRef })).rejects.toThrow();
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
});
|
||||
@@ -209,7 +209,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toStrictEqual({
|
||||
@@ -247,7 +247,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
@@ -286,7 +286,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
@@ -325,7 +325,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
@@ -353,7 +353,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
@@ -381,7 +381,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
@@ -414,7 +414,7 @@ describe('DefaultJenkinsInfoProvider', () => {
|
||||
);
|
||||
const info: JenkinsInfo = await provider.getInstance({ entityRef });
|
||||
|
||||
expect(mockCatalog.getEntityByRef).toBeCalledWith(entityRef, {
|
||||
expect(mockCatalog.getEntityByRef).toHaveBeenCalledWith(entityRef, {
|
||||
backstageToken: undefined,
|
||||
});
|
||||
expect(info).toMatchObject({
|
||||
|
||||
@@ -133,6 +133,6 @@ describe('KafkaDashboardClient', () => {
|
||||
} as unknown as Entity;
|
||||
|
||||
kafkaDashboardClient.getDashboardUrl('cluster2', '', mockEntity);
|
||||
expect(mockConfigApi.getConfigArray).toBeCalled();
|
||||
expect(mockConfigApi.getConfigArray).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ describe('useConsumerGroupOffsets', () => {
|
||||
},
|
||||
};
|
||||
const { result } = subject();
|
||||
expect(() => result.current).toThrowError();
|
||||
expect(() => result.current).toThrow();
|
||||
expect(result.error).toStrictEqual(
|
||||
new Error(
|
||||
`Failed to parse kafka consumer group annotation: got "dev/another,consumer"`,
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('GkeClusterLocator', () => {
|
||||
listClusters: mockedListClusters,
|
||||
} as any);
|
||||
|
||||
expect(mockedListClusters).toBeCalledTimes(0);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
it('should not accept missing projectId', async () => {
|
||||
const config: Config = new ConfigReader({
|
||||
@@ -48,7 +48,7 @@ describe('GkeClusterLocator', () => {
|
||||
} as any),
|
||||
).toThrow("Missing required config value at 'projectId'");
|
||||
|
||||
expect(mockedListClusters).toBeCalledTimes(0);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
describe('listClusters', () => {
|
||||
@@ -72,7 +72,7 @@ describe('GkeClusterLocator', () => {
|
||||
const result = await sut.getClusters();
|
||||
|
||||
expect(result).toStrictEqual([]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -111,7 +111,7 @@ describe('GkeClusterLocator', () => {
|
||||
skipMetricsLookup: true,
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -148,7 +148,7 @@ describe('GkeClusterLocator', () => {
|
||||
skipMetricsLookup: false,
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/-',
|
||||
});
|
||||
@@ -197,7 +197,7 @@ describe('GkeClusterLocator', () => {
|
||||
skipMetricsLookup: false,
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -252,7 +252,7 @@ describe('GkeClusterLocator', () => {
|
||||
skipMetricsLookup: false,
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -306,7 +306,7 @@ describe('GkeClusterLocator', () => {
|
||||
skipMetricsLookup: false,
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -330,7 +330,7 @@ describe('GkeClusterLocator', () => {
|
||||
'There was an error retrieving clusters from GKE for projectId=some-project region=some-region; caused by Error: some error',
|
||||
);
|
||||
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
@@ -376,7 +376,7 @@ describe('GkeClusterLocator', () => {
|
||||
},
|
||||
},
|
||||
]);
|
||||
expect(mockedListClusters).toBeCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockedListClusters).toHaveBeenCalledWith({
|
||||
parent: 'projects/some-project/locations/some-region',
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ describe('getCombinedClusterSupplier', () => {
|
||||
'ctx',
|
||||
);
|
||||
|
||||
expect(() => getCombinedClusterSupplier(config, catalogApi)).toThrowError(
|
||||
expect(() => getCombinedClusterSupplier(config, catalogApi)).toThrow(
|
||||
new Error('Unsupported kubernetes.clusterLocatorMethods: "magic"'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -72,9 +72,11 @@ describe('useKubernetesObjects', () => {
|
||||
const mockDecorateRequestBodyForAuth = jest.fn();
|
||||
|
||||
const expectMocksCalledCorrectly = (numOfCalls: number = 1) => {
|
||||
expect(mockGetClusters).toBeCalledTimes(numOfCalls);
|
||||
expect(mockGetClusters).toHaveBeenCalledTimes(numOfCalls);
|
||||
expect(mockGetClusters).toHaveBeenLastCalledWith();
|
||||
expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(numOfCalls * 2);
|
||||
expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes(
|
||||
numOfCalls * 2,
|
||||
);
|
||||
expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledWith('google', {
|
||||
entity,
|
||||
});
|
||||
@@ -82,7 +84,7 @@ describe('useKubernetesObjects', () => {
|
||||
'authprovider2',
|
||||
entityWithAuthToken,
|
||||
);
|
||||
expect(mockGetObjectsByEntity).toBeCalledTimes(numOfCalls);
|
||||
expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(numOfCalls);
|
||||
expect(mockGetObjectsByEntity).toHaveBeenLastCalledWith(
|
||||
entityWithAuthToken,
|
||||
);
|
||||
@@ -166,10 +168,10 @@ describe('useKubernetesObjects', () => {
|
||||
expect(result.current.error).toBe('some-error');
|
||||
expect(result.current.kubernetesObjects).toBeUndefined();
|
||||
|
||||
expect(mockGetClusters).toBeCalledTimes(1);
|
||||
expect(mockGetClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetClusters).toHaveBeenLastCalledWith();
|
||||
expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(0);
|
||||
expect(mockGetObjectsByEntity).toBeCalledTimes(0);
|
||||
expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes(0);
|
||||
expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
it('should return error when decorateRequestBodyForAuth throws', async () => {
|
||||
(useApi as any).mockReturnValue({
|
||||
@@ -189,12 +191,12 @@ describe('useKubernetesObjects', () => {
|
||||
expect(result.current.error).toBe('some-error');
|
||||
expect(result.current.kubernetesObjects).toBeUndefined();
|
||||
|
||||
expect(mockGetClusters).toBeCalledTimes(1);
|
||||
expect(mockGetClusters).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetClusters).toHaveBeenLastCalledWith();
|
||||
expect(mockDecorateRequestBodyForAuth).toBeCalledTimes(1);
|
||||
expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledTimes(1);
|
||||
expect(mockDecorateRequestBodyForAuth).toHaveBeenCalledWith('google', {
|
||||
entity,
|
||||
});
|
||||
expect(mockGetObjectsByEntity).toBeCalledTimes(0);
|
||||
expect(mockGetObjectsByEntity).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,9 +42,7 @@ describe('clusterLinks', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
"Could not find Kubernetes dashboard app named 'unknownapp'",
|
||||
);
|
||||
).toThrow("Could not find Kubernetes dashboard app named 'unknownapp'");
|
||||
});
|
||||
|
||||
describe('default app', () => {
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('clusterLinks - AKS formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('AKS dashboard requires a dashboardParameters option');
|
||||
).toThrow('AKS dashboard requires a dashboardParameters option');
|
||||
});
|
||||
it('should provide a subscriptionId in the dashboardParameters options', () => {
|
||||
expect(() =>
|
||||
@@ -44,7 +44,7 @@ describe('clusterLinks - AKS formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'AKS dashboard requires a "subscriptionId" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
@@ -63,7 +63,7 @@ describe('clusterLinks - AKS formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'AKS dashboard requires a "resourceGroup" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
@@ -82,7 +82,7 @@ describe('clusterLinks - AKS formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'AKS dashboard requires a "clusterName" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -28,6 +28,6 @@ describe('clusterLinks - EKS formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('EKS formatter is not yet implemented. Please, contribute!');
|
||||
).toThrow('EKS formatter is not yet implemented. Please, contribute!');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('clusterLinks - GKE formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('GKE dashboard requires a dashboardParameters option');
|
||||
).toThrow('GKE dashboard requires a dashboardParameters option');
|
||||
});
|
||||
it('should provide a projectId in the dashboardParameters options', () => {
|
||||
expect(() =>
|
||||
@@ -44,7 +44,7 @@ describe('clusterLinks - GKE formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'GKE dashboard requires a "projectId" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
@@ -63,7 +63,7 @@ describe('clusterLinks - GKE formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'GKE dashboard requires a "region" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
@@ -82,7 +82,7 @@ describe('clusterLinks - GKE formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError(
|
||||
).toThrow(
|
||||
'GKE dashboard requires a "clusterName" of type string in the dashboardParameters option',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('clusterLinks - OpenShift formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('OpenShift dashboard requires a dashboardUrl option');
|
||||
).toThrow('OpenShift dashboard requires a dashboardUrl option');
|
||||
});
|
||||
it('should return an url on the workloads when there is a namespace only', () => {
|
||||
const url = openshiftFormatter({
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('clusterLinks - rancher formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('Rancher dashboard requires a dashboardUrl option');
|
||||
).toThrow('Rancher dashboard requires a dashboardUrl option');
|
||||
});
|
||||
it('should return a url on the workloads when there is a namespace only', () => {
|
||||
const url = rancherFormatter({
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('clusterLinks - standard formatter', () => {
|
||||
},
|
||||
kind: 'Deployment',
|
||||
}),
|
||||
).toThrowError('standard dashboard requires a dashboardUrl option');
|
||||
).toThrow('standard dashboard requires a dashboardUrl option');
|
||||
});
|
||||
it('should return an url on the workloads when there is a namespace only', () => {
|
||||
const url = standardFormatter({
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user