Skip to content

Commit

Permalink
chore: try to fix this f******* test
Browse files Browse the repository at this point in the history
  • Loading branch information
romgere committed May 31, 2024
1 parent 3832366 commit 6079042
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions tests/integration/components/settings-form/handle-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,113 @@ import waitCalciteReady from 'text2stl/tests/helpers/wait-calcite-ready';
module('Integration | Component | advanced-settings-form/handle', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
const model = new TextMakerSettings({
...textMakerDefault,
type: ModelType.TextWithSupport,
});
this.set('model', model);

await render(hbs`<SettingsForm::Handle @model={{this.model}} />`);

assert.dom('[data-test-handle-type-item]').exists('it render handle type radio group');

assert
.dom('[data-test-handle-settings]')
.doesNotExist('it does not render handle settings when handle-type is "none"');

await click('[data-test-handle-type-item] [data-test-value="hole"]');
await waitUntil(() => model.handleSettings.type === 'hole', { timeout: 5000 });
await waitCalciteReady();
await waitFor('[data-test-handle-position]', { timeout: 5000 });
assert.dom('[data-test-handle-position]').exists('it show handle-position input');
assert.dom('[data-test-settings-handle-size]').exists('it show handle-size input');
assert.dom('[data-test-settings-handle-offsetX]').exists('it show handle-offsetX input');
assert.dom('[data-test-settings-handle-offsetY]').exists('it show handle-offsetY input');
assert.strictEqual(model.handleSettings.type, 'hole', 'handle type was updated');

assert
.dom('[data-test-settings-handle-size2]')
.doesNotExist('it does not render handle size 2 when handle type is "hole"');

await click('[data-test-handle-type-item] [data-test-value="handle"]');
assert.strictEqual(model.handleSettings.type, 'handle', 'handle type was updated');
assert.dom('[data-test-handle-position]').exists('it show handle-position input');
assert.dom('[data-test-settings-handle-size]').exists('it show handle-size input');
assert.dom('[data-test-settings-handle-offsetX]').exists('it show handle-offsetX input');
assert
.dom('[data-test-settings-handle-offsetY]')
.doesNotExist('it does not show handle-offsetY input');
assert
.dom('[data-test-settings-handle-size2]')
.exists('it renders handle size 2 when handle type is "handle"');

assert
.dom(`[data-test-handle-position] [data-test-value="${model.handleSettings.position}"]`)
.isChecked('It checks correct handle position value');

assert
.dom('[data-test-settings-handle-size]')
.hasValue(`${model.handleSettings.size}`, 'It render correct handle size value');
await fillCalciteInput('[data-test-settings-handle-size]', '123');
assert.strictEqual(model.handleSettings.size, 123, 'handle size was updated');

assert
.dom('[data-test-settings-handle-size2]')
.hasValue(`${model.handleSettings.size2}`, 'It render correct handle size2 value');
await fillCalciteInput('[data-test-settings-handle-size2]', '321');
assert.strictEqual(model.handleSettings.size2, 321, 'handle size2 was updated');

assert
.dom('[data-test-settings-handle-offsetX]')
.hasValue(`${model.handleSettings.offsetX}`, 'It render correct handle offsetX value');
await fillCalciteInput('[data-test-settings-handle-offsetX]', '456');
assert.strictEqual(model.handleSettings.offsetX, 456, 'handle offsetX was updated');

await click('[data-test-handle-position] [data-test-value="bottom"]');
assert.strictEqual(model.handleSettings.position, 'bottom', 'handle position was updated');
assert.strictEqual(
model.handleSettings.offsetX,
textMakerDefault.handleSettings.offsetX,
'handle offsetX was reset to a default value',
);
assert.strictEqual(
model.handleSettings.offsetY,
textMakerDefault.handleSettings.offsetY,
'handle offsetY was reset to a default value',
);

await click('[data-test-handle-type-item] [data-test-value="hole"]');
assert.strictEqual(
model.handleSettings.position,
'top',
'handle position was reset to a default value',
);
assert.strictEqual(
model.handleSettings.offsetX,
textMakerDefault.handleSettings.offsetX,
'handle offsetX was reset to a default value',
);
assert.strictEqual(
model.handleSettings.offsetY,
textMakerDefault.handleSettings.offsetY,
'handle offsetY was reset to a default value',
);

await click('[data-test-handle-position] [data-test-value="left"]');
assert.strictEqual(model.handleSettings.position, 'left', 'handle position was updated');
assert.strictEqual(
model.handleSettings.offsetX,
textMakerDefault.handleSettings.offsetX,
'handle offsetX was reset to a default value',
);
assert.strictEqual(
model.handleSettings.offsetY,
textMakerDefault.handleSettings.offsetY,
'handle offsetY was reset to a default value',
);
});

test('it renders', async function (assert) {
const model = new TextMakerSettings({
...textMakerDefault,
Expand Down

0 comments on commit 6079042

Please sign in to comment.