|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { Constants } from '../../cypress-e2e/fixtures/constants'; |
| 3 | + |
| 4 | +test.describe('Complete React case', () => { |
| 5 | + test.beforeEach(async ({ page }) => { |
| 6 | + await page.goto('/'); |
| 7 | + }); |
| 8 | + |
| 9 | + test('Check App build and running', async ({ page }) => { |
| 10 | + const text = Constants.elementsText.completeReactCaseApp; |
| 11 | + await expect(page.locator('h1')).toHaveText(text.header); |
| 12 | + await expect(page.locator('strong').nth(0)).toHaveText(text.paragraphs.firstParagraph); |
| 13 | + await expect(page.locator('strong').nth(1)).toHaveText(text.paragraphs.secondParagraph); |
| 14 | + await expect(page.locator('h4').filter({ hasText: text.buttons.h4Buttons })).toBeVisible(); |
| 15 | + await expect(page.locator('h4').filter({ hasText: text.h4Dialog })).toBeVisible(); |
| 16 | + await expect(page.locator('h4').filter({ hasText: text.h4HoverElement })).toBeVisible(); |
| 17 | + await expect(page.locator('.tool-tip')).toHaveText(text.h4HoverElement); |
| 18 | + }); |
| 19 | + |
| 20 | + test('Check App buttons', async ({ page }) => { |
| 21 | + const { buttons } = Constants.elementsText.completeReactCaseApp; |
| 22 | + await expect(page.getByRole('button', { name: buttons.primaryButton })).toBeVisible(); |
| 23 | + await expect(page.getByRole('button', { name: buttons.warningButton })).toBeVisible(); |
| 24 | + await expect(page.getByRole('button', { name: buttons.openDialogButton })).toBeVisible(); |
| 25 | + await expect(page.getByRole('button', { name: buttons.primaryButton })).toHaveCSS( |
| 26 | + 'background-color', |
| 27 | + Constants.color.lightWashedAzure, |
| 28 | + ); |
| 29 | + await expect(page.getByRole('button', { name: buttons.warningButton })).toHaveCSS( |
| 30 | + 'background-color', |
| 31 | + Constants.color.lightWashedOrange, |
| 32 | + ); |
| 33 | + }); |
| 34 | + |
| 35 | + test('Check App Dialog popup', async ({ page }) => { |
| 36 | + const { buttons, nameMessage } = Constants.elementsText.completeReactCaseApp; |
| 37 | + await page.getByRole('button', { name: buttons.openDialogButton }).click(); |
| 38 | + await expect(page.getByRole('button', { name: buttons.closeButton })).toBeVisible(); |
| 39 | + await expect(page.getByText(nameMessage)).toBeVisible(); |
| 40 | + await page.fill('input', Constants.commonPhrases.completeReactCaseApp.input); |
| 41 | + await page.getByRole('button', { name: buttons.closeButton }).click(); |
| 42 | + }); |
| 43 | +}); |
| 44 | + |
0 commit comments