From 700c53485643c1d72256bde9d27cf64a5c2c811e Mon Sep 17 00:00:00 2001 From: Eirik Mo Date: Sun, 1 Oct 2023 14:23:38 +0200 Subject: [PATCH] feat: add test for updating toast --- test/src/app/page.tsx | 15 +++++++++++++++ test/tests/basic.spec.ts | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/test/src/app/page.tsx b/test/src/app/page.tsx index 9e9826b..73181ea 100644 --- a/test/src/app/page.tsx +++ b/test/src/app/page.tsx @@ -126,6 +126,21 @@ export default function Home({ searchParams }: any) { > Non-dismissible Toast + {showAutoClose ?
: null} {showDismiss ?
: null} diff --git a/test/tests/basic.spec.ts b/test/tests/basic.spec.ts index 688689a..de74409 100644 --- a/test/tests/basic.spec.ts +++ b/test/tests/basic.spec.ts @@ -1,4 +1,4 @@ -import { test, expect } from '@playwright/test'; +import { expect, test } from '@playwright/test'; test.beforeEach(async ({ page }) => { await page.goto('/'); @@ -159,4 +159,10 @@ test.describe('Basic functionality', () => { await page.getByTestId('default-button').click(); await expect(page.locator('[data-sonner-toaster]')).toHaveAttribute('dir', 'ltr'); }); + + test('show correct toast content when updating', async ({ page }) => { + await page.getByTestId('update-toast').click(); + await expect(page.getByText('My Unupdated Toast')).toHaveCount(0); + await expect(page.getByText('My Updated Toast')).toHaveCount(1); + }); });