Skip to content

Remove the collapse functionality #885

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

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions app/components/table-of-contents.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ul class='table-of-contents '>
<li class='toc-item toc-group'>
<a {{on 'click' (fn this.toggle 'modules')}} href='#' data-test-toc-title='packages'>Packages</a>
<ul class='sub-table-of-contents modules selected'>
<li class='toc-item toc-group' data-test-toc-title="packages">
Packages
<ul class='sub-table-of-contents modules'>
{{#each @moduleIDs as |moduleID|}}

{{#if (not-eq moduleID '@ember/object/computed')}}
Expand All @@ -15,9 +15,9 @@
</li>

{{#if @isShowingNamespaces}}
<li class='table-of-contents'>
<a {{on 'click' (fn this.toggle 'namespaces')}} href='#' data-test-toc-title='namespaces'>Namespaces</a>
<ul class='sub-table-of-contents namespaces selected'>
<li class='table-of-contents' data-test-toc-title="namespaces">
Namespaces
<ul class='sub-table-of-contents namespaces'>
{{#each @namespaceIDs as |namespaceID|}}
<li class='toc-item toc-link' data-test-namespace={{namespaceID}}>
<LinkTo @route='project-version.namespaces.namespace' @models={{array @version namespaceID}}>{{namespaceID}}</LinkTo>
Expand All @@ -27,9 +27,9 @@
</li>
{{/if}}

<li class='table-of-contents '>
<a {{on 'click' (fn this.toggle 'classes')}} href='#' data-test-toc-title='classes'>Classes</a>
<ul class='sub-table-of-contents classes selected'>
<li class='table-of-contents' data-test-toc-title="classes">
Classes
<ul class='sub-table-of-contents classes'>
{{#each @classesIDs as |classID|}}
<li class='toc-item toc-link' data-test-class={{classID}}>
<LinkTo @route='project-version.classes.class' @models={{array @version classID}}>{{classID}}</LinkTo>
Expand Down
12 changes: 0 additions & 12 deletions app/components/table-of-contents.js

This file was deleted.

4 changes: 2 additions & 2 deletions app/components/table-of-projects.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ul class="table-of-contents ">
<ul class="table-of-contents">
<li class="toc-item" data-test-home>
<LinkTo @route="project" @model="ember">Home</LinkTo>
</li>
<li class="toc-heading">Projects</li>
<li>Projects</li>
<ul class="sub-table-of-contents">
<li class="toc-item"><LinkTo @route="project" @model="ember" @current-when={{eq @activeProject "ember"}} class="spec-ember">Ember</LinkTo></li>
<li class="toc-item"><LinkTo @route="project" @model="ember-data" @current-when={{eq @activeProject "ember-data"}} class="spec-ember-data">EmberData</LinkTo></li>
Expand Down
1 change: 1 addition & 0 deletions app/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ main a.edit-icon {
.table-of-contents li {
margin: 3px 0;
list-style-type: none;
color: var(--color-gray-600);
}

li.toc-heading {
Expand Down
96 changes: 7 additions & 89 deletions tests/integration/components/table-of-contents-test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { module, test, skip } from 'qunit';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render, findAll, click } from '@ember/test-helpers';
import { render, findAll } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';

const TIMEOUT_FOR_ANIMATION = 600;
const CLASSES = ['Descriptor', 'Ember'];
const MODULES = ['@ember/application', '@ember/array'];

module('Integration | Component | table of contents', function (hooks) {
setupRenderingTest(hooks);

test('it renders', async function (assert) {
test('it renders classes', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
this.set('emberVersion', '2.4.3');
this.set('classesIDs', CLASSES);
Expand All @@ -29,15 +28,15 @@ module('Integration | Component | table of contents', function (hooks) {
);
const contentReference = '.sub-table-of-contents';

assert.dom(contentTitle).hasText('Classes');
assert.dom(contentTitle).includesText('Classes');
assert
.dom(`${contentReference} li`)
.exists({ count: 2 }, 'We have two items to display');
assert.dom(findAll(`${contentReference} li`)[0]).hasText(CLASSES[0]);
assert.dom(findAll(`${contentReference} li`)[1]).hasText(CLASSES[1]);
});

test('Starts with underlying content visible', async function (assert) {
test('it renders packages', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
this.set('emberVersion', '2.4.3');
this.set('moduleIDs', MODULES);
Expand All @@ -54,96 +53,15 @@ module('Integration | Component | table of contents', function (hooks) {
const contentReference = '.sub-table-of-contents';
const content = document.querySelector(contentReference);
const contentTitle = document.querySelector(
'[data-test-toc-title="classes"]'
'[data-test-toc-title="packages"]'
);

assert.dom(contentTitle).hasText('Classes');
assert.dom(content).hasClass('selected');
assert.dom(contentTitle).includesText('Packages');
assert
.dom(`${contentReference} li`)
.exists({ count: 2 }, 'We have two items to display');
assert.dom(content).isVisible();
assert.dom(findAll(`${contentReference} li`)[0]).hasText(MODULES[0]);
assert.dom(findAll(`${contentReference} li`)[1]).hasText(MODULES[1]);
});

skip('Underlying content hides once clicked', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
this.set('emberVersion', '2.4.3');
this.set('moduleIDs', MODULES);

await render(hbs`
<TableOfContents
@showPrivateClasses={{true}}
@version={{this.emberVersion}}
@moduleIDs={{this.moduleIDs}}
@isShowingNamespaces={{true}}
/>
`);

const contentTitle = document.querySelector(
'[data-test-toc-title="packages"]'
);
const contentReference = '.sub-table-of-content';
const content = document.querySelector(contentReference);

assert.dom(contentTitle).hasText('Packages');
assert.dom(content).hasClass('selected');
assert.dom(content).isVisible();

await click(contentTitle);

const done = assert.async();
setTimeout(() => {
assert.dom(content).isNotVisible();
assert.dom(content).doesNotHaveClass('selected');
done();
}, TIMEOUT_FOR_ANIMATION);
});

skip('Underlying content should be visible after 2 clicks', async function (assert) {
// Set any properties with this.set('myProperty', 'value');
this.set('emberVersion', '2.4.3');
this.set('moduleIDs', MODULES);

await render(hbs`
<TableOfContents
@showPrivateClasses={{true}}
@version={{this.emberVersion}}
@moduleIDs={{this.moduleIDs}}
@isShowingNamespaces={{true}}
/>
`);

const titleButton = document.querySelector(
'[data-test-toc-title="packages"]'
);
const contentReference = '.sub-table-of-contents';
const content = document.querySelector(contentReference);

assert.dom(titleButton).hasText('Packages');
assert.dom(content).hasClass('selected');
assert.dom(content).isVisible();

await click(titleButton);

const done1 = assert.async();

setTimeout(async () => {
assert.dom(content).isNotVisible();
assert.dom(content).doesNotHaveClass('selected');

await click(titleButton);

const done2 = assert.async();

setTimeout(() => {
assert.dom(content).isVisible();
assert.dom(content).hasClass('selected');
done2();
}, TIMEOUT_FOR_ANIMATION);

done1();
}, TIMEOUT_FOR_ANIMATION);
});
});