Skip to content

Commit

Permalink
Remove gh-pages from Player (#20)
Browse files Browse the repository at this point in the history
* Remove gh-pages from Player

It is no longer in use

* Refactor web test runner login to use Auth Module (#23)

* Try logging in with auth module instead

* Reduce concurrency in web-test-runner to 1 to pass more test. (Storage issue in auth module?)

* Fix tests

* Set active player to undefined when re-configuring players.

* Remove debug log

---------

Co-authored-by: Jeremy Karlsson <[email protected]>
  • Loading branch information
osmestad and enjikaka authored Jan 23, 2024
1 parent 13218bb commit eee5b57
Show file tree
Hide file tree
Showing 20 changed files with 65 additions and 300 deletions.
1 change: 0 additions & 1 deletion packages/player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"bowser": "^2.11.0",
"cypress": "^13.6.3",
"esbuild": "^0.19.0",
"gh-pages": "^5.0.0",
"idb-keyval": "^6.2.1",
"js-levenshtein": "^1.1.6",
"mux.js": "^6.2.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/player/src/api/event/device-change.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { OutputDevice } from '../../internal/output-devices';
import { trueTime } from '../../internal/true-time';
import { credentialsProvider } from '../../test-helpers';

import { deviceChange } from './device-change';

await trueTime.synchronize();
Player.setCredentialsProvider(credentialsProvider);

beforeEach(async () => {
Player.setCredentialsProvider(credentialsProvider);

await Player.load(
{
productId: '141120674',
Expand Down
9 changes: 2 additions & 7 deletions packages/player/src/event-bus.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,20 @@ import { expect } from '@esm-bundle/chai';

import { events } from './event-bus';
import { PlayerError } from './internal/index';
import { trueTime } from './internal/true-time';
import { credentialsProvider, waitForEvent } from './test-helpers';

import * as Player from './index';

describe('eventBus', () => {
beforeEach(async () => {
await trueTime.synchronize();
});
Player.setCredentialsProvider(credentialsProvider);

describe('eventBus', () => {
it('playback engine sends events through the bus', async () => {
const mediaProductTransitionEvents = [];

events.addEventListener('media-product-transition', e =>
mediaProductTransitionEvents.push(e),
);

Player.setCredentialsProvider(credentialsProvider);

await Player.load(
{
productId: '141120674',
Expand Down
21 changes: 7 additions & 14 deletions packages/player/src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { expect } from '@esm-bundle/chai';

import * as Config from './config';
import { trueTime } from './internal/true-time';
import { credentialsProvider, mockNativePlayer } from './test-helpers';

import * as Player from './index';

await trueTime.synchronize();
Player.setCredentialsProvider(credentialsProvider);

describe('bootstrap', () => {
it('enables output devices if options.outputDevices is true', () => {
Expand Down Expand Up @@ -35,7 +34,7 @@ describe('getMediaElement', () => {
],
});

Player.setCredentialsProvider(credentialsProvider);
Player.setStreamingWifiAudioQuality('LOW');

await Player.load(
{
Expand All @@ -46,12 +45,14 @@ describe('getMediaElement', () => {
},
0,
);

const mediaElement = Player.getMediaElement();

expect(mediaElement).to.be.instanceOf(HTMLMediaElement);
});

it('returns the mediaElement value on browser player', async () => {
/* To enalbe this test we need another test user with HTMLMediaElement compatible streaming configuration (MP3 Preview?). */
it.skip('returns the mediaElement value on browser player', async () => {
Player.bootstrap({
outputDevices: false,
players: [
Expand All @@ -63,6 +64,8 @@ describe('getMediaElement', () => {
],
});

Player.setStreamingWifiAudioQuality('LOW');

await Player.load(
{
productId: '141120674',
Expand Down Expand Up @@ -92,16 +95,6 @@ describe('getMediaElement', () => {
],
});

await Player.load(
{
productId: '141120674',
productType: 'track',
sourceId: 'tidal-player-tests',
sourceType: 'tidal-player-tests',
},
0,
);

const mediaElement = Player.getMediaElement();

expect(mediaElement).to.equal(null);
Expand Down
2 changes: 2 additions & 0 deletions packages/player/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export function getMediaElement(): HTMLMediaElement | null {
* @param {Options} options
*/
export function bootstrap(options: Options) {
playerState.activePlayer = undefined;

if (options.outputDevices === true) {
Config.update({ outputDevicesEnabled: true });
}
Expand Down
10 changes: 3 additions & 7 deletions packages/player/src/internal/beacon/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { expect } from '@esm-bundle/chai';
import * as sinon from 'sinon';

import { setCredentialsProvider } from '../../api/index';
import * as Player from '../../index';
import { credentialsProvider } from '../../test-helpers';
import type { StreamingSessionStart } from '../event-tracking/streaming-metrics/streaming-session-start';
import { trueTime } from '../true-time';

import { commit } from './index';

describe('commit', () => {
beforeEach(async () => {
await trueTime.synchronize();
setCredentialsProvider(credentialsProvider);
});
Player.setCredentialsProvider(credentialsProvider);

describe('commit', () => {
const worker = sinon.createStubInstance(Worker);

const mockedPromisedEvent = Promise.resolve({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { credentialsProvider, waitFor } from '../../test-helpers';
import { trueTime } from '../true-time';
import { waitFor } from '../../test-helpers';

import { getAssetPosition } from './get-asset-position';

describe('getAssetPosition', () => {
beforeEach(async () => {
await trueTime.synchronize();
});

it('returns 0 if there is no active player', () => {
const playerPosition = getAssetPosition();

expect(playerPosition).to.equal(0);
});

it('return currentTime if there is a player', async () => {
Player.setCredentialsProvider(credentialsProvider);

await Player.load(
{
productId: '141120674',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { trueTime } from '../../internal/true-time';
import { credentialsProvider, waitFor } from '../../test-helpers';
import { waitFor } from '../../test-helpers';

import { getMediaProduct } from './get-media-product';

describe('getMediaProduct', () => {
beforeEach(async () => {
await trueTime.synchronize();
await Player.reset();
});

Expand All @@ -22,8 +20,6 @@ describe('getMediaProduct', () => {
this.timeout(10000);

const test = async () => {
Player.setCredentialsProvider(credentialsProvider);

console.debug('loading');
await Player.load(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@ import { expect } from '@esm-bundle/chai';
import * as Player from '../../index';
import { outputDevices } from '../../internal/output-devices';
import { credentialsProvider } from '../../test-helpers';
import { trueTime } from '../true-time';

import { getOutputDevices } from './get-output-devices';

Player.setCredentialsProvider(credentialsProvider);

describe('getOutputDevices', () => {
beforeEach(async () => {
await trueTime.synchronize();

Player.setCredentialsProvider(credentialsProvider);

// Output devices is reported by the player, thus need one to
await Player.load(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { credentialsProvider, waitFor } from '../../test-helpers';
import { trueTime } from '../true-time';
import { waitFor } from '../../test-helpers';

import { getPlaybackContext } from './get-playback-context';

describe('getPlaybackContext', () => {
beforeEach(async () => {
await trueTime.synchronize();
});

it('returns undefined if there is no active player', () => {
const activePlaybackContext = getPlaybackContext();

expect(activePlaybackContext).to.equal(undefined);
});

it('returns the playback context', async () => {
Player.setCredentialsProvider(credentialsProvider);
Player.setStreamingWifiAudioQuality('LOW');

console.debug('load');
await Player.load(
{
productId: '141120674',
Expand All @@ -32,10 +25,8 @@ describe('getPlaybackContext', () => {
0,
);

console.debug('play');
await Player.play();

console.debug('waitFor 2s');
await waitFor(2000);

const activePlaybackContext = getPlaybackContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { credentialsProvider, waitFor } from '../../test-helpers';
import { trueTime } from '../true-time';
import { waitFor } from '../../test-helpers';

import { getPlaybackState } from './get-playback-state';

describe('getPlaybackState', () => {
beforeEach(async () => {
await trueTime.synchronize();
});

it('returns IDLE if there is no active player', () => {
const activeState = getPlaybackState();

expect(activeState).to.equal('IDLE');
});

it('return NOT_PLAYING when a media product is loaded', async () => {
Player.setCredentialsProvider(credentialsProvider);
Player.setStreamingWifiAudioQuality('LOW');

await Player.load(
Expand All @@ -35,7 +29,6 @@ describe('getPlaybackState', () => {
});

it('return PLAYING when a media product is playing', async () => {
Player.setCredentialsProvider(credentialsProvider);
Player.setStreamingWifiAudioQuality('LOW');

await Player.load(
Expand Down
9 changes: 2 additions & 7 deletions packages/player/src/internal/handlers/load.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { expect } from '@esm-bundle/chai';

import * as Player from '../../index';
import { trueTime } from '../../internal/true-time';
import {
credentialsProvider,
getPreloadedStreamingSessionId,
waitFor,
} from '../../test-helpers';

describe('load', () => {
beforeEach(async () => {
await trueTime.synchronize();
});
Player.setCredentialsProvider(credentialsProvider);

describe('load', () => {
it('re-uses a next for loading if it is the same media product', async () => {
Player.setCredentialsProvider(credentialsProvider);

await Player.load(
{
productId: '1766030',
Expand Down
9 changes: 2 additions & 7 deletions packages/player/src/internal/handlers/set-next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@ import { expect } from '@esm-bundle/chai';
import * as Player from '../../index';
import type { MediaProduct } from '../../index';
import { waitFor } from '../../internal/helpers/wait-for';
import { trueTime } from '../../internal/true-time';
import { credentialsProvider, waitForEvent } from '../../test-helpers';

describe('nextHandler', () => {
beforeEach(async () => {
await trueTime.synchronize();

Player.setCredentialsProvider(credentialsProvider);
});
Player.setCredentialsProvider(credentialsProvider);

describe('nextHandler', () => {
it('doesnt preload if no mediaProduct', async () => {
await Player.load(
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { expect } from '@esm-bundle/chai';

import { credentialsProvider } from '../../test-helpers';
import { trueTime } from '../true-time';

import { fetchPlaybackInfo } from './playback-info-resolver';

await trueTime.synchronize();

describe('playbackInfoResolver', () => {
it('fetches playback info if there is only clientId defined, gets preview', async () => {
const { clientId } = await credentialsProvider.getCredentials();
Expand Down
5 changes: 1 addition & 4 deletions packages/player/src/internal/output-devices.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import {
findOutputType,
getOutputDeviceByName,
} from './output-devices';
import { trueTime } from './true-time';

await trueTime.synchronize();
Player.setCredentialsProvider(credentialsProvider);

beforeEach(async () => {
Player.setCredentialsProvider(credentialsProvider);

await Player.load(
{
productId: '141120674',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,10 @@ import type { MediaProductTransition } from '../../api/event/media-product-trans
import { events } from '../../event-bus';
import * as Player from '../../index';
import { playerState } from '../../player/state';
import { credentialsProvider, waitForEvent } from '../../test-helpers';
import { waitForEvent } from '../../test-helpers';
import { waitFor } from '../helpers/wait-for';
import { trueTime } from '../true-time';

describe('ConnectionHandler', () => {
beforeEach(async () => {
await trueTime.synchronize();

Player.setCredentialsProvider(credentialsProvider);
});

it('reloads the mediaProduct when connection was lost and player stopped playing', async () => {
await Player.load(
{
Expand Down
1 change: 0 additions & 1 deletion packages/player/src/internal/services/pushkin.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import { assert } from '@esm-bundle/chai';
import { credentialsProvider } from '../../test-helpers';

import { fetchWebSocketURL, socketOpen } from './pushkin';
Expand Down
Loading

0 comments on commit eee5b57

Please sign in to comment.