Skip to content

Commit

Permalink
fix: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
markkaylor committed May 24, 2024
1 parent 305e602 commit 38526fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"test:front:update:ce": "yarn test:front:ce -u",
"test:front:watch": "cross-env IS_EE=true run test:front --watch",
"test:front:watch:ce": "cross-env IS_EE=false run test:front --watch",
"test:generate-app": "yarn build:ts && node test/scripts/generate-test-app.js",
"test:generate-app": "yarn build:ts && node tests/scripts/generate-test-app.js",
"test:generate-app:no-build": "node tests/scripts/generate-test-app.js",
"test:ts": "yarn test:ts:packages && yarn test:ts:front && yarn test:ts:back",
"test:ts:back": "nx run-many --target=test:ts:back --nx-ignore-cycles",
Expand Down
22 changes: 18 additions & 4 deletions tests/api/core/admin/ee/audit-logs/audit-logs.test.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describeOnCondition(edition === 'EE')('Audit logs', () => {
let strapi;
let rq;
let contentApiRq;
let initialEntries;

const builder = createTestBuilder();

Expand All @@ -66,7 +65,7 @@ describeOnCondition(edition === 'EE')('Audit logs', () => {
// Ensure the audit logs are empty
await strapi.db.query('admin::audit-log').deleteMany();

initialEntries = await Promise.all([
await Promise.all([
createArticle({ title: 'Article1', password: 'password' }),
createArticle({ title: 'Article2', password: 'password' }),
createArticle({ title: 'Article3', password: 'password' }),
Expand Down Expand Up @@ -121,14 +120,29 @@ describeOnCondition(edition === 'EE')('Audit logs', () => {
const { body } = await rq({ method: 'GET', url: '/admin/audit-logs' });

expect(body.results.length).toBe(3);
expect(body.results[0]).toMatchObject({
id: expect.any(Number),
action: expect.any(String),
date: expect.any(String),
payload: expect.any(Object),
user: expect.any(Object),
});
});

test('Finds one audit log', async () => {
const [auditLogToGet] = await strapi.db?.query('admin::audit-log').findMany();
const { body } = await rq({
method: 'GET',
url: `/admin/audit-logs/${initialEntries[0].data.id}`,
url: `/admin/audit-logs/${auditLogToGet.id}`,
});

expect(body.id).toBe(initialEntries[0].data.id);
expect(body.id).toBe(auditLogToGet.id);
expect(body).toMatchObject({
id: expect.any(Number),
action: expect.any(String),
date: expect.any(String),
payload: expect.any(Object),
user: expect.any(Object),
});
});
});

0 comments on commit 38526fb

Please sign in to comment.