import { module, test } from 'qunit'; import { click, visit, currentURL } from '@ember/test-helpers'; import { setupApplicationTest } from 'ember-qunit'; module('Acceptance | einkaufszettel', function(hooks) { setupApplicationTest(hooks); test('visiting /einkaufszettel', async function(assert) { await visit('/'); assert.equal(currentURL(), '/'); assert.dom('nav').exists(); assert.dom('nav a.menu-index').hasText('EinkaufsZettel'); assert.dom('nav a.menu-zettel').hasText('Zettel'); assert.dom('nav a.menu-produkte').hasText('Produkte'); assert.dom('nav a.menu-rezepte').hasText('Rezepte'); }); test('navigating using the nav-bar', async function(assert) { await visit('/'); assert.dom('nav').exists(); assert.dom('nav a.menu-index').hasText('EinkaufsZettel'); assert.dom('nav a.menu-zettel').hasText('Zettel'); assert.dom('nav a.menu-produkte').hasText('Produkte'); assert.dom('nav a.menu-rezepte').hasText('Rezepte'); await click('nav a.menu-zettel'); assert.equal(currentURL(), '/zettel'); await click('nav a.menu-produkte'); assert.equal(currentURL(), '/produkte'); await click('nav a.menu-rezepte'); assert.equal(currentURL(), '/rezepte'); await click('nav a.menu-index'); assert.equal(currentURL(), '/'); }); test('visiting /zettel', async function(assert) { await visit('/zettel'); assert.dom('nav').exists(); assert.dom('nav a.menu-index').hasText('EinkaufsZettel'); assert.dom('nav a.menu-zettel').hasText('Zettel'); assert.dom('nav a.menu-produkte').hasText('Produkte'); assert.dom('nav a.menu-rezepte').hasText('Rezepte'); assert.dom('.jumbo h2').hasText('deine Zettel'); assert.dom('.jumbo a.button').hasText('Zettel aktualisieren'); await click('.jumbo a.button'); assert.equal(currentURL(), '/zettel'); }); test('visiting /produkte', async function(assert) { await visit('/produkte'); assert.dom('nav').exists(); assert.dom('nav a.menu-index').hasText('EinkaufsZettel'); assert.dom('nav a.menu-zettel').hasText('Zettel'); assert.dom('nav a.menu-produkte').hasText('Produkte'); assert.dom('nav a.menu-rezepte').hasText('Rezepte'); assert.dom('.jumbo h2').hasText('deine Produkte'); assert.dom('.jumbo a.button').hasText('Produkt hinzufügen'); await click('.jumbo a.button'); assert.equal(currentURL(), '/neues-produkt'); }); test('visiting /rezepte', async function(assert) { await visit('/rezepte'); assert.dom('nav').exists(); assert.dom('nav a.menu-index').hasText('EinkaufsZettel') assert.dom('nav a.menu-zettel').hasText('Zettel'); assert.dom('nav a.menu-produkte').hasText('Produkte'); assert.dom('nav a.menu-rezepte').hasText('Rezepte'); assert.dom('.jumbo h2').hasText('deine Rezepte'); assert.dom('.jumbo a.button').hasText('Rezepte bearbeiten'); await click('.jumbo a.button'); assert.equal(currentURL(), '/rezepte'); }); });