mirror of
https://github.com/directus/directus.git
synced 2026-01-23 19:18:07 -05:00
* Remove UTC conversion from date, time and datetime fields * Fix mysql / maria timestamps when not in UTC timezone * Add sequential tests with node timezone change * Increase connection attempt check * Add error catching in tests flow setup * Check for server connectivity * Fix promises * Fix timestamp inconsistencies * Revert to previously used parseISO * Ensure database and directus connection * Add another timezone to test positive and negative GMT * Set local server hostname to localhost * Add tests for SQLite * Use notNullable primary key * Revert connection testing sleep duration * Fix nested transactions on SQLite * Increase MSSQL request timeout * Add type override flag for SQLite * Remove commented code * Add type override flags for Oracle * Updated test file path * Increase test servers launch timeout * Increase test servers launch timeout * Update format of tests * Fix typo * Increase test timeout for CockroachDB * Add type overrides when creating fields through collections service * Remove time field type conversion for Oracle * Update collections list in test * Remove check for time field in Oracle * Add missing continue... * Remove database override * Add note for SQLite * Rename flags and extract shared util * Abstract remaining DB specific checks * Revert flags renaming except renaming of test files * Use date helper to add field flag * Move field date typecasting upstream * Use timestamp helper for date-created and date-updated * Fix tests * Remove unused vars * Add tests for date-created * Increase connection attempt count * Fix test for mariadb * Increase allowable difference to account for delays * Add tests for date-updated * Fix tests again for mariadb * Add date helpers post merge Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import NodeEnvironment from 'jest-environment-node';
|
|
import axios from 'axios';
|
|
import * as SequentialTests from './sequentialTests.js';
|
|
import { sleep } from './utils/sleep';
|
|
|
|
/* eslint-disable no-var */
|
|
declare global {
|
|
var directusFlowDataServerUrl: string;
|
|
var totalTestsCount: number;
|
|
var testFilePath: string;
|
|
}
|
|
|
|
class CustomEnvironment extends NodeEnvironment {
|
|
constructor(config: any, context: any) {
|
|
super(config);
|
|
this.global.testFilePath = String(context.testPath).split('tests')[1]!;
|
|
}
|
|
|
|
async setup() {
|
|
const serverUrl = process.env.serverUrl;
|
|
const totalTestsCount = Number(process.env.totalTestsCount);
|
|
|
|
if (!serverUrl || isNaN(totalTestsCount)) {
|
|
throw 'Missing flow env variables';
|
|
}
|
|
|
|
this.global.directusFlowDataServerUrl = serverUrl;
|
|
this.global.totalTestsCount = totalTestsCount;
|
|
|
|
let waiting = SequentialTests.getReversedTestIndex(this.global.testFilePath) !== 0;
|
|
|
|
while (waiting) {
|
|
const response = await axios.get(
|
|
`${this.global.directusFlowDataServerUrl}/items/tests_flow_completed?aggregate[count]=id&access_token=AdminToken`
|
|
);
|
|
const completedCount = Number(response.data.data[0].count.id);
|
|
|
|
if (
|
|
this.global.totalTestsCount + SequentialTests.getReversedTestIndex(this.global.testFilePath) ===
|
|
completedCount
|
|
) {
|
|
waiting = false;
|
|
} else {
|
|
await sleep(1000);
|
|
}
|
|
}
|
|
|
|
await super.setup();
|
|
}
|
|
|
|
async teardown() {
|
|
const body = {
|
|
test_file_path: this.global.testFilePath,
|
|
};
|
|
|
|
await axios.post(`${this.global.directusFlowDataServerUrl}/items/tests_flow_completed`, body, {
|
|
headers: {
|
|
Authorization: 'Bearer AdminToken',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
|
|
await super.teardown();
|
|
}
|
|
|
|
getVmContext() {
|
|
return super.getVmContext();
|
|
}
|
|
}
|
|
|
|
export default CustomEnvironment;
|