From 9689ad415da89aba5be1b80dec259be6ecd0c479 Mon Sep 17 00:00:00 2001 From: weilirs <62249815+weilirs@users.noreply.github.com> Date: Wed, 22 Nov 2023 01:47:15 -0600 Subject: [PATCH] test(e2e, playwright): add tests for close buttons in solution-viewer improvements (#52382) --- e2e/solution-viewer.spec.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/e2e/solution-viewer.spec.ts b/e2e/solution-viewer.spec.ts index 54b68a21341..a394fad4183 100644 --- a/e2e/solution-viewer.spec.ts +++ b/e2e/solution-viewer.spec.ts @@ -12,6 +12,11 @@ test.describe('Solution Viewer component', () => { test('renders the modal correctly', async ({ page }) => { await page.getByRole('button').filter({ hasText: /view/i }).first().click(); + const projectSolutionViewerModal = page.getByTestId( + 'project-solution-viewer-modal' + ); + await expect(projectSolutionViewerModal).toBeVisible(); + // The modal should show the solution title... await expect( page.getByRole('heading').and(page.getByText(/solution for/i)) @@ -19,5 +24,18 @@ test.describe('Solution Viewer component', () => { // ...and relevant code file/s await expect(page.getByText(/js/i)).toBeVisible(); await expect(page.locator('pre').first()).toBeVisible(); + + const closeButtons = await page + .getByRole('button', { name: 'Close' }) + .all(); + + const topRightCloseButton = closeButtons[0]; + await topRightCloseButton.click(); + await expect(projectSolutionViewerModal).toBeHidden(); + + await page.getByRole('button', { name: 'View' }).first().click(); + const bottomRightCloseButton = closeButtons[1]; + await bottomRightCloseButton.click(); + await expect(projectSolutionViewerModal).toBeHidden(); }); });