Skip to content

Commit

Permalink
Disable sharing in collab and use unique artifact key
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed May 5, 2024
1 parent 5ba41a1 commit 252349e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
7 changes: 6 additions & 1 deletion packages/lexical-playground/__tests__/e2e/Share.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -221,6 +225,7 @@ export default function ActionsPlugin({
</button>
<button
className="action-button share"
disabled={isCollabActive}
onClick={() =>
shareDoc(
serializedDocumentFromEditorState(editor.getEditorState(), {
Expand Down

0 comments on commit 252349e

Please sign in to comment.