Skip to content

Commit

Permalink
fix(frontend): hide task form after creating new project task
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Jun 5, 2024
1 parent b112ae4 commit d7195aa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/app/projects/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class ProjectsController extends Controller {
}

this.fetchTasksByProject.perform(this.selectedProject);
this.selectedTask = undefined;
}

@dropTask
Expand Down
35 changes: 30 additions & 5 deletions frontend/tests/acceptance/project-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ module("Acceptance | projects", function (hooks) {
assert.dom("[data-test-task-form]").exists();
assert.dom("[data-test-save]").isDisabled();

assert.dom("[data-test-name]").exists();
assert.dom("[data-test-name]").isVisible();
await fillIn("[data-test-name]", "FooBar Task 1");
assert.dom("[data-test-save]").isNotDisabled();

Expand All @@ -80,9 +82,6 @@ module("Acceptance | projects", function (hooks) {

await click("[data-test-save]");

assert.dom("[data-test-name]").hasValue("FooBar Task 1");
assert.dom("[data-test-reference]").hasValue("Reference of FooBar Task 1");
assert.dom("[data-test-estimated-time]").hasValue("02:15");
assert.dom("[data-test-task-table-row]").exists({ count: 1 });
});

Expand Down Expand Up @@ -116,7 +115,6 @@ module("Acceptance | projects", function (hooks) {
await fillIn("[data-test-estimated-time]", "02:15");

await click("[data-test-save]");
await click("[data-test-cancel]");

assert.dom("[data-test-task-form]").doesNotExist();
assert.dom("[data-test-table-name]").hasText("FooBar Task 1");
Expand All @@ -135,7 +133,6 @@ module("Acceptance | projects", function (hooks) {
await click("[data-test-archived] input");

await click("[data-test-save]");
await click("[data-test-cancel]");

assert.dom("[data-test-task-form]").doesNotExist();
assert.dom("[data-test-table-name]").hasText("FooBar Task 1 updated");
Expand All @@ -144,6 +141,34 @@ module("Acceptance | projects", function (hooks) {
assert.dom("[data-test-table-archived]").hasClass("fa-square-check");
});

test("The cancel button will hide the form", async function (assert) {
await visit("/projects");
assert.strictEqual(currentURL(), "/projects");

await selectChoose(
"[data-test-customer-selection]",
".ember-power-select-option",
0
);

await selectChoose(
"[data-test-project-selection]",
".ember-power-select-option",
0
);

assert.dom("[data-test-add-task]").exists();
assert.dom("[data-test-task-table-row]").doesNotExist();

await click("[data-test-add-task]");
assert.dom("[data-test-task-form]").exists();
assert.dom("[data-test-save]").isDisabled();

await click("[data-test-cancel]");

assert.dom("[data-test-task-form]").doesNotExist();
});

test("shows all customers to superuser", async function (assert) {
const user = this.server.create("user", { isSuperuser: true });
this.server.create("project");
Expand Down

0 comments on commit d7195aa

Please sign in to comment.