Refactor logging and clean up unused console statements across multiple files
This commit is contained in:
parent
d6c7fde40c
commit
397cf28673
@ -34,7 +34,7 @@ test.beforeAll(async ({ browser }) => {
|
|||||||
await page.locator('form button[type="submit"]:has-text("Login")').click();
|
await page.locator('form button[type="submit"]:has-text("Login")').click();
|
||||||
await page.waitForURL(new RegExp(`${BASE_URL}/(chores|groups|dashboard)?/?$`));
|
await page.waitForURL(new RegExp(`${BASE_URL}/(chores|groups|dashboard)?/?$`));
|
||||||
await page.context().storageState({ path: `e2e/.auth/list-user-${process.env.PLAYWRIGHT_WORKER_INDEX || 0}.json` });
|
await page.context().storageState({ path: `e2e/.auth/list-user-${process.env.PLAYWRIGHT_WORKER_INDEX || 0}.json` });
|
||||||
|
|
||||||
// After login, ensure the target group exists or create it.
|
// After login, ensure the target group exists or create it.
|
||||||
// For simplicity, we'll assume groups.spec.ts created a group.
|
// For simplicity, we'll assume groups.spec.ts created a group.
|
||||||
// We need its name. A robust way is to query the API or have a fixed test group.
|
// We need its name. A robust way is to query the API or have a fixed test group.
|
||||||
@ -46,15 +46,14 @@ test.beforeAll(async ({ browser }) => {
|
|||||||
await page.goto(`${BASE_URL}/groups`);
|
await page.goto(`${BASE_URL}/groups`);
|
||||||
const firstGroupCard = page.locator('.neo-group-card h1.neo-group-header').first();
|
const firstGroupCard = page.locator('.neo-group-card h1.neo-group-header').first();
|
||||||
if (await firstGroupCard.isVisible()) {
|
if (await firstGroupCard.isVisible()) {
|
||||||
const name = await firstGroupCard.textContent();
|
const name = await firstGroupCard.textContent();
|
||||||
if (name) groupNameForListTests = name.trim();
|
if (name) groupNameForListTests = name.trim();
|
||||||
else console.warn("Could not determine group name for list tests, using default or generated.");
|
else console.warn("Could not determine group name for list tests, using default or generated.");
|
||||||
} else {
|
} else {
|
||||||
console.warn("No groups found for list tests, creating a new one might be needed or tests will fail.");
|
console.warn("No groups found for list tests, creating a new one might be needed or tests will fail.");
|
||||||
// If no groups, these tests might not be able to proceed correctly.
|
// If no groups, these tests might not be able to proceed correctly.
|
||||||
// For now, we'll assume `groupNameForListTests` is somewhat valid or will be set.
|
// For now, we'll assume `groupNameForListTests` is somewhat valid or will be set.
|
||||||
}
|
}
|
||||||
console.log(`Using group: "${groupNameForListTests}" for list tests.`);
|
|
||||||
await page.close();
|
await page.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -124,7 +123,7 @@ test('2. View a List and its (empty) items', async ({ page }) => {
|
|||||||
const groupCard = page.locator(`.neo-group-card:has-text("${groupNameForListTests}")`);
|
const groupCard = page.locator(`.neo-group-card:has-text("${groupNameForListTests}")`);
|
||||||
await groupCard.click();
|
await groupCard.click();
|
||||||
await page.waitForURL(new RegExp(`${BASE_URL}/groups/\\d+`));
|
await page.waitForURL(new RegExp(`${BASE_URL}/groups/\\d+`));
|
||||||
|
|
||||||
const listLink = page.locator(`.list-card-link:has-text("${createdListName}"), .list-group-item:has-text("${createdListName}")`).first();
|
const listLink = page.locator(`.list-card-link:has-text("${createdListName}"), .list-group-item:has-text("${createdListName}")`).first();
|
||||||
await listLink.click();
|
await listLink.click();
|
||||||
await page.waitForURL(new RegExp(`${BASE_URL}/groups/\\d+/lists/${createdListId}`));
|
await page.waitForURL(new RegExp(`${BASE_URL}/groups/\\d+/lists/${createdListId}`));
|
||||||
@ -168,7 +167,7 @@ test('3. Add an Item to a List', async ({ page }) => {
|
|||||||
test('4. Mark an Item as Completed', async ({ page }) => {
|
test('4. Mark an Item as Completed', async ({ page }) => {
|
||||||
expect(createdListId).toBeTruthy();
|
expect(createdListId).toBeTruthy();
|
||||||
expect(createdListName).toBeTruthy();
|
expect(createdListName).toBeTruthy();
|
||||||
|
|
||||||
// Navigate to the list detail page
|
// Navigate to the list detail page
|
||||||
await page.goto(`${BASE_URL}/groups`);
|
await page.goto(`${BASE_URL}/groups`);
|
||||||
await page.locator(`.neo-group-card:has-text("${groupNameForListTests}")`).click();
|
await page.locator(`.neo-group-card:has-text("${groupNameForListTests}")`).click();
|
||||||
@ -180,7 +179,7 @@ test('4. Mark an Item as Completed', async ({ page }) => {
|
|||||||
const firstItem = page.locator('.neo-item').first();
|
const firstItem = page.locator('.neo-item').first();
|
||||||
const itemNameElement = firstItem.locator('.neo-item-name');
|
const itemNameElement = firstItem.locator('.neo-item-name');
|
||||||
const itemName = await itemNameElement.textContent(); // Get name for confirmation dialog
|
const itemName = await itemNameElement.textContent(); // Get name for confirmation dialog
|
||||||
|
|
||||||
const checkbox = firstItem.locator('input[type="checkbox"]');
|
const checkbox = firstItem.locator('input[type="checkbox"]');
|
||||||
await checkbox.check(); // This will trigger @change which calls confirmUpdateItem
|
await checkbox.check(); // This will trigger @change which calls confirmUpdateItem
|
||||||
|
|
||||||
@ -188,7 +187,7 @@ test('4. Mark an Item as Completed', async ({ page }) => {
|
|||||||
await expect(page.locator('.modal-container.confirm-modal')).toBeVisible();
|
await expect(page.locator('.modal-container.confirm-modal')).toBeVisible();
|
||||||
await expect(page.locator('.modal-body')).toContainText(`Mark "${itemName}" as complete?`);
|
await expect(page.locator('.modal-body')).toContainText(`Mark "${itemName}" as complete?`);
|
||||||
await page.locator('.modal-footer button:has-text("Confirm")').click();
|
await page.locator('.modal-footer button:has-text("Confirm")').click();
|
||||||
|
|
||||||
// Verify the item's appearance changes (e.g., strikethrough, class 'neo-item-complete')
|
// Verify the item's appearance changes (e.g., strikethrough, class 'neo-item-complete')
|
||||||
await expect(firstItem).toHaveClass(/neo-item-complete/);
|
await expect(firstItem).toHaveClass(/neo-item-complete/);
|
||||||
// Also check if checkbox is now checked (it should be due to optimistic update + confirmation)
|
// Also check if checkbox is now checked (it should be due to optimistic update + confirmation)
|
||||||
|
@ -308,16 +308,13 @@ const selectGroup = (group: Group) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openCreateListDialog = (group: Group) => {
|
const openCreateListDialog = (group: Group) => {
|
||||||
console.log('Opening create list dialog for group:', group);
|
|
||||||
// Ensure we have the latest groups data
|
// Ensure we have the latest groups data
|
||||||
fetchGroups().then(() => {
|
fetchGroups().then(() => {
|
||||||
console.log('Setting up modal with group:', group);
|
|
||||||
availableGroupsForModal.value = [{
|
availableGroupsForModal.value = [{
|
||||||
label: group.name,
|
label: group.name,
|
||||||
value: group.id
|
value: group.id
|
||||||
}];
|
}];
|
||||||
showCreateListModal.value = true;
|
showCreateListModal.value = true;
|
||||||
console.log('Modal should be visible now:', showCreateListModal.value);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,15 +59,6 @@ const authStore = useAuthStore();
|
|||||||
const notificationStore = useNotificationStore();
|
const notificationStore = useNotificationStore();
|
||||||
const { t, locale, messages } = useI18n();
|
const { t, locale, messages } = useI18n();
|
||||||
|
|
||||||
// Debug output
|
|
||||||
console.log('=== i18n Debug Info ===');
|
|
||||||
console.log('Current locale:', locale.value);
|
|
||||||
console.log('Available messages:', messages.value);
|
|
||||||
console.log('English messages:', messages.value.en);
|
|
||||||
console.log('LoginPage messages:', messages.value.en?.loginPage);
|
|
||||||
console.log('Test translation:', t('loginPage.emailLabel'));
|
|
||||||
console.log('Test fallback:', t('message.hello'));
|
|
||||||
|
|
||||||
const email = ref('');
|
const email = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const isPwdVisible = ref(false);
|
const isPwdVisible = ref(false);
|
||||||
|
@ -57,25 +57,20 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
|
|
||||||
const fetchCurrentUser = async () => {
|
const fetchCurrentUser = async () => {
|
||||||
if (!accessToken.value) {
|
if (!accessToken.value) {
|
||||||
console.log('No access token found, clearing tokens')
|
|
||||||
clearTokens()
|
clearTokens()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
console.log('Fetching current user profile...')
|
|
||||||
const response = await api.get(API_ENDPOINTS.USERS.PROFILE)
|
const response = await api.get(API_ENDPOINTS.USERS.PROFILE)
|
||||||
console.log('User profile fetched:', response.data)
|
|
||||||
setUser(response.data)
|
setUser(response.data)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('AuthStore: Failed to fetch current user:', error)
|
|
||||||
clearTokens()
|
clearTokens()
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const login = async (email: string, password: string) => {
|
const login = async (email: string, password: string) => {
|
||||||
console.log('Attempting login...')
|
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('username', email)
|
formData.append('username', email)
|
||||||
formData.append('password', password)
|
formData.append('password', password)
|
||||||
@ -86,10 +81,8 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Login successful, setting tokens...')
|
|
||||||
const { access_token, refresh_token } = response.data
|
const { access_token, refresh_token } = response.data
|
||||||
setTokens({ access_token, refresh_token })
|
setTokens({ access_token, refresh_token })
|
||||||
// Fetch profile data after login
|
|
||||||
await fetchCurrentUser()
|
await fetchCurrentUser()
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@ export const useListDetailStore = defineStore('listDetail', {
|
|||||||
// Call the actual API endpoint using generic post method
|
// Call the actual API endpoint using generic post method
|
||||||
const endpoint = `/financials/expense_splits/${payload.expense_split_id}/settle`
|
const endpoint = `/financials/expense_splits/${payload.expense_split_id}/settle`
|
||||||
const response = await apiClient.post(endpoint, payload.activity_data)
|
const response = await apiClient.post(endpoint, payload.activity_data)
|
||||||
console.log('Settlement activity created:', response.data)
|
|
||||||
|
|
||||||
// Refresh list data to show updated statuses
|
// Refresh list data to show updated statuses
|
||||||
if (payload.list_id_for_refetch) {
|
if (payload.list_id_for_refetch) {
|
||||||
@ -111,31 +110,31 @@ export const useListDetailStore = defineStore('listDetail', {
|
|||||||
},
|
},
|
||||||
getPaidAmountForSplit:
|
getPaidAmountForSplit:
|
||||||
(state: ListDetailState) =>
|
(state: ListDetailState) =>
|
||||||
(splitId: number): number => {
|
(splitId: number): number => {
|
||||||
let totalPaid = 0
|
let totalPaid = 0
|
||||||
if (state.currentList && state.currentList.expenses) {
|
if (state.currentList && state.currentList.expenses) {
|
||||||
for (const expense of state.currentList.expenses) {
|
for (const expense of state.currentList.expenses) {
|
||||||
const split = expense.splits.find((s) => s.id === splitId)
|
const split = expense.splits.find((s) => s.id === splitId)
|
||||||
if (split && split.settlement_activities) {
|
if (split && split.settlement_activities) {
|
||||||
totalPaid = split.settlement_activities.reduce((sum, activity) => {
|
totalPaid = split.settlement_activities.reduce((sum, activity) => {
|
||||||
return sum + parseFloat(activity.amount_paid)
|
return sum + parseFloat(activity.amount_paid)
|
||||||
}, 0)
|
}, 0)
|
||||||
break
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return totalPaid
|
||||||
return totalPaid
|
},
|
||||||
},
|
|
||||||
getExpenseSplitById:
|
getExpenseSplitById:
|
||||||
(state: ListDetailState) =>
|
(state: ListDetailState) =>
|
||||||
(splitId: number): ExpenseSplit | undefined => {
|
(splitId: number): ExpenseSplit | undefined => {
|
||||||
if (!state.currentList || !state.currentList.expenses) return undefined
|
if (!state.currentList || !state.currentList.expenses) return undefined
|
||||||
for (const expense of state.currentList.expenses) {
|
for (const expense of state.currentList.expenses) {
|
||||||
const split = expense.splits.find((s) => s.id === splitId)
|
const split = expense.splits.find((s) => s.id === splitId)
|
||||||
if (split) return split
|
if (split) return split
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ const initializeSW = async () => {
|
|||||||
try {
|
try {
|
||||||
await self.skipWaiting();
|
await self.skipWaiting();
|
||||||
clientsClaim();
|
clientsClaim();
|
||||||
console.log('Service Worker initialized successfully');
|
// console.log('Service Worker initialized successfully');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error during service worker initialization:', error);
|
console.error('Error during service worker initialization:', error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user