Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Service cannot be used before helper failing test #1086

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion test-app/tests/integration/helpers/file-queue-helper-test.gts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { render, click, settled, waitFor } from '@ember/test-helpers';
import { DEFAULT_QUEUE, FileState } from 'ember-file-upload';
import type { UploadFile } from 'ember-file-upload';
import { selectFiles } from 'ember-file-upload/test-support';
import { uploadHandler } from 'ember-file-upload';
import { type FileQueueService, uploadHandler } from 'ember-file-upload';
import { later } from '@ember/runloop';
import fileQueue from 'ember-file-upload/helpers/file-queue';
import { on } from '@ember/modifier';
Expand All @@ -20,6 +20,31 @@ module('Integration | Helper | file-queue', function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);

test('service can be used before helper', async function (assert) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until some code fixing the addon is pushed, this test will fail. And that is ok as this PR is only intended to show the bug. I don't think I will have time anytime soon to fix the code itself, so very happy if someone can take-over and finish this.

const fileQueueService = this.owner.lookup(
'service:file-queue',
) as FileQueueService;

await render(
<template>
<ul>
{{#each fileQueueService.files as |file|}}
<li>
{{file.name}}
</li>
{{/each}}
</ul>

{{#let (fileQueue) as |queue|}}
<label>
<input type='file' {{queue.selectFile}} hidden />
Select File
</label>
{{/let}}
</template>,
);
});

test('filter is triggered when selecting files', async function (assert) {
const filter = (file: File) => {
assert.step(`filter: ${file.name}`);
Expand Down
Loading