|
| 1 | +import { click, currentURL, visit } from '@ember/test-helpers'; |
| 2 | +import { module, test } from 'qunit'; |
| 3 | + |
| 4 | +import { setupApplicationTest } from 'cargo/tests/helpers'; |
| 5 | + |
| 6 | +const TAB_README = '[data-test-readme-tab] a'; |
| 7 | +const TAB_VERSIONS = '[data-test-versions-tab] a'; |
| 8 | +const TAB_REV_DEPS = '[data-test-rev-deps-tab] a'; |
| 9 | +const TAB_SETTINGS = '[data-test-settings-tab] a'; |
| 10 | + |
| 11 | +module('Acceptance | crate navigation tabs', function (hooks) { |
| 12 | + setupApplicationTest(hooks); |
| 13 | + |
| 14 | + test('basic navigation between tabs works as expected', async function (assert) { |
| 15 | + this.server.create('crate', { name: 'nanomsg' }); |
| 16 | + this.server.create('version', { crateId: 'nanomsg', num: '0.6.1' }); |
| 17 | + |
| 18 | + await visit('/crates/nanomsg'); |
| 19 | + assert.equal(currentURL(), '/crates/nanomsg'); |
| 20 | + |
| 21 | + assert.dom(TAB_README).hasAttribute('href', '/crates/nanomsg').hasAttribute('data-test-active'); |
| 22 | + assert.dom(TAB_VERSIONS).hasAttribute('href', '/crates/nanomsg/versions').hasNoAttribute('data-test-active'); |
| 23 | + assert |
| 24 | + .dom(TAB_REV_DEPS) |
| 25 | + .hasAttribute('href', '/crates/nanomsg/reverse_dependencies') |
| 26 | + .hasNoAttribute('data-test-active'); |
| 27 | + assert.dom(TAB_SETTINGS).doesNotExist(); |
| 28 | + |
| 29 | + await click(TAB_VERSIONS); |
| 30 | + assert.equal(currentURL(), '/crates/nanomsg/versions'); |
| 31 | + |
| 32 | + assert.dom(TAB_README).hasAttribute('href', '/crates/nanomsg').hasNoAttribute('data-test-active'); |
| 33 | + assert.dom(TAB_VERSIONS).hasAttribute('href', '/crates/nanomsg/versions').hasAttribute('data-test-active'); |
| 34 | + assert |
| 35 | + .dom(TAB_REV_DEPS) |
| 36 | + .hasAttribute('href', '/crates/nanomsg/reverse_dependencies') |
| 37 | + .hasNoAttribute('data-test-active'); |
| 38 | + assert.dom(TAB_SETTINGS).doesNotExist(); |
| 39 | + |
| 40 | + await click(TAB_REV_DEPS); |
| 41 | + assert.equal(currentURL(), '/crates/nanomsg/reverse_dependencies'); |
| 42 | + |
| 43 | + assert.dom(TAB_README).hasAttribute('href', '/crates/nanomsg').hasNoAttribute('data-test-active'); |
| 44 | + assert.dom(TAB_VERSIONS).hasAttribute('href', '/crates/nanomsg/versions').hasNoAttribute('data-test-active'); |
| 45 | + assert |
| 46 | + .dom(TAB_REV_DEPS) |
| 47 | + .hasAttribute('href', '/crates/nanomsg/reverse_dependencies') |
| 48 | + .hasAttribute('data-test-active'); |
| 49 | + assert.dom(TAB_SETTINGS).doesNotExist(); |
| 50 | + }); |
| 51 | +}); |
0 commit comments