Skip to content

Commit

Permalink
focus on description after starting time tracker, ST-254
Browse files Browse the repository at this point in the history
  • Loading branch information
Onatcer committed Jun 18, 2024
1 parent 0c054bd commit 0121195
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 26 deletions.
43 changes: 24 additions & 19 deletions e2e/organization.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,50 @@ test('test that new manager can be invited', async ({ page }) => {
const editorId = Math.round(Math.random() * 10000);
await page.getByLabel('Email').fill(`new+${editorId}@editor.test`);
await page.getByRole('button', { name: 'Manager' }).click();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.reload();
await expect(page.getByRole('main')).toContainText(
`new+${editorId}@editor.test`
);
await Promise.all([
page.getByRole('button', { name: 'Add', exact: true }).click(),
expect(page.getByRole('main')).toContainText(
`new+${editorId}@editor.test`
),
]);
});

test('test that new employee can be invited', async ({ page }) => {
await goToOrganizationSettings(page);
const editorId = Math.round(Math.random() * 10000);
await page.getByLabel('Email').fill(`new+${editorId}@editor.test`);
await page.getByRole('button', { name: 'Employee' }).click();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.reload();
await expect(page.getByRole('main')).toContainText(
`new+${editorId}@editor.test`
);
await Promise.all([
page.getByRole('button', { name: 'Add', exact: true }).click(),
await expect(page.getByRole('main')).toContainText(
`new+${editorId}@editor.test`
),
]);
});

test('test that new admin can be invited', async ({ page }) => {
await goToOrganizationSettings(page);
const adminId = Math.round(Math.random() * 10000);
await page.getByLabel('Email').fill(`new+${adminId}@admin.test`);
await page.getByRole('button', { name: 'Administrator' }).click();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.reload();
await expect(page.getByRole('main')).toContainText(
`new+${adminId}@admin.test`
);
await Promise.all([
page.getByRole('button', { name: 'Add', exact: true }).click(),
expect(page.getByRole('main')).toContainText(
`new+${adminId}@admin.test`
),
]);
});
test('test that error shows if no role is selected', async ({ page }) => {
await goToOrganizationSettings(page);
const noRoleId = Math.round(Math.random() * 10000);

await page.getByLabel('Email').fill(`new+${noRoleId}@norole.test`);
await page.getByRole('button', { name: 'Add', exact: true }).click();
await expect(page.getByRole('main')).toContainText(
'The role field is required.'
);
await Promise.all([
page.getByRole('button', { name: 'Add', exact: true }).click(),
expect(page.getByRole('main')).toContainText(
'The role field is required.'
),
]);
});

// TODO: Add Test for import
6 changes: 5 additions & 1 deletion resources/js/Components/Common/DatePicker.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref } from 'vue';
import { ref, watch } from 'vue';
import { getDayJsInstance, getLocalizedDayJs } from '@/utils/time';
import { twMerge } from 'tailwind-merge';
Expand All @@ -14,6 +14,10 @@ const model = defineModel<string | null>({
const tempDate = ref(getLocalizedDayJs(model.value).format('YYYY-MM-DD'));
watch(model, (value) => {
tempDate.value = getLocalizedDayJs(value).format('YYYY-MM-DD');
});
function updateDate(event: Event) {
const target = event.target as HTMLInputElement;
const newValue = target.value;
Expand Down
4 changes: 2 additions & 2 deletions resources/js/Components/CurrentSidebarTimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TimeTrackerStartStop from '@/Components/Common/TimeTrackerStartStop.vue';
import { getCurrentOrganizationId } from '@/utils/useUser';
const store = useCurrentTimeEntryStore();
const { currentTimeEntry, now, isActive } = storeToRefs(store);
const { onToggleButtonPress } = store;
const { setActiveState } = store;

Check failure on line 11 in resources/js/Components/CurrentSidebarTimer.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 11 in resources/js/Components/CurrentSidebarTimer.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 11 in resources/js/Components/CurrentSidebarTimer.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 11 in resources/js/Components/CurrentSidebarTimer.vue

View workflow job for this annotation

GitHub Actions / phpunit

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 11 in resources/js/Components/CurrentSidebarTimer.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.
const currentTime = computed(() => {
if (now.value && currentTimeEntry.value.start) {
Expand Down Expand Up @@ -50,7 +50,7 @@ const isRunningInDifferentOrganization = computed(() => {
</div>
<TimeTrackerStartStop
:active="isActive"
@changed="onToggleButtonPress"
@changed="setActiveState"
size="base"></TimeTrackerStartStop>
</div>
</template>
16 changes: 12 additions & 4 deletions resources/js/Components/TimeTracker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BillableToggleButton from '@/Components/Common/BillableToggleButton.vue';
import TimeTrackerStartStop from '@/Components/Common/TimeTrackerStartStop.vue';
import { usePage } from '@inertiajs/vue3';
import { type User } from '@/types/models';
import { computed, onMounted, watch } from 'vue';
import { computed, onMounted, ref, watch } from 'vue';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import duration from 'dayjs/plugin/duration';
Expand All @@ -31,8 +31,8 @@ dayjs.extend(utc);
const currentTimeEntryStore = useCurrentTimeEntryStore();
const { currentTimeEntry, isActive, now } = storeToRefs(currentTimeEntryStore);
const { startLiveTimer, stopLiveTimer, onToggleButtonPress } =
currentTimeEntryStore;
const { startLiveTimer, stopLiveTimer, setActiveState } = currentTimeEntryStore;

Check failure on line 34 in resources/js/Components/TimeTracker.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 34 in resources/js/Components/TimeTracker.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 34 in resources/js/Components/TimeTracker.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 34 in resources/js/Components/TimeTracker.vue

View workflow job for this annotation

GitHub Actions / phpunit

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.

Check failure on line 34 in resources/js/Components/TimeTracker.vue

View workflow job for this annotation

GitHub Actions / build

Property 'setActiveState' does not exist on type '_StoreWithState<"currentTimeEntry", _UnwrapAll<Pick<{ currentTimeEntry: Ref<{ [x: string]: unknown; start: string; id: string; user_id: string; project_id: string | null; end: string | null; duration: number | null; description: string | null; task_id: string | null; organization_id: string; tags: string[]; billable...'.
const currentTimeEntryDescriptionInput = ref<HTMLInputElement | null>(null);
watch(isActive, () => {
if (isActive.value) {
Expand Down Expand Up @@ -71,9 +71,16 @@ function updateTimeEntry() {
}
}
function onToggleButtonPress(newState: boolean) {
setActiveState(newState);
if (newState) {
currentTimeEntryDescriptionInput.value?.focus();
}
}
function startTimerIfNotActive() {
if (!isActive.value) {
onToggleButtonPress(true);
setActiveState(true);
}
}
Expand Down Expand Up @@ -116,6 +123,7 @@ function switchToTimeEntryOrganization() {
<input
placeholder="What are you working on?"
data-testid="time_entry_description"
ref="currentTimeEntryDescriptionInput"
v-model="currentTimeEntry.description"
@keydown.enter="startTimerIfNotActive"
@blur="updateTimeEntry"
Expand Down

0 comments on commit 0121195

Please sign in to comment.