diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
index c72e4f3..b6d1a9b 100644
--- a/.github/workflows/codecov.yml
+++ b/.github/workflows/codecov.yml
@@ -8,54 +8,20 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@v2.3.1
- # - name: Install Node.js, NPM and Yarn
- # env:
- # ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- # uses: actions/setup-node@v1.4.2
- # with:
- # node-version: 14
-
- # - name: yarn install from npmjs registry
- # env:
- # ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- # run: |
- # npm config set registry https://registry.npmjs.org
- # cd app/client
- # yarn install --no-lockfile
- # cd ..
- # yarn install --no-lockfile
- # cd ..
- # yarn install --no-lockfile
-
- - name: configure app/client for yarn cache
+ - name: install yarn dependencies in app/client using cache
uses: bahmutov/npm-install@v1.6.0
with:
working-directory: ./app/client
- - name: configure project root for yarn cache
+ - name: install yarn dependencies in ./ using cache
uses: bahmutov/npm-install@v1.6.0
with:
working-directory: ./
- - name: ./app/client yarn install
- run: yarn install --frozen-lockfile
- working-directory: ./app/client
- - name: ./ yarn install
- run: yarn install --frozen-lockfile
- working-directory: ./
-
- # - name: Configure private AWS npm registry and install packages from it
- # env:
- # ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- # if: ${{ failure() }}
- # run: |
- # npm config set registry https://packages.deskreen.com/
- # npm set //packages.deskreen.com/:_authToken="${{ secrets.NPMRC_USER_TOKEN }}"
- # npm config set always-auth true
- # cd app/client
- # yarn install --frozen-lockfile
- # cd ../..
- # yarn install --frozen-lockfile
+ - name: install yarn dependencies in ./app using cache
+ uses: bahmutov/npm-install@v1.6.0
+ with:
+ working-directory: ./app
- name: yarn build
run: yarn build
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index e1ba063..4a10ff9 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -41,37 +41,52 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2.3.1
- - name: Install Node.js, NPM and Yarn
- env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- uses: actions/setup-node@v1.4.2
+ - name: install yarn dependencies in app/client using cache
+ uses: bahmutov/npm-install@v1.6.0
with:
- node-version: 14
+ working-directory: ./app/client
- - name: yarn install from npmjs registry
- env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- run: |
- npm config set registry https://registry.npmjs.org
- cd app/client
- yarn install --no-lockfile
- cd ..
- yarn install --no-lockfile
- cd ..
- yarn install --no-lockfile
+ - name: install yarn dependencies in ./ using cache
+ uses: bahmutov/npm-install@v1.6.0
+ with:
+ working-directory: ./
- - name: Configure private AWS npm registry and install packages from it
+ - name: install yarn dependencies in ./app using cache
+ uses: bahmutov/npm-install@v1.6.0
+ with:
+ working-directory: ./app
+
+ - name: yarn build
env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- if: ${{ failure() }}
- run: |
- npm config set registry https://packages.deskreen.com/
- npm set //packages.deskreen.com/:_authToken="${{ secrets.NPMRC_USER_TOKEN }}"
- npm config set always-auth true
- cd app/client
- yarn install --frozen-lockfile
- cd ../..
- yarn install --frozen-lockfile
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: yarn build
+
+ - name: yarn lint
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: yarn lint
+
+ - name: yarn tsc
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: yarn tsc
+
+ - name: yarn test
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: yarn test
+
+ - name: yarn build-ux
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: yarn build-ux
+
+ - name: yarn test-ux
+ uses: GabrielBB/xvfb-action@v1.2
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ run: yarn test-ux
- name: yarn package-ci
env:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 065a2dd..70525db 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -16,37 +16,20 @@ jobs:
- name: Check out Git repository
uses: actions/checkout@v2.3.1
- - name: Install Node.js, NPM and Yarn
- env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- uses: actions/setup-node@v1.4.2
+ - name: install yarn dependencies in app/client using cache
+ uses: bahmutov/npm-install@v1.6.0
with:
- node-version: 14
+ working-directory: ./app/client
- - name: yarn install from npmjs registry
- env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- run: |
- npm config set registry https://registry.npmjs.org
- cd app/client
- yarn install --no-lockfile
- cd ..
- yarn install --no-lockfile
- cd ..
- yarn install --no-lockfile
+ - name: install yarn dependencies in ./ using cache
+ uses: bahmutov/npm-install@v1.6.0
+ with:
+ working-directory: ./
- - name: Configure private AWS npm registry and install packages from it
- env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'
- if: ${{ failure() }}
- run: |
- npm config set registry https://packages.deskreen.com/
- npm set //packages.deskreen.com/:_authToken="${{ secrets.NPMRC_USER_TOKEN }}"
- npm config set always-auth true
- cd app/client
- yarn install --frozen-lockfile
- cd ../..
- yarn install --frozen-lockfile
+ - name: install yarn dependencies in ./app using cache
+ uses: bahmutov/npm-install@v1.6.0
+ with:
+ working-directory: ./app
# following step does code signing when `electron-builder --publish always` (look in package.json)
- name: yarn package-ci
diff --git a/app/api/config.ts b/app/api/config.ts
index de96847..3cc61ab 100644
--- a/app/api/config.ts
+++ b/app/api/config.ts
@@ -4,7 +4,7 @@ let protocol;
let port;
if (!host && !protocol && !port) {
- host = 'localhost';
+ host = '127.0.0.1';
protocol = 'http';
port = 3131; // TODO: read port from signaling server api
}
diff --git a/app/app.global.css b/app/app.global.css
index f722c23..aa0501a 100644
--- a/app/app.global.css
+++ b/app/app.global.css
@@ -143,6 +143,10 @@ body
left: -40px !important;
}
+div.class-allow-device-to-connect-alert {
+ z-index: 9999;
+}
+
/* ALLOW CONNECTION ALERT BLINK ANIMATION START */
div.class-allow-device-to-connect-alert
> div.bp3-alert-body
diff --git a/app/client/package.json b/app/client/package.json
index aa5c71e..75d4c9e 100644
--- a/app/client/package.json
+++ b/app/client/package.json
@@ -25,6 +25,7 @@
"react-reveal": "^1.2.2",
"react-scripts": "3.4.3",
"react-spinners": "^0.9.0",
+ "react-test-renderer": "^17.0.1",
"screenfull": "^5.0.2",
"shortid": "^2.2.15",
"socket.io-client": "^2.3.0",
diff --git a/app/client/sonar-project.properties b/app/client/sonar-project.properties
index db1b3a6..7486edd 100644
--- a/app/client/sonar-project.properties
+++ b/app/client/sonar-project.properties
@@ -1,7 +1,8 @@
sonar.projectKey=deskreen-viewer
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.sources=src
-sonar.coverage.exclusions=src/**/*.spec.ts,src/**/*.spec.tsx,src/**/*.test.ts,src/**/*.test.tsx,src/serviceWorker.ts,src/index.tsx
+sonar.cpd.exclusions=src/**/mocks/*,src/**/*.spec.ts,src/**/*.spec.tsx,src/**/*.test.ts,src/**/*.test.tsx,src/serviceWorker.ts,src/index.tsx
+sonar.coverage.exclusions=src/**/mocks/*,src/**/*.spec.ts,src/**/*.spec.tsx,src/**/*.test.ts,src/**/*.test.tsx,src/serviceWorker.ts,src/index.tsx
sonar.host.url=http://localhost:9000
sonar.login=e3b5f73b8778290f7074c40a4159c32b7f15a8e6
sonar.exclusions=src/serviceWorker.ts,node_modules/**
diff --git a/app/client/src/App.tsx b/app/client/src/App.tsx
index d9365b7..00f57d5 100644
--- a/app/client/src/App.tsx
+++ b/app/client/src/App.tsx
@@ -1,332 +1,9 @@
-import React, {
- useEffect,
- useState,
- useRef,
- useContext,
- useCallback,
-} from 'react';
-import { useTranslation } from 'react-i18next';
-import i18n from './config/i18n';
-import { H3, Position, Toaster } from '@blueprintjs/core';
-import { Grid, Row, Col } from 'react-flexbox-grid';
-import { findDOMNode } from 'react-dom';
-import ReactPlayer from 'react-player';
-import screenfull from 'screenfull';
-import Crypto from './utils/crypto';
-import './App.css';
-import PeerConnection from './features/PeerConnection';
-import VideoAutoQualityOptimizer from './features/VideoAutoQualityOptimizer';
-import ConnectingIndicator from './components/ConnectingIndicator';
-import MyDeviceInfoCard from './components/MyDeviceInfoCard';
-import {
- DARK_UI_BACKGROUND,
- LIGHT_UI_BACKGROUND,
-} from './constants/styleConstants';
-import { AppContext } from './providers/AppContextProvider';
-import PlayerControlPanel from './components/PlayerControlPanel';
-import { VideoQuality } from './features/PeerConnection/VideoQualityEnum';
-import { REACT_PLAYER_WRAPPER_ID } from './constants/appConstants';
-import { TFunction } from 'i18next';
-import ErrorDialog from './components/ErrorDialog';
-import { ErrorMessage } from './components/ErrorDialog/ErrorMessageEnum';
-
-const Fade = require('react-reveal/Fade');
-const Slide = require('react-reveal/Slide');
-
-function getPromptContent(step: number, t: TFunction) {
- switch (step) {
- case 1:
- return (
-
- {t(
- 'Waiting for user to click ALLOW button on screen sharing device...'
- )}
-
- );
- case 2:
- return Connected!
;
- case 3:
- return (
-
- {t(
- 'Wating for user to select source to share from screen sharing device...'
- )}
-
- );
- default:
- return Error occured :(
;
- }
-}
+import React from 'react';
+import MainView from './containers/MainView';
function App() {
- const { t } = useTranslation();
- const { isDarkTheme, setIsDarkThemeHook } = useContext(AppContext);
- const [isErrorDialogOpen, setIsErrorDialogOpen] = useState(false);
-
- const [toaster, setToaster] = useState();
-
- const refHandlers = {
- toaster: (ref: Toaster) => {
- setToaster(ref);
- },
- };
-
- const player = useRef(null);
- const [promptStep, setPromptStep] = useState(1);
- const [dialogErrorMessage, setDialogErrorMessage] = useState(
- ErrorMessage.UNKNOWN_ERROR
- );
- const [connectionIconType, setConnectionIconType] = useState<
- 'feed' | 'feed-subscribed'
- >('feed');
- const [myDeviceDetails, setMyDeviceDetails] = useState({
- myIP: '',
- myOS: '',
- myDeviceType: '',
- myBrowser: '',
- });
-
- const [playing, setPlaying] = useState(true);
- const [isFullScreenOn, setIsFullScreenOn] = useState(false);
- const [url, setUrl] = useState();
- const [screenSharingSourceType, setScreenSharingSourceType] = useState<
- 'screen' | 'window'
- >('screen');
- const [isWithControls, setIsWithControls] = useState(!screenfull.isEnabled);
- const [isShownTextPrompt, setIsShownTextPrompt] = useState(false);
- const [isShownSpinnerIcon, setIsShownSpinnerIcon] = useState(false);
- const [spinnerIconType, setSpinnerIconType] = useState<
- 'desktop' | 'application'
- >('desktop');
- const [videoQuality, setVideoQuality] = useState(
- VideoQuality.Q_AUTO
- );
- const [peer, setPeer] = useState();
-
- const changeLanguage = (lng: string) => {
- i18n.changeLanguage(lng);
- };
-
- useEffect(() => {
- if (!peer) return;
- if (!peer.isStreamStarted) return;
- peer.setVideoQuality(videoQuality);
- }, [videoQuality, peer]);
-
- useEffect(() => {
- document.body.style.backgroundColor = isDarkTheme
- ? DARK_UI_BACKGROUND
- : LIGHT_UI_BACKGROUND;
- }, [isDarkTheme]);
-
- useEffect(() => {
- if (!peer) {
- const _peer = new PeerConnection(
- setUrl,
- new Crypto(),
- new VideoAutoQualityOptimizer(),
- isDarkTheme,
- setMyDeviceDetails,
- () => {
- setConnectionIconType('feed-subscribed');
-
- setIsShownTextPrompt(false);
- setIsShownTextPrompt(true);
- setPromptStep(2);
-
- setTimeout(() => {
- setIsShownTextPrompt(false);
- setIsShownTextPrompt(true);
- setPromptStep(3);
- }, 2000);
- },
- setScreenSharingSourceType,
- setIsDarkThemeHook,
- changeLanguage,
- setDialogErrorMessage,
- setIsErrorDialogOpen
- );
-
- setPeer(_peer);
-
- setTimeout(() => {
- setIsShownTextPrompt(true);
- }, 100);
- }
- }, [setIsDarkThemeHook, isDarkTheme, peer]);
-
- useEffect(() => {
- // infinite use effect
- setTimeout(() => {
- setIsShownSpinnerIcon(!isShownSpinnerIcon);
- setSpinnerIconType(
- spinnerIconType === 'desktop' ? 'application' : 'desktop'
- );
- }, 1500);
- }, [isShownSpinnerIcon, spinnerIconType]);
-
- const handlePlayPause = useCallback(() => {
- setPlaying(!playing);
- }, [playing]);
-
- useEffect(() => {
- if (url !== undefined) {
- setTimeout(() => {
- // @ts-ignore
- document.querySelector('.container > .react-reveal').style.display =
- 'none';
- }, 1000);
- }
- }, [url]);
-
- useEffect(() => {
- if (promptStep === 3) {
- // start infinite use effect
- setIsShownSpinnerIcon(true);
- }
- }, [promptStep]);
-
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {getPromptContent(promptStep, t)}
-
-
-
-
-
-
-
-
-
-
-
-
-
setIsWithControls(isEnabled)}
- isDefaultPlayerTurnedOn={isWithControls}
- handleClickFullscreen={() => {
- if (!screenfull.isEnabled) return;
- // @ts-ignore Property 'request' does not exist on type '{ isEnabled: false; }'.
- screenfull.request(findDOMNode(player.current));
- setIsFullScreenOn(!isFullScreenOn);
- }}
- handleClickPlayPause={handlePlayPause}
- isPlaying={playing}
- setVideoQuality={setVideoQuality}
- selectedVideoQuality={videoQuality}
- screenSharingSourceType={screenSharingSourceType}
- toaster={toaster}
- />
-
-
-
-
-
+
);
}
diff --git a/app/client/src/api/config.ts b/app/client/src/api/config.ts
index 0584c2d..ffe1463 100644
--- a/app/client/src/api/config.ts
+++ b/app/client/src/api/config.ts
@@ -1,4 +1,3 @@
-/* istanbul ignore file */
let host;
let protocol;
let port;
diff --git a/app/client/src/api/generator.spec.ts b/app/client/src/api/generator.spec.ts
new file mode 100644
index 0000000..d0dceba
--- /dev/null
+++ b/app/client/src/api/generator.spec.ts
@@ -0,0 +1,34 @@
+import generator from './generator';
+import { TEST_PORT, TEST_HOST, TEST_PROTOCOL } from './mocks/generatorTestVariables';
+
+// how to use local variables in jest mock to get rid of hoisting mocks to top most code block:
+//stackoverflow.com/questions/44649699/service-mocked-with-jest-causes-the-module-factory-of-jest-mock-is-not-allowe
+jest.mock('./config', () => {
+ const generatorTestVariables = require('./mocks/generatorTestVariables');
+
+ return {
+ host: generatorTestVariables.TEST_HOST,
+ protocol: generatorTestVariables.TEST_PROTOCOL,
+ port: generatorTestVariables.TEST_PORT,
+ };
+});
+
+
+describe('generator.ts', () => {
+ afterEach(() => {
+ jest.clearAllMocks();
+ jest.restoreAllMocks();
+ });
+
+ describe('when generator() is called properly', () => {
+ it('should produce correct string', () => {
+ const roomID = '333';
+
+ const result = generator(roomID);
+
+ expect(result).toMatch(
+ `${TEST_PROTOCOL}://${TEST_HOST}:${TEST_PORT}/${roomID}`
+ );
+ });
+ });
+});
diff --git a/app/client/src/api/generator.ts b/app/client/src/api/generator.ts
index 4debac7..1788bc4 100644
--- a/app/client/src/api/generator.ts
+++ b/app/client/src/api/generator.ts
@@ -1,4 +1,3 @@
-/* istanbul ignore file */
import config from './config';
export default (resourceName = '') => {
diff --git a/app/client/src/api/mocks/generatorTestVariables.ts b/app/client/src/api/mocks/generatorTestVariables.ts
new file mode 100644
index 0000000..f2e31ae
--- /dev/null
+++ b/app/client/src/api/mocks/generatorTestVariables.ts
@@ -0,0 +1,3 @@
+export const TEST_PORT = '3232';
+export const TEST_HOST = '123.123.123.123';
+export const TEST_PROTOCOL = 'http';
diff --git a/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.spec.tsx b/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.spec.tsx
new file mode 100644
index 0000000..d68cb0f
--- /dev/null
+++ b/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.spec.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+import renderer from 'react-test-renderer';
+import LoadingSharingIcon from './LoadingSharingIcon';
+
+jest.useFakeTimers();
+
+it('should match exact snapshot', () => {
+ const subject = renderer.create(
+ <>
+
+ >
+ );
+
+ expect(subject).toMatchSnapshot();
+});
diff --git a/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.tsx b/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.tsx
new file mode 100644
index 0000000..5517664
--- /dev/null
+++ b/app/client/src/components/ConnectingIndicator/LoadingSharingIcon.tsx
@@ -0,0 +1,65 @@
+import React, { useContext } from 'react';
+import { Icon } from '@blueprintjs/core';
+import { Col, Row } from 'react-flexbox-grid';
+import PropagateLoader from 'react-spinners/PropagateLoader';
+import { AppContext } from '../../providers/AppContextProvider';
+
+const Fade = require('react-reveal/Fade');
+
+interface SelectSharingIconProps {
+ loadingSharingIconType: LoadingSharingIconType;
+ isShownLoadingSharingIcon: boolean;
+}
+
+function LoadingSharingIcon(props: SelectSharingIconProps) {
+ const { isDarkTheme } = useContext(AppContext);
+
+ const {
+ loadingSharingIconType: selectingSharingIconType,
+ isShownLoadingSharingIcon: isShownSelectingSharingIcon,
+ } = props;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default LoadingSharingIcon;
diff --git a/app/client/src/components/ConnectingIndicator/SelectSharingIcon.tsx b/app/client/src/components/ConnectingIndicator/SelectSharingIcon.tsx
deleted file mode 100644
index 33bbf60..0000000
--- a/app/client/src/components/ConnectingIndicator/SelectSharingIcon.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import React, { useContext } from 'react';
-import { Icon } from '@blueprintjs/core';
-import { Col, Row } from 'react-flexbox-grid';
-import PropagateLoader from 'react-spinners/PropagateLoader';
-import { AppContext } from '../../providers/AppContextProvider';
-
-const Fade = require('react-reveal/Fade');
-
-interface SelectSharingIconProps {
- selectingSharingIconType: 'desktop' | 'application';
- isShownSelectingSharingIcon: boolean;
-}
-
-function SelectSharingIcon(props: SelectSharingIconProps) {
- const { isDarkTheme } = useContext(AppContext);
-
- const { selectingSharingIconType, isShownSelectingSharingIcon } = props;
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
-
-export default SelectSharingIcon;
diff --git a/app/client/src/components/ConnectingIndicator/__snapshots__/LoadingSharingIcon.spec.tsx.snap b/app/client/src/components/ConnectingIndicator/__snapshots__/LoadingSharingIcon.spec.tsx.snap
new file mode 100644
index 0000000..3b04745
--- /dev/null
+++ b/app/client/src/components/ConnectingIndicator/__snapshots__/LoadingSharingIcon.spec.tsx.snap
@@ -0,0 +1,93 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should match exact snapshot 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/app/client/src/components/ConnectingIndicator/index.tsx b/app/client/src/components/ConnectingIndicator/index.tsx
index 443f094..0b19a7d 100644
--- a/app/client/src/components/ConnectingIndicator/index.tsx
+++ b/app/client/src/components/ConnectingIndicator/index.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import { Text } from '@blueprintjs/core';
import { Row } from 'react-flexbox-grid';
import ConnectingIndicatorIcon from './ConnectingIndicatorIcon';
-import SelectSharingIcon from './SelectSharingIcon';
+import LoadingSharingIcon from './LoadingSharingIcon';
const basePulsingCircleStyles = {
borderRadius: '100%',
@@ -18,9 +18,9 @@ const basePulsingCircleStyles = {
function getConnectingStepContent(
currentStep: number,
- connectionIconType: 'feed' | 'feed-subscribed',
- selectingSharingIconType: 'desktop' | 'application',
- isShownSelectingSharingIcon: boolean,
+ connectionIconType: ConnectionIconType,
+ loadingSharingIconType: LoadingSharingIconType,
+ isShownLoadingSharingIcon: boolean,
) {
const pulsingCircle1Styles = {
@@ -68,9 +68,9 @@ function getConnectingStepContent(
);
case 3:
return (
-
);
default:
@@ -80,9 +80,9 @@ function getConnectingStepContent(
interface ConnectingIndicatorProps {
currentStep: number;
- connectionIconType: 'feed' | 'feed-subscribed';
+ connectionIconType: ConnectionIconType;
isShownSelectingSharingIcon: boolean;
- selectingSharingIconType: 'desktop' | 'application';
+ selectingSharingIconType: LoadingSharingIconType;
}
function ConnectingIndicator(props: ConnectingIndicatorProps) {
diff --git a/app/client/src/components/ErrorDialog/ErrorMessageEnum.ts b/app/client/src/components/ErrorDialog/ErrorMessageEnum.ts
index daa64f4..a6b296a 100644
--- a/app/client/src/components/ErrorDialog/ErrorMessageEnum.ts
+++ b/app/client/src/components/ErrorDialog/ErrorMessageEnum.ts
@@ -1,6 +1,6 @@
export enum ErrorMessage {
UNKNOWN_ERROR = 'An unknonw error uccured.',
DENY_TO_CONNECT = 'You were not allowed to connect.',
- DICONNECTED = 'You were disconnected.',
+ DISCONNECTED = 'You were disconnected.',
NOT_ALLOWED = 'You were not allowed to connect.',
}
diff --git a/app/client/src/components/PlayerControlPanel/__snapshots__/index.spec.tsx.snap b/app/client/src/components/PlayerControlPanel/__snapshots__/index.spec.tsx.snap
new file mode 100644
index 0000000..48178af
--- /dev/null
+++ b/app/client/src/components/PlayerControlPanel/__snapshots__/index.spec.tsx.snap
@@ -0,0 +1,393 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should match exact snapshot 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/app/client/src/components/PlayerControlPanel/handlePlayerToggleFullscreen.ts b/app/client/src/components/PlayerControlPanel/handlePlayerToggleFullscreen.ts
new file mode 100644
index 0000000..f4e4d50
--- /dev/null
+++ b/app/client/src/components/PlayerControlPanel/handlePlayerToggleFullscreen.ts
@@ -0,0 +1,33 @@
+/* istanbul ignore file */
+
+// IMPORTANT! leave upper blank line so this file is ignored for coverage!!! More on this issue here
+// https://github.com/facebook/create-react-app/issues/6106#issuecomment-550076629
+import { REACT_PLAYER_WRAPPER_ID } from "../../constants/appConstants";
+
+export default () => {
+ const player = document.querySelector(
+ `#${REACT_PLAYER_WRAPPER_ID} > video`
+ );
+ if (!player) return;
+ // @ts-ignore
+ if (player.requestFullScreen) {
+ // @ts-ignore
+ player.requestFullScreen();
+ // @ts-ignore
+ } else if (player.webkitRequestFullScreen) {
+ // @ts-ignore
+ player.webkitRequestFullScreen();
+ // @ts-ignore
+ } else if (player.mozRequestFullScreen) {
+ // @ts-ignore
+ player.mozRequestFullScreen();
+ // @ts-ignore
+ } else if (player.msRequestFullscreen) {
+ // @ts-ignore
+ player.msRequestFullscreen();
+ // @ts-ignore
+ } else if (player.webkitEnterFullscreen) {
+ // @ts-ignore
+ player.webkitEnterFullscreen(); //for iphone this code worked
+ }
+};
diff --git a/app/client/src/components/PlayerControlPanel/index.spec.tsx b/app/client/src/components/PlayerControlPanel/index.spec.tsx
new file mode 100644
index 0000000..8ac582a
--- /dev/null
+++ b/app/client/src/components/PlayerControlPanel/index.spec.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+import renderer from 'react-test-renderer';
+import PlayerControlPanel from '.';
+import { VideoQuality } from '../../features/VideoAutoQualityOptimizer/VideoQualityEnum';
+
+jest.useFakeTimers();
+
+it('should match exact snapshot', () => {
+ const subject = renderer.create(
+ <>
+ {}}
+ isPlaying
+ isDefaultPlayerTurnedOn
+ handleClickFullscreen={() => {}}
+ handleClickPlayPause={() => {}}
+ setVideoQuality={() => {}}
+ selectedVideoQuality={VideoQuality.Q_100_PERCENT}
+ screenSharingSourceType={'screen'}
+ toaster={undefined}
+ />
+ >
+ );
+ expect(subject).toMatchSnapshot();
+});
diff --git a/app/client/src/components/PlayerControlPanel/index.tsx b/app/client/src/components/PlayerControlPanel/index.tsx
index 1479367..a09a280 100644
--- a/app/client/src/components/PlayerControlPanel/index.tsx
+++ b/app/client/src/components/PlayerControlPanel/index.tsx
@@ -1,9 +1,8 @@
-import React, {
- useEffect,
- useMemo,
- useState,
- useCallback,
-} from 'react';
+/* istanbul ignore file */
+
+// IMPORTANT! leave upper blank line so this file is ignored for coverage!!! More on this issue here
+// https://github.com/facebook/create-react-app/issues/6106#issuecomment-550076629
+import React, { useEffect, useMemo, useState, useCallback } from 'react';
import {
Alignment,
Button,
@@ -26,8 +25,9 @@ import DeskreenIconPNG from '../../images/deskreen_logo_128x128.png';
import RedHeartTwemojiPNG from '../../images/red_heart_2764_twemoji_120x120.png';
import { Col, Row } from 'react-flexbox-grid';
import screenfull from 'screenfull';
-import { VideoQuality } from '../../features/PeerConnection/VideoQualityEnum';
-import { REACT_PLAYER_WRAPPER_ID } from '../../constants/appConstants';
+import { VideoQuality } from '../../features/VideoAutoQualityOptimizer/VideoQualityEnum';
+import handlePlayerToggleFullscreen from './handlePlayerToggleFullscreen';
+import initScreenfullOnChange from './initScreenfullOnChange';
const videoQualityButtonStyle: React.CSSProperties = {
width: '100%',
@@ -42,12 +42,11 @@ interface PlayerControlPanelProps {
handleClickPlayPause: () => void;
setVideoQuality: (q: VideoQuality) => void;
selectedVideoQuality: VideoQuality;
- screenSharingSourceType: 'screen' | 'window';
+ screenSharingSourceType: ScreenSharingSourceType;
toaster: undefined | Toaster;
}
function PlayerControlPanel(props: PlayerControlPanelProps) {
-
const {
isPlaying,
onSwitchChangedCallback,
@@ -65,40 +64,11 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {
const [isFullScreenOn, setIsFullScreenOn] = useState(false);
useEffect(() => {
- if (!screenfull.isEnabled) return;
- // @ts-ignore
- screenfull.on('change', () => {
- // @ts-ignore
- setIsFullScreenOn(screenfull.isFullscreen);
- });
+ initScreenfullOnChange(setIsFullScreenOn);
}, []);
const handleClickFullscreenWhenDefaultPlayerIsOn = useCallback(() => {
- const player = document.querySelector(
- `#${REACT_PLAYER_WRAPPER_ID} > video`
- );
- if (!player) return;
- // @ts-ignore
- if (player.requestFullScreen) {
- // @ts-ignore
- player.requestFullScreen();
- // @ts-ignore
- } else if (player.webkitRequestFullScreen) {
- // @ts-ignore
- player.webkitRequestFullScreen();
- // @ts-ignore
- } else if (player.mozRequestFullScreen) {
- // @ts-ignore
- player.mozRequestFullScreen();
- // @ts-ignore
- } else if (player.msRequestFullscreen) {
- // @ts-ignore
- player.msRequestFullscreen();
- // @ts-ignore
- } else if (player.webkitEnterFullscreen) {
- // @ts-ignore
- player.webkitEnterFullscreen(); //for iphone this code worked
- }
+ handlePlayerToggleFullscreen();
}, []);
return (
@@ -113,7 +83,12 @@ function PlayerControlPanel(props: PlayerControlPanelProps) {