Skip to content

Commit

Permalink
Don't show toasts in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuvonen committed Dec 13, 2024
1 parent e1d9cec commit d46735c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 22 deletions.
6 changes: 0 additions & 6 deletions e2e/log.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ test('logs veggies', async ({page}) => {
'This Week 2 Veggies',
);

const elements = await page.getByTestId('toast-message').all();
for (const element of elements) {
await element.click();
}

await expect(page.getByTestId('toast-message')).toBeHidden();
await page.getByTestId('navbar-link-settings').click();
await page.getByTestId('navbar-link-log').click();
await expect(page.getByTestId('category-status-chart-center-label')).toHaveText(
Expand Down
4 changes: 0 additions & 4 deletions e2e/stats.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ test("shows current week's veggies", async ({page}) => {
await page.getByText(/^apple$/).click();
await page.getByText('Apricot').click();
await page.getByText('Avocado').click();
const elements = await page.getByTestId('toast-message').all();
for (const element of elements) {
await element.click();
}
await page.getByTestId('navbar-link-stats').click();
await expect(page.getByTestId('tag-apple')).toBeVisible();
await expect(page.getByTestId('tag-apricot')).toBeVisible();
Expand Down
8 changes: 1 addition & 7 deletions src/components/ToastContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ const {messages} = storeToRefs(appStateStore);
const {removeToastMessage} = appStateStore;
</script>
<template>
<TransitionGroup
tag="div"
name="toasts"
class="toast-container"
aria-live="polite"
@before-leave="() => console.log('before-leave')"
>
<TransitionGroup tag="div" name="toasts" class="toast-container" aria-live="polite">
<ToastMessage
v-for="message in messages"
:key="message.id"
Expand Down
10 changes: 6 additions & 4 deletions src/stores/appStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ export const useAppStateStore = defineStore('appState', () => {
const messages = ref<Message[]>([]);

const addToastMessage = (text: string) => {
messages.value.push({
id: crypto.randomUUID(),
text,
});
if (import.meta.env.MODE !== 'staging') {
messages.value.push({
id: crypto.randomUUID(),
text,
});
}
};

const removeToastMessage = (targetId: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/views/LogView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ watch(currentVeggies, (newCurrentVeggies, oldCurrentVeggies) => {
addToastMessage(t('toasts.challengeCompleted', [getCheer()]));
} else if (allVeggies.value.length % 100 === 0) {
addToastMessage(t('toasts.totalVeggies', [allVeggies.value.length, getCheer()]));
} else if (Math.random() <= 0.35) {
} else if (Math.random() <= 0.4) {
const facts = [
...Object.values<string>(tm(`facts.${addedVeggie}`)),
t('toasts.uniqueVeggies', [uniqueVeggies.value.length, ALL_VEGGIES.length, getCheer()]),
Expand Down

0 comments on commit d46735c

Please sign in to comment.