Skip to content

Commit

Permalink
chore: make tests more splittable (#9638)
Browse files Browse the repository at this point in the history
* chore: make tests more splittable

* enable splitting by putting modules into separate files
  • Loading branch information
runspired authored Jan 30, 2025
1 parent 61c0d8b commit 1be6d58
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 9);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 10);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 11);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 12);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 13);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 14);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 15);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 16);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 17);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 18);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 19);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 2);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 3);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 4);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 5);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 6);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 7);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { runTestGroup } from './mutating-has-many-test-infra';

runTestGroup(20, 8);
Original file line number Diff line number Diff line change
Expand Up @@ -395,34 +395,52 @@ function getMutations(): Mutation[] {
];
}

module('Integration | Relationships | Collection | Mutation', function (hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function () {
this.owner.register('model:user', User);
const STATES: Array<{
startingState: { name: string; cb: (store: Store) => User };
mutation: Mutation;
}> = [];

getStartingState().forEach((startingState) => {
getMutations().forEach((mutation) => {
STATES.push({
startingState,
mutation,
});
});
});

export function runTestGroup(splitNum: number, offset: number) {
STATES.forEach(({ startingState, mutation }, index) => {
// Run only every Nth test, offset by 0
if (index % splitNum !== offset) {
return;
}

module(
`Integration | Relationships | Collection | Mutation > Starting state: ${startingState.name} > Mutation: ${mutation.name}`,
function (hooks) {
setupRenderingTest(hooks);

hooks.beforeEach(function () {
this.owner.register('model:user', User);
});

getStartingState().forEach((startingState) => {
module(`Starting state: ${startingState.name}`, function () {
getMutations().forEach((mutation) => {
module(`Mutation: ${mutation.name}`, function () {
getMutations().forEach((mutation2) => {
test(`followed by Mutation: ${mutation2.name}`, async function (assert) {
const store = this.owner.lookup('service:store') as Store;
const user = startingState.cb(store);
const rc = await reactiveContext.call(this, user, {
identity: null,
type: 'user',
fields: [{ name: 'friends', kind: 'hasMany', type: 'user', options: { async: false, inverse: null } }],
});
rc.reset();

await applyMutation(assert, store, user, mutation, rc);
await applyMutation(assert, store, user, mutation2, rc);
getMutations().forEach((mutation2) => {
test(`followed by Mutation: ${mutation2.name}`, async function (assert) {
const store = this.owner.lookup('service:store') as Store;
const user = startingState.cb(store);
const rc = await reactiveContext.call(this, user, {
identity: null,
type: 'user',
fields: [{ name: 'friends', kind: 'hasMany', type: 'user', options: { async: false, inverse: null } }],
});
rc.reset();

await applyMutation(assert, store, user, mutation, rc);
await applyMutation(assert, store, user, mutation2, rc);
});
});
});
});
}
);
});
});
}

0 comments on commit 1be6d58

Please sign in to comment.