Skip to content

Commit

Permalink
Fix(tenant): Update e2e-api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arimet committed Sep 13, 2023
1 parent 14e1ff0 commit 166bff9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/api/e2e/publishedDataset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ describe('e2e publishedDataset Authentication', () => {

beforeAll(async () => {
server = requestServer();
await clear();
await connect();
await clear('lodex_test');
await connect('lodex_test');
await loadFixtures(fixtures);
});

Expand Down Expand Up @@ -393,9 +393,9 @@ describe('e2e publishedDataset Authentication', () => {
afterAll(async () => {
server.close();

await clear();
await clear('lodex_test');
await close();
const db = await mongoClient();
const db = await mongoClient('lodex_test');
db.close();
});
});
19 changes: 9 additions & 10 deletions src/api/e2e/ssr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const authentifiedHeader = {
},
auth.cookieSecret,
)}`,
headers: {
'X-Lodex-Tenant': 'lodex_test',
},
};

describe('ssr', () => {
Expand All @@ -31,8 +34,8 @@ describe('ssr', () => {
});

beforeEach(async () => {
await clear();
await connect();
await clear('lodex_test');
await connect('lodex_test');
await loadFixtures(fixtures);
});

Expand Down Expand Up @@ -126,9 +129,7 @@ describe('ssr', () => {
});

it('should redirect to login', () => {
expect(state.router.location.pathname).toBe(
'/intance/lodex_test/login',
);
expect(state.router.location.pathname).toBe('/login');
});

it('should not preload the dataset for home', () => {
Expand Down Expand Up @@ -228,9 +229,7 @@ describe('ssr', () => {
});

it('should redirect to login', () => {
expect(state.router.location.pathname).toEqual(
'/intance/lodex_test/login',
);
expect(state.router.location.pathname).toEqual('/login');
});

it('should not preload fields', () => {
Expand Down Expand Up @@ -259,13 +258,13 @@ describe('ssr', () => {
});

afterEach(async () => {
await clear();
await clear('lodex_test');
await close();
});

afterAll(async () => {
server.close();
const db = await mongoClient();
const db = await mongoClient('lodex_test');
db.close();
});
});
6 changes: 3 additions & 3 deletions src/api/services/saveParsedStream-e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const fixtures = {
describe('e2e upload saveparsedStream', () => {
let db;
beforeAll(async () => {
db = await connect();
db = await connect('lodex_test');
});

describe('optimal', () => {
Expand Down Expand Up @@ -211,7 +211,7 @@ describe('e2e upload saveparsedStream', () => {
});

afterAll(async () => {
await clear();
await clear('lodex_test');
});
});

Expand Down Expand Up @@ -311,7 +311,7 @@ describe('e2e upload saveparsedStream', () => {
});

afterAll(async () => {
await clear();
await clear('lodex_test');
});
});

Expand Down
8 changes: 4 additions & 4 deletions src/common/tests/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import mongoClient from '../../api/services/mongoClient';

let db;

export async function connect() {
export async function connect(tenant) {
if (!db) {
db = await mongoClient();
db = await mongoClient(tenant);
db.dataset = await datasetFactory(db);
db.publishedDataset = await publishedDatasetFactory(db);
db.publishedCharacteristic = await publishedCharacteristicFactory(db);
Expand Down Expand Up @@ -48,8 +48,8 @@ export function loadFixtures(fixtures) {
return Promise.all(promises);
}

export async function clear() {
await connect();
export async function clear(tenant) {
await connect(tenant);

await Promise.all([
db.dataset.remove({}),
Expand Down

0 comments on commit 166bff9

Please sign in to comment.