Skip to content

Commit

Permalink
remove redundant tests, temporal assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeh committed Sep 25, 2024
1 parent 83a51bd commit 6fcde3e
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions api/test/sections/sections-crud.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,18 @@ import { TestManager } from 'api/test/utils/test-manager';

describe('Page Sections API', () => {
let testManager: TestManager<unknown>;
let authToken: string;

beforeAll(async () => {
testManager = await TestManager.createTestManager();
await testManager.clearDatabase();
const { jwtToken } = await testManager.setUpTestUser();
authToken = jwtToken;
});

afterAll(async () => {
await testManager.clearDatabase();
await testManager.close();
});

it('Should allow anonymous users to read page sections', async () => {
// When
const res = await testManager.request().get('/sections');

// Then
expect(res.status).toBe(200);
expect(res.body.data).toBeDefined();
});

it('Should allow authenticated users to read page sections with its widgets', async () => {
it('Should allow users to read page sections with its widgets', async () => {
// Given
const entityMocks = testManager.mocks();
const sections = [
Expand All @@ -50,14 +38,12 @@ describe('Page Sections API', () => {
];

// When
const res = await testManager
.request()
.get('/sections') // Implicit ?include[]=baseWidgets&sort[]=order&sort[]=baseWidget.sectionOrder
.set('Authorization', `Bearer ${authToken}`);
const res = await testManager.request().get('/sections'); // Implicit ?include[]=baseWidgets&sort[]=order&sort[]=baseWidget.sectionOrder

// Then
const bodyData = res.body.data;
expect(bodyData).toHaveLength(2);
expect(bodyData).toStrictEqual(ObjectUtils.normalizeDates(sections));
// TODO: Once we figure out how to e2e tests this, we need to assert that the data in each widget in properly computed, along with filters etc
//expect(bodyData).toStrictEqual(ObjectUtils.normalizeDates(sections));
});
});

0 comments on commit 6fcde3e

Please sign in to comment.