|
| 1 | +/** |
| 2 | + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors |
| 3 | + * SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | + */ |
| 5 | + |
| 6 | +import { expect, test } from '@playwright/test' |
| 7 | +import { createRandomUser, deleteUser, login, setUserPreference } from './support/utils.ts' |
| 8 | + |
| 9 | +test.describe('First Run Wizard', () => { |
| 10 | + test('opens automatically on first login', async ({ page }) => { |
| 11 | + const user = await createRandomUser() |
| 12 | + |
| 13 | + try { |
| 14 | + await login(page, user.userId, user.password) |
| 15 | + |
| 16 | + // The wizard is injected by first-run.ts and opened automatically |
| 17 | + const wizard = page.locator('.first-run-wizard') |
| 18 | + await expect(wizard).toBeVisible() |
| 19 | + |
| 20 | + // For a brand-new user the intro animation (video) is shown first |
| 21 | + await expect(wizard.locator('video')).toBeVisible() |
| 22 | + } finally { |
| 23 | + await deleteUser(user.userId) |
| 24 | + } |
| 25 | + }) |
| 26 | + |
| 27 | + test('opens when a new major version was shipped', async ({ page }) => { |
| 28 | + const user = await createRandomUser() |
| 29 | + |
| 30 | + try { |
| 31 | + // Simulate a user who last saw wizard version 2.0.0. |
| 32 | + // The stored version is greater than "1" (so changelogOnly = true) |
| 33 | + // but less than the current CHANGELOG_VERSION (33.0.0), |
| 34 | + // so the wizard is injected and opened again. |
| 35 | + await setUserPreference(user.userId, 'firstrunwizard', 'show', '2.0.0') |
| 36 | + |
| 37 | + await login(page, user.userId, user.password) |
| 38 | + |
| 39 | + const wizard = page.locator('.first-run-wizard') |
| 40 | + await expect(wizard).toBeVisible() |
| 41 | + |
| 42 | + // The intro animation is always shown first; skip it to advance |
| 43 | + // directly to the "What's new" page (changelog-only mode). |
| 44 | + const skipButton = wizard.getByRole('button', { name: 'Skip' }) |
| 45 | + await expect(skipButton).toBeVisible({ timeout: 5_000 }) |
| 46 | + await skipButton.click() |
| 47 | + |
| 48 | + // In changelog-only mode the wizard advances directly to the |
| 49 | + // "What's new" page after the intro animation. |
| 50 | + await expect(wizard).toContainText('New in Nextcloud Hub') |
| 51 | + } finally { |
| 52 | + await deleteUser(user.userId) |
| 53 | + } |
| 54 | + }) |
| 55 | + |
| 56 | + test('"About & What\'s new" menu entry reopens the wizard', async ({ page }) => { |
| 57 | + const user = await createRandomUser() |
| 58 | + |
| 59 | + try { |
| 60 | + await login(page, user.userId, user.password) |
| 61 | + |
| 62 | + // Close the first-run wizard that opens automatically on first login |
| 63 | + const wizard = page.locator('.first-run-wizard') |
| 64 | + await expect(wizard).toBeVisible() |
| 65 | + |
| 66 | + // Skip the intro animation as soon as the Skip button appears (~2s) |
| 67 | + const skipButton = wizard.getByRole('button', { name: 'Skip' }) |
| 68 | + await expect(skipButton).toBeVisible({ timeout: 5_000 }) |
| 69 | + await skipButton.click() |
| 70 | + |
| 71 | + // Close the slideshow |
| 72 | + const closeButton = wizard.getByRole('button', { name: 'Close' }) |
| 73 | + await expect(closeButton).toBeVisible() |
| 74 | + await closeButton.click() |
| 75 | + await expect(wizard).not.toBeVisible() |
| 76 | + |
| 77 | + // Open the user settings menu to find the "About & What's new" entry |
| 78 | + const userMenu = page.locator('[aria-controls="header-menu-user-menu"]') |
| 79 | + await userMenu.click() |
| 80 | + |
| 81 | + // Use the link role to avoid strict mode violation from the duplicate ID |
| 82 | + // that Nextcloud renders on both the <li> and the inner <a> element |
| 83 | + const aboutEntry = page.getByRole('link', { name: "About & What's new" }) |
| 84 | + await aboutEntry.click() |
| 85 | + |
| 86 | + // The wizard should open again via the app-menu.ts handler |
| 87 | + await expect(wizard).toBeVisible() |
| 88 | + } finally { |
| 89 | + await deleteUser(user.userId) |
| 90 | + } |
| 91 | + }) |
| 92 | + |
| 93 | + test('can be navigated and closed', async ({ page }) => { |
| 94 | + const user = await createRandomUser() |
| 95 | + |
| 96 | + try { |
| 97 | + await login(page, user.userId, user.password) |
| 98 | + |
| 99 | + const wizard = page.locator('.first-run-wizard') |
| 100 | + await expect(wizard).toBeVisible() |
| 101 | + |
| 102 | + // Skip the intro animation as soon as the Skip button appears (~2s) |
| 103 | + const skipButton = wizard.getByRole('button', { name: 'Skip' }) |
| 104 | + await expect(skipButton).toBeVisible({ timeout: 5_000 }) |
| 105 | + await skipButton.click() |
| 106 | + |
| 107 | + // The slideshow is now shown with the Close button always visible. |
| 108 | + const closeButton = wizard.getByRole('button', { name: 'Close' }) |
| 109 | + await expect(closeButton).toBeVisible() |
| 110 | + |
| 111 | + // Navigate through all pages by repeatedly clicking the last button |
| 112 | + // (always the forward/primary navigation button) until the final |
| 113 | + // page's "Get started!" button is reached. |
| 114 | + const getStartedButton = wizard.getByRole('button', { name: 'Get started!' }) |
| 115 | + |
| 116 | + while (!(await getStartedButton.isVisible())) { |
| 117 | + // The last button in DOM order is always the last navigation button |
| 118 | + // in the button_wrapper (after the Close and Back buttons) |
| 119 | + await wizard.getByRole('button').last().click() |
| 120 | + } |
| 121 | + |
| 122 | + // Clicking "Get started!" on the last page closes the wizard |
| 123 | + await getStartedButton.click() |
| 124 | + |
| 125 | + // The wizard should no longer be visible after closing |
| 126 | + await expect(wizard).not.toBeVisible() |
| 127 | + } finally { |
| 128 | + await deleteUser(user.userId) |
| 129 | + } |
| 130 | + }) |
| 131 | +}) |
0 commit comments