From 252349e53d13ae85cb416d654c3d49bbf535a599 Mon Sep 17 00:00:00 2001 From: Bob Ippolito Date: Sun, 5 May 2024 11:34:18 -0700 Subject: [PATCH] Disable sharing in collab and use unique artifact key --- .github/workflows/e2e-test.yml | 7 ++++--- packages/lexical-playground/__tests__/e2e/Share.spec.mjs | 7 ++++++- .../lexical-playground/src/plugins/ActionsPlugin/index.tsx | 5 +++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 1b2e5f518c2..72456dac034 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -18,8 +18,9 @@ jobs: CI: true E2E_EDITOR_MODE: ${{ inputs.editor-mode }} E2E_EVENTS_MODE: ${{ inputs.events-mode }} - cache_playwright_path: ${{ inputs.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || inputs.os == 'windows-latest' && 'C:\Users\runneradmin\AppData\Local\ms-playwright' || '~/.cache/ms-playwright'}} + cache_playwright_path: ${{ inputs.os == 'macos-latest' && '~/Library/Caches/ms-playwright' || inputs.os == 'windows-latest' && 'C:\Users\runneradmin\AppData\Local\ms-playwright' || '~/.cache/ms-playwright' }} test_results_path: ${{ inputs.os == 'windows-latest' && '~/.npm/_logs/' || 'test-results/' }} + test_script: test-e2e-${{ inputs.editor-mode == 'rich-text-with-collab' && 'collab-' || '' }}${{ inputs.prod && 'prod-' || '' }}ci-${{ inputs.browser }} steps: - uses: actions/checkout@v4 - name: Use Node.js ${{ inputs.node-version }} @@ -49,11 +50,11 @@ jobs: path: ${{ env.cache_playwright_path }} key: ${{ steps.playwright-cache.outputs.cache-primary-key }} - name: Run tests - run: npm run test-e2e-${{ inputs.editor-mode == 'rich-text-with-collab' && 'collab-' || ''}}${{ inputs.prod && 'prod-' || '' }}ci-${{ inputs.browser }} + run: npm run ${{ env.test_script }} - name: Upload Artifacts if: failure() uses: actions/upload-artifact@v4 with: - name: Test Results + name: Test Results ${{ inputs.os }}-${{ inputs.browser }}-${{ inputs.editor-mode }}-${{ inputs.events-mode }}-${{ inputs.prod && 'prod' || 'dev' }}-${{ inputs.node-version }} path: ${{ env.test_results_path }} retention-days: 7 diff --git a/packages/lexical-playground/__tests__/e2e/Share.spec.mjs b/packages/lexical-playground/__tests__/e2e/Share.spec.mjs index f79d254360c..53b41fd6222 100644 --- a/packages/lexical-playground/__tests__/e2e/Share.spec.mjs +++ b/packages/lexical-playground/__tests__/e2e/Share.spec.mjs @@ -18,7 +18,12 @@ import { test.describe('Share', () => { test.beforeEach(({isCollab, page}) => initialize({isCollab, page})); - test(`can share the editor state`, async ({page}) => { + test('is disabled in collab', async ({page, isCollab}) => { + test.skip(!isCollab); + expect(page.locator('.action-button.share')).toBeDisabled(); + }); + test('can share the editor state', async ({page, isCollab}) => { + test.skip(isCollab); await focusEditor(page); const fooHTML = html` diff --git a/packages/lexical-playground/src/plugins/ActionsPlugin/index.tsx b/packages/lexical-playground/src/plugins/ActionsPlugin/index.tsx index e485f6fb5f0..c02e8bb257e 100644 --- a/packages/lexical-playground/src/plugins/ActionsPlugin/index.tsx +++ b/packages/lexical-playground/src/plugins/ActionsPlugin/index.tsx @@ -34,6 +34,7 @@ import { } from 'lexical'; import {useCallback, useEffect, useState} from 'react'; +import {INITIAL_SETTINGS} from '../../appSettings'; import useFlashMessage from '../../hooks/useFlashMessage'; import useModal from '../../hooks/useModal'; import Button from '../../ui/Button'; @@ -104,6 +105,9 @@ export default function ActionsPlugin({ const showFlashMessage = useFlashMessage(); const {isCollabActive} = useCollaborationContext(); useEffect(() => { + if (INITIAL_SETTINGS.isCollab) { + return; + } docFromHash(window.location.hash).then((doc) => { if (doc && doc.source === 'Playground') { editor.setEditorState(editorStateFromSerializedDocument(editor, doc)); @@ -221,6 +225,7 @@ export default function ActionsPlugin({