Skip to content

Commit

Permalink
fix(e2e): fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonLantukh committed May 8, 2023
1 parent 759ed17 commit 4fdfa79
Show file tree
Hide file tree
Showing 10 changed files with 241 additions and 494 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeceptjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x]
node-version: [18.x]
config: [desktop, mobile]

steps:
Expand All @@ -21,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
yarn
npm install wait-on -g
yarn global add wait-on
- name: Start preview server
run: yarn start:test &
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lhci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 16.x
node-version: 18.x
- name: yarn install, build
run: |
yarn install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: [pull_request]

jobs:
lint:
runs-on: macos-latest
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on: [pull_request]

jobs:
build:
runs-on: macos-latest
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v1
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "JW Player",
"private": true,
"engines": {
"node": ">=16.0.0"
"node": ">=18.0.0"
},
"scripts": {
"prepare": "husky install",
Expand Down Expand Up @@ -39,6 +39,7 @@
"deploy:github": "node ./scripts/deploy-github.js"
},
"dependencies": {
"@codeceptjs/allure-legacy": "^1.0.2",
"@inplayer-org/inplayer.js": "^3.13.7",
"classnames": "^2.3.1",
"date-fns": "^2.28.0",
Expand Down Expand Up @@ -86,7 +87,7 @@
"@vitejs/plugin-react": "^1.0.7",
"@vitest/coverage-c8": "^0.25.7",
"allure-commandline": "^2.17.2",
"codeceptjs": "3.3.0",
"codeceptjs": "3.4.1",
"confusing-browser-globals": "^1.0.10",
"depcheck": "^1.4.3",
"eslint": "^7.31.0",
Expand All @@ -101,7 +102,7 @@
"lint-staged": "^10.5.4",
"luxon": "^3.2.1",
"npm-run-all": "^4.1.5",
"playwright": "^1.25.2",
"playwright": "1.33.0",
"postcss": "^8.3.5",
"postcss-import": "^14.0.2",
"postcss-scss": "^4.0.4",
Expand Down Expand Up @@ -142,4 +143,4 @@
"flat": "^5.0.1",
"json5": "^2.2.2"
}
}
}
2 changes: 2 additions & 0 deletions test-e2e/codecept.desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.config = {
show: !!process.env.SHOW,
channel: 'chrome',
locale: 'en-US',
keepCookies: false,
},
},
include: {
Expand All @@ -38,6 +39,7 @@ exports.config = {
},
allure: {
enabled: true,
require: '@codeceptjs/allure-legacy',
},
},
};
2 changes: 2 additions & 0 deletions test-e2e/codecept.mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exports.config = {
show: !!process.env.SHOW,
channel: 'chrome',
emulate: devices['Pixel 5'],
keepCookies: false,
},
},
include: {
Expand All @@ -39,6 +40,7 @@ exports.config = {
},
allure: {
enabled: true,
require: '@codeceptjs/allure-legacy',
},
},
};
11 changes: 6 additions & 5 deletions test-e2e/tests/watch_history/logged_in_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,18 @@ function runTestSuite(config: typeof testConfigs.svod, configNoWatchlist: typeof
I.dontSee(constants.continueWatchingShelfTitle);

await registerOrLogin(I);
I.see(constants.continueWatchingShelfTitle);

const continueWatchingShelfXPath = makeShelfXpath(ShelfId.continueWatching);
I.clickHome();
I.waitForText(constants.continueWatchingShelfTitle, normalTimeout);

await within(continueWatchingShelfXPath, async () => {
await within(makeShelfXpath(ShelfId.continueWatching), async () => {
I.see(videoTitle);
I.see('10 min');
});

await I.openVideoCard(videoTitle, ShelfId.continueWatching, false, async (locator) => await checkProgress(I, locator, (80 / videoLength) * 100));
const selector = `${makeShelfXpath(ShelfId.continueWatching)}//div[@aria-label="Play ${videoTitle}"]`;
await checkProgress(I, selector, (80 / videoLength) * 100);

I.click(selector);
await I.waitForPlayerPlaying(videoTitle);

await checkElapsed(I, 1, 20);
Expand Down
21 changes: 0 additions & 21 deletions test-e2e/utils/password_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,20 @@ async function testPasswordToggling(I: CodeceptJS.I, name = 'password') {
I.fillField({ name }, 'password123!');

await checkPasswordType(I, name, 'password');
// When the input type is password, you should not be able to copy the password value
await tryToCopyPassword(I, name, '');

I.click(`input[name="${name}"]+div div[aria-label="View password"]`);
await checkPasswordType(I, name, 'text');
// When the input type is text, you should be able to copy the password value
await tryToCopyPassword(I, name, 'password123!');

await I.writeClipboard('dummy');

I.click(`input[name="${name}"]+div div[aria-label="Hide password"]`);
await checkPasswordType(I, name, 'password');

// Password should not be able to be copied again and whatever is in the clipboard should stay in the clipboard
await tryToCopyPassword(I, name, 'dummy');
}

async function checkPasswordType(I: CodeceptJS.I, name, expectedType) {
assert.strictEqual(await I.grabAttributeFrom(`input[name="${name}"]`, 'type'), expectedType);
}

async function tryToCopyPassword(I: CodeceptJS.I, name, expectedResult) {
// Use Ctrl + A, Ctrl + C to highlight and copy the password
I.click(`input[name="${name}"]`);

await I.pressKey(['CommandOrControl', 'A']);
await I.pressKey(['CommandOrControl', 'C']);
// For some reason keyboard copy doesn't work when running via yarn
await I.executeScript(() => document.execCommand('copy'));

const clipboard = await I.readClipboard();

assert.strictEqual(clipboard, expectedResult);
}

export default {
testPasswordToggling,
createRandomEmail: function () {
Expand Down
Loading

0 comments on commit 4fdfa79

Please sign in to comment.