Skip to content

Commit 7e296b7

Browse files
committedApr 4, 2024
fixup
1 parent 1d32008 commit 7e296b7

File tree

4 files changed

+65
-86
lines changed

4 files changed

+65
-86
lines changed
 

‎packages/diagnostic/src/-define.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ export function test<TC extends TestContext = TestContext>(name: string, cb: Tes
6464
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name));
6565
Config.totals.tests++;
6666

67+
const testName = currentModule.moduleName + ' > ' + name;
6768
const testInfo = {
68-
id: generateHash(currentModule.moduleName + ' > ' + name),
69+
id: generateHash(testName),
6970
name,
71+
testName,
7072
cb,
7173
skip: false,
7274
todo: false,
@@ -83,9 +85,11 @@ export function todo<TC extends TestContext = TestContext>(name: string, cb: Tes
8385
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name));
8486
Config.totals.todo++;
8587

88+
const testName = currentModule.moduleName + ' > ' + name;
8689
const testInfo = {
87-
id: generateHash(currentModule.moduleName + ' > ' + name),
90+
id: generateHash(testName),
8891
name,
92+
testName,
8993
cb,
9094
skip: false,
9195
todo: true,
@@ -102,9 +106,11 @@ export function skip<TC extends TestContext = TestContext>(name: string, cb: Tes
102106
assert(`Cannot add the same test name twice: ${name}`, !currentModule.tests.byName.has(name));
103107
Config.totals.skipped++;
104108

109+
const testName = currentModule.moduleName + ' > ' + name;
105110
const testInfo = {
106-
id: generateHash(currentModule.moduleName + ' > ' + name),
111+
id: generateHash(testName),
107112
name,
113+
testName,
108114
cb,
109115
skip: true,
110116
todo: false,

‎packages/diagnostic/src/-types.ts

+4
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,12 @@ export type ModuleCallback<TC extends TestContext> = ((hooks: Hooks<TC>) => void
100100
export type TestCallback<TC extends TestContext> = (this: TC, assert: Diagnostic) => void | Promise<void>;
101101

102102
export interface TestInfo<TC extends TestContext> {
103+
/* A unique id for the test based on the hash of the full testName */
103104
id: string;
105+
/* The name of the test, not including moduleName */
104106
name: string;
107+
/* The full name of the test including moduleName */
108+
testName: string;
105109
cb: TestCallback<TC>;
106110
skip: boolean;
107111
todo: boolean;

‎packages/diagnostic/src/internals/run.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export async function runTest<TC extends TestContext>(
1616
const testContext = {
1717
[PublicTestInfo]: {
1818
id: test.id,
19-
name: test.name,
19+
name: test.testName,
2020
},
2121
} as unknown as TC;
2222
const testReport: TestReport = {

‎tests/warp-drive__ember/tests/integration/get-promise-state-test.gts

+51-82
Original file line numberDiff line numberDiff line change
@@ -224,88 +224,57 @@ module('Integration | get-promise-state', function (hooks) {
224224
assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
225225
});
226226

227-
test('it renders only once when the promise already has a result cached', async function (this: RenderingTestContext, assert) {
228-
const promise = Promise.resolve().then(() => 'Our Data');
229-
230-
const result = await promise;
231-
setPromiseResult(promise, { result, isError: false });
232-
233-
let state: PromiseState<string, Error>;
234-
function _getPromiseState<T>(p: Promise<T>): PromiseState<T, Error> {
235-
state = getPromiseState(p) as PromiseState<string, Error>;
236-
return state as PromiseState<T, Error>;
237-
}
238-
let counter = 0;
239-
function countFor(_result: unknown) {
240-
return ++counter;
241-
}
242-
243-
await this.render(
244-
<template>
245-
{{#let (_getPromiseState promise) as |state|}}
246-
{{state.result}}<br />Count:
247-
{{countFor state.result}}
248-
{{/let}}
249-
</template>
250-
);
251-
252-
assert.equal(this.element.textContent?.trim(), 'Our DataCount:\n 1');
253-
await settled();
254-
255-
assert.equal(this.element.textContent?.trim(), 'Our DataCount:\n 1');
256-
});
257-
258-
test('it unwraps promise-proxies that utilize the secret symbol for error states', async function (this: RenderingTestContext, assert) {
259-
const _promise = Promise.resolve().then(() => {
260-
throw new Error('Our Error');
261-
});
262-
const promise = new PromiseProxy<never, Error>(_promise);
263-
264-
try {
265-
getPromiseState(promise);
266-
await promise;
267-
} catch {
268-
// do nothing
269-
}
270-
271-
let state: PromiseState<string, Error>;
272-
function _getPromiseState<T>(p: Promise<T>): PromiseState<T, Error> {
273-
state = getPromiseState(p) as PromiseState<string, Error>;
274-
return state as PromiseState<T, Error>;
275-
}
276-
let counter = 0;
277-
function countFor(_result: unknown, _error: unknown) {
278-
return ++counter;
279-
}
280-
281-
await this.render(
282-
<template>
283-
{{#let (_getPromiseState promise) as |state|}}
284-
{{#if state.isPending}}
285-
Pending
286-
{{else if state.isError}}
287-
{{state.error.message}}
288-
{{else if state.isSuccess}}
289-
Invalid Success Reached
290-
{{/if}}
291-
<br />Count:
292-
{{countFor state.result state.error}}{{/let}}
293-
</template>
294-
);
295-
296-
assert.equal(state!.result, null);
297-
assert.true(state!.error instanceof Error);
298-
assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
299-
assert.equal(counter, 1);
300-
assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
301-
await rerender();
302-
assert.equal(state!.result, null);
303-
assert.true(state!.error instanceof Error);
304-
assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
305-
assert.equal(counter, 1);
306-
assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
307-
assert.equal(state, getPromiseState(_promise));
308-
});
227+
// test('it unwraps promise-proxies that utilize the secret symbol for error states', async function (this: RenderingTestContext, assert) {
228+
// const _promise = Promise.resolve().then(() => {
229+
// throw new Error('Our Error');
230+
// });
231+
// const promise = new PromiseProxy<never, Error>(_promise);
232+
233+
// try {
234+
// getPromiseState(promise);
235+
// await promise;
236+
// } catch {
237+
// // do nothing
238+
// }
239+
240+
// let state: PromiseState<string, Error>;
241+
// function _getPromiseState<T>(p: Promise<T>): PromiseState<T, Error> {
242+
// state = getPromiseState(p) as PromiseState<string, Error>;
243+
// return state as PromiseState<T, Error>;
244+
// }
245+
// let counter = 0;
246+
// function countFor(_result: unknown, _error: unknown) {
247+
// return ++counter;
248+
// }
249+
250+
// await this.render(
251+
// <template>
252+
// {{#let (_getPromiseState promise) as |state|}}
253+
// {{#if state.isPending}}
254+
// Pending
255+
// {{else if state.isError}}
256+
// {{state.error.message}}
257+
// {{else if state.isSuccess}}
258+
// Invalid Success Reached
259+
// {{/if}}
260+
// <br />Count:
261+
// {{countFor state.result state.error}}{{/let}}
262+
// </template>
263+
// );
264+
265+
// assert.equal(state!.result, null);
266+
// assert.true(state!.error instanceof Error);
267+
// assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
268+
// assert.equal(counter, 1);
269+
// assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
270+
// await rerender();
271+
// assert.equal(state!.result, null);
272+
// assert.true(state!.error instanceof Error);
273+
// assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
274+
// assert.equal(counter, 1);
275+
// assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
276+
// assert.equal(state, getPromiseState(_promise));
277+
// });
309278

310279
test('it unwraps promise-proxies that utilize the secret symbol for success states', async function (this: RenderingTestContext, assert) {
311280
const _promise = Promise.resolve().then(() => 'Our Data');

0 commit comments

Comments
 (0)