From 3166c31c1a8936d34a23c860d13add43a989abf9 Mon Sep 17 00:00:00 2001 From: "Andrea N. Cardona" Date: Tue, 10 Oct 2023 12:34:26 -0600 Subject: [PATCH] feat: ErrorBoundary avt test (#14754) * feat: add keyboard nav definition tooltip * feat: errorboundary avt test * Delete e2e/components/DefinitionTooltip/DefinitionTooltip-test.avt.e2e.js * Update e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js Co-authored-by: Guilherme Datilio Ribeiro * Update e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js Co-authored-by: Guilherme Datilio Ribeiro --------- Co-authored-by: Guilherme Datilio Ribeiro Co-authored-by: TJ Egan --- .../ErrorBoundary-test.avt.e2e.js | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js diff --git a/e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js b/e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js new file mode 100644 index 000000000000..228acfe6e1bc --- /dev/null +++ b/e2e/components/ErrorBoundary/ErrorBoundary-test.avt.e2e.js @@ -0,0 +1,64 @@ +/** + * Copyright IBM Corp. 2016, 2023 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const { expect, test } = require('@playwright/test'); +const { visitStory } = require('../../test-utils/storybook'); + +test.describe('ErrorBoundary @avt', () => { + test('@avt-default-state ErrorBoundary', async ({ page }) => { + await visitStory(page, { + component: 'ErrorBoundary', + id: 'components-errorboundary--default', + globals: { + theme: 'white', + }, + }); + await expect(page).toHaveNoACViolations('ErrorBoundary'); + }); + + test('@avt-advanced-states ErrorBoundary with Custom context', async ({ + page, + }) => { + await visitStory(page, { + component: 'ErrorBoundary', + id: 'components-errorboundary--skeleton', + globals: { + theme: 'white', + }, + }); + await expect(page).toHaveNoACViolations( + 'ErrorBoundary with Custom context' + ); + }); + + test('@avt-keyboard-state default', async ({ page }) => { + await visitStory(page, { + component: 'ErrorBoundary', + id: 'components-errorboundary--default', + globals: { + theme: 'white', + }, + args: { + disabled: true, + }, + }); + + const errorBoundaryButton = page.getByRole('button', { + name: 'Toggle throwing error', + }); + const elementLocator = page.locator('div.cds--layout'); + + // Testing ErrorBoundary + await page.keyboard.press('Tab'); + await expect(errorBoundaryButton).toBeVisible(); + await expect(elementLocator).toContainText('Successfully rendered'); + await errorBoundaryButton.click(); + await expect(elementLocator).toContainText('Whoops'); + }); +});