-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from zfir-dev/add-accep-test
Add acceptance test
- Loading branch information
Showing
5 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{{!-- app/components/open-modal-button.hbs --}} | ||
<button type="button" {{on "click" this.openModal}}>Open Modal</button> | ||
<button data-test-modal-btn="" type="button" {{on "click" this.openModal}}>Open Modal</button> | ||
{{#if this.isModalOpen}} | ||
<InputModal @closeModal={{this.closeModal}} /> | ||
{{/if}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { click, find, settled, visit, waitFor, waitUntil } from '@ember/test-helpers'; | ||
|
||
module('Acceptance | application | app', function (hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
test('I can fill form', async function (assert) { | ||
await visit('/'); | ||
await settled(); | ||
|
||
const h2 = find('h2') as HTMLElement; // get first h2 element | ||
assert.deepEqual(h2.textContent, 'Welcome to DevCon 2024 Ember.js Test Demo'); | ||
|
||
assert.dom('[data-test-modal-btn]').exists(); // assert open modal button exists | ||
|
||
const hasUserName = await waitUntil(() => { | ||
const div = find('.user-info') as HTMLDivElement; | ||
return div?.textContent?.includes('Welcome John'); | ||
}, { timeout: 3000 }); | ||
|
||
assert.strictEqual(hasUserName, true); // assert welcome user name exists | ||
|
||
await waitFor('.date', { timeout: 3000 }); | ||
assert.dom('[data-test-date]').containsText(new Date() as unknown as string); // assert date exists | ||
|
||
await click('[data-test-modal-btn]'); | ||
assert.dom('[data-test-modal]').exists(); // assert modal opens | ||
assert.dom('[data-test-close-btn]').exists(); // assert close button exists | ||
assert.dom('[data-test-save-btn]').exists(); // assert save button exists | ||
|
||
await click('[data-test-close-btn]'); | ||
assert.dom('[data-test-modal]').doesNotExist(); // assert modal is closed | ||
}); | ||
}); |