Skip to content

TagSpaces is an offline, open source, document manager with tagging support

chore: added e2e tests for the onboarding workflow

Ilian Sapundshieva71864f4c6b9
diff --git a/tests/e2e/onboarding.pw.e2e.js b/tests/e2e/onboarding.pw.e2e.js
new file mode 100644
index 000000000..e20e1258b
--- /dev/null
+++ b/tests/e2e/onboarding.pw.e2e.js
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2016-present - TagSpaces GmbH. All rights reserved.
+ */
+import { test, expect } from './fixtures';
+import { startTestingApp, stopApp } from './hook';
+import { clearDataStorage } from './welcome.helpers';
+
+// Onboarding tests boot the app WITHOUT an extconfig override so
+// ExtIsFirstRun is undefined and the license/onboarding dialogs auto-show
+// from default settings (firstRun: true). General tests use extconfig.js
+// which suppresses the dialogs — that's why this file owns its own
+// beforeAll instead of sharing the general suite's setup.
+
+test.beforeAll(async ({ isWeb, isS3, webServerPort }, testInfo) => {
+ await startTestingApp({ isWeb, isS3, webServerPort, testInfo });
+});
+
+test.afterAll(async () => {
+ await stopApp();
+});
+
+test.afterEach(async ({ isWeb }) => {
+ // Reset firstRun and onboarding flags between tests so each one starts
+ // from a clean slate. clearDataStorage clears localStorage; we then
+ // reload so providers re-mount and the license/wizard appear again.
+ await clearDataStorage(isWeb);
+ if (!isWeb) {
+ await global.client.reload();
+ }
+});
+
+test.describe('TST91 - Onboarding flow', () => {
+ test('TST9101 - License dialog shown on first run [electron,web,s3]', async () => {
+ // The license dialog blocks until accepted. Its primary CTA is the
+ // "Agree License" button; the "Quit" button is the alternative.
+ const agreeBtn = await global.client.waitForSelector(
+ '[data-tid=agreeLicenseDialog]',
+ { timeout: 10000, state: 'visible' },
+ );
+ expect(agreeBtn).toBeTruthy();
+
+ const quitBtn = await global.client.$('[data-tid=confirmLicenseDialog]');
+ expect(quitBtn).toBeTruthy();
+ });
+
+ test('TST9102 - Accepting license opens the onboarding wizard [electron,web,s3]', async () => {
+ // License dialog should be visible.
+ await global.client.waitForSelector('[data-tid=agreeLicenseDialog]', {
+ timeout: 10000,
+ state: 'visible',
+ });
+
+ // Accepting the license should close it and reveal the onboarding
+ // wizard underneath. The wizard's close button has the stable data-tid
+ // 'closeOnboardingDialog'.
+ await global.client.click('[data-tid=agreeLicenseDialog]');
+
+ const closeOnboarding = await global.client.waitForSelector(
+ '[data-tid=closeOnboardingDialog]',
+ { timeout: 5000, state: 'visible' },
+ );
+ expect(closeOnboarding).toBeTruthy();
+
+ // The wizard footer should show a Next button on the first slide
+ // (the finish CTA only appears on the last slide).
+ const nextBtn = await global.client.waitForSelector(
+ '[data-tid=onboardingNextTID]',
+ { timeout: 3000, state: 'visible' },
+ );
+ expect(nextBtn).toBeTruthy();
+ });
+
+ test('TST9103 - Wizard navigates through all slides via Next [electron,web,s3]', async () => {
+ await global.client.waitForSelector('[data-tid=agreeLicenseDialog]', {
+ timeout: 10000,
+ state: 'visible',
+ });
+ await global.client.click('[data-tid=agreeLicenseDialog]');
+ await global.client.waitForSelector('[data-tid=closeOnboardingDialog]', {
+ timeout: 5000,
+ state: 'visible',
+ });
+
+ // 5 slides total → 4 Next clicks land us on slide 5.
+ // After the 4th click, Next should be replaced by the finish CTA
+ // (either onboardingOpenPrimaryTID or onboardingChooseFolderToStartTID).
+ for (let i = 0; i < 4; i++) {
+ await global.client.click('[data-tid=onboardingNextTID]');
+ // Small settle time for Swiper transition (500ms speed).
+ await global.client.waitForTimeout(600);
+ }
+
+ // The Next button should be gone on the last slide.
+ const stillHasNext = await global.client.$(
+ '[data-tid=onboardingNextTID]',
+ );
+ expect(stillHasNext).toBeFalsy();
+
+ // The finish CTA must be present in one of its two forms.
+ const openPrimary = await global.client.$(
+ '[data-tid=onboardingOpenPrimaryTID]',
+ );
+ const chooseFolder = await global.client.$(
+ '[data-tid=onboardingChooseFolderToStartTID]',
+ );
+ expect(openPrimary || chooseFolder).toBeTruthy();
+ });
+
+ test('TST9104 - Closing the wizard marks onboarding completed [electron,web,s3]', async () => {
+ await global.client.waitForSelector('[data-tid=agreeLicenseDialog]', {
+ timeout: 10000,
+ state: 'visible',
+ });
+ await global.client.click('[data-tid=agreeLicenseDialog]');
+ await global.client.waitForSelector('[data-tid=closeOnboardingDialog]', {
+ timeout: 5000,
+ state: 'visible',
+ });
+
+ // Close via the X — this should dispatch setOnboardingCompleted(true).
+ await global.client.click('[data-tid=closeOnboardingDialog]');
+
+ // Wait for the dialog to actually disappear before reading state.
+ await global.client.waitForSelector('[data-tid=closeOnboardingDialog]', {
+ timeout: 3000,
+ state: 'hidden',
+ });
+
+ // Read Redux-persisted settings from localStorage and verify the
+ // onboardingCompleted flag was set.
+ const onboardingCompleted = await global.client.evaluate(() => {
+ const root = JSON.parse(localStorage.getItem('persist:root') || '{}');
+ if (!root.settings) return null;
+ const settings = JSON.parse(root.settings);
+ return settings.onboardingCompleted;
+ });
+ expect(onboardingCompleted).toBe(true);
+ });
+});
diff --git a/tests/e2e/welcome.helpers.js b/tests/e2e/welcome.helpers.js
index a569386aa..280bc1380 100644
--- a/tests/e2e/welcome.helpers.js
+++ b/tests/e2e/welcome.helpers.js
@@ -18,26 +18,35 @@ export async function clearDataStorage(isWeb) {
}
export async function closeWelcomePlaywright() {
+ // Order matters since the onboarding redesign: the License dialog now
+ // opens alone first, and the Onboarding wizard is chained from the
+ // license-accept handler. Dismiss them in that order. Each step is best-
+ // effort — if the user already accepted the license in a prior test in
+ // the same worker, the wait will timeout harmlessly.
+ let licenseFound = false;
try {
- const el = await global.client.waitForSelector(
- '[data-tid=closeOnboardingDialog]',
- {
- timeout: 3000,
- state: 'visible',
- },
+ const license = await global.client.waitForSelector(
+ '[data-tid=agreeLicenseDialog]',
+ { timeout: 3000, state: 'visible' },
);
- if (el) {
- await el.click();
- /*
- await global.client.click('[data-tid=nextStepOnboarding]');
- await global.client.click('[data-tid=nextStepOnboarding]');
- await global.client.click('[data-tid=nextStepOnboarding]');
- await global.client.click('[data-tid=nextStepOnboarding]');
- await global.client.click('[data-tid=startTagSpacesAfterOnboarding]');
- */
- await global.client.click('[data-tid=agreeLicenseDialog]');
+ if (license) {
+ await license.click();
+ licenseFound = true;
}
} catch (e) {
- //console.log('closeOnboardingDialog not exist');
+ // license dialog not present — nothing to accept
+ }
+ // Onboarding only chains in if the license was just accepted. Skip the
+ // wait otherwise to avoid penalising tests where neither dialog is up.
+ if (licenseFound) {
+ try {
+ const onboarding = await global.client.waitForSelector(
+ '[data-tid=closeOnboardingDialog]',
+ { timeout: 3000, state: 'visible' },
+ );
+ if (onboarding) await onboarding.click();
+ } catch (e) {
+ // onboarding wizard not present (e.g., onboardingCompleted already)
+ }
}
}