Skip to content

Commit

Permalink
Merge branch 'feat/rebase-codecept-e2e-e2447' into 'master'
Browse files Browse the repository at this point in the history
Rebase codecept e2e engine#2447

See merge request minds/front!2118
  • Loading branch information
markharding committed Nov 11, 2022
2 parents d733b1e + 4ac0896 commit e4cff30
Show file tree
Hide file tree
Showing 66 changed files with 4,937 additions and 7,993 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ lint:
# <<: *cypress_tests

.playwright_tests: &playwright_tests
image: mcr.microsoft.com/playwright:v1.22.0-focal
image: mcr.microsoft.com/playwright:v1.27.0-focal
stage: qa
script:
- >
Expand Down
3 changes: 3 additions & 0 deletions e2e/test/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ SUPERMIND_SENDER_PASSWORD=

SUPERMIND_SETTINGS_USERNAME=supermind_settings
SUPERMIND_SETTINGS_PASSWORD=

SUPERMIND_FILTER_TEST_USERNAME=supermind_filter_test
SUPERMIND_FILTER_TEST_USERNAME=
1 change: 1 addition & 0 deletions e2e/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
1 change: 1 addition & 0 deletions e2e/test/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/fermium
50 changes: 26 additions & 24 deletions e2e/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,71 @@ Playwright end-to-end test automation with CodeceptJS (Gherkin) and Browserstack
### Key Integrations

* Playwright + CodeceptJS + BrowserStack
* Page Object Model
* Page Object Models
* Gherkin
* Gitlab CI
* Parallel execution
* Platform: Chrome, Firefox, Webkit

### Dependencies

#### _Pre-requisites_: Install latest version of Node, web browsers and create environment variables.

#### _Node_: https://nodejs.org/en/download/
#### _Pre-requisites_: Install latest version of Node (or use NVM), web browsers and create environment variables

#### _Environment variables for Playwright Tests_

| Variable | Description |
| -------- | ----------- |
| E2E_DOMAIN | The URL you are testing against. eg: 'http://localhost:8080'. Do not include a trailing slash. |
| BROWSERSTACK_USERNAME | Optional username for Browserstack integration |
| BROWSERSTACK_ACCESS_KEY | Optional access key for Browserstack integration |
| BYPASS_SIGNING_KEY | The key to sign the bypass tokens with |
| PLAYWRIGHT_USERNAME | The username of the default user you will test against |
| PLAYWRIGHT_PASSWORD | The password of the default user you will test against |
| BYPASS_SIGNING_KEY | The key to sign the bypass tokens with (optional?) |
| SUPERMIND_SENDER_USERNAME | The username of the supermind sender |
| SUPERMIND_SENDER_PASSWORD | The password of the supermind sender |


#### _Environment variables for BrowserStack Connection_

BROWSERSTACK_USERNAME & BROWSERSTACK_ACCESS_KEY
| SUPERMIND_SENDER_USERNAME | The username of a dedicated user to act as a supermind sender |
| SUPERMIND_SENDER_PASSWORD | The password of a dedicated user to act as a supermind sender |
| SUPERMIND_SETTINGS_USERNAME | Username of a dedicated user for testing Supermind Settings |
| SUPERMIND_SETTINGS_PASSWORD | Password of a dedicated user for testing Supermind Settings |
| SUPERMIND_FILTER_TEST_USERNAME | Username of a dedicated user for testing Supermind Console filters |
| SUPERMIND_FILTER_TEST_USERNAME | Password of a dedicated user for testing Supermind Console filters |

## Run Command

### Installing

```
```sh
cd e2e/test
yarn

nvm use # if you want to quickly upgrade your node version and use NVM

npm install
```

### Running via CLI

```
yarn run test:e2e:local
```sh
npm run test:e2e:local
```

### Running via CodeceptUI

```
yarn run test:e2e:local:ui
```sh
npm run test:e2e:local:ui
```

### Running via Browserstack on Chrome, Firefox & Webkit browsers in parallel

```
yarn run test:e2e:real
```sh
npm run test:e2e:real
```

*In case of errors, check screenshots saved under e2e/test/error-screenshots folder.

## Creating New Tests
To create a new suite of tests:
- Create a Feature file (to define gherkin features and scenarios).
- Create a Steps file (to define individual Steps - Given/When/Then).
- Create a Page file (to define common functions and variables).
- Ensure that all the files above are linked via codeceptjs config file.
- If necessary, create a Feature file (to define gherkin features and scenarios).
- If necessary, create a Steps file (to define individual Steps - Given/When/Then).
- If necessary, create a Page file (to define common functions and variables).
- Ensure that Pages and Fragments are references in ALL Codeceptjs config files in the include section.

## Helpful Links
- How to write tests in CodeceptJs + Gherkin click [here](https://codecept.io/bdd/)
Expand Down
92 changes: 92 additions & 0 deletions e2e/test/codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
require('ts-node/register');

import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

require('dotenv').config();

type CustomMainConfig = Omit<CodeceptJS.MainConfig, 'gherkin'> & {
gherkin: {
features: string | Array<string>;
steps: string | Array<string>;
};
};

export const config: CustomMainConfig = {
tests: './steps/*-steps.ts',
output: './error-screenshots',
helpers: {
Playwright: {
url: process.env.E2E_DOMAIN || 'https://minds.com/',
show: true,
video: true,
browser: 'chromium',
restart: 'session',
keepCookies: true,
keepBrowserState: true,
waitForNavigation: 'domcontentloaded',
timeout: 10000,
waitForTimeout: 10000,
trace: true,
},
CookieHelper: {
require: './helpers/cookie-helper.ts',
},
CommonHelper: {
require: './helpers/common-helper.ts',
},
},
include: {
// pages
activityFeedPage: './pages/activityFeedPage.ts',
boostMarketingPage: './pages/boostMarketingPage.ts',
boostPage: './pages/boostPage.ts',
channelPage: './pages/channelPage.ts',
commonPage: './pages/commonPage.ts',
devtoolsPage: './pages/devtoolsPage.ts',
loginPage: './pages/loginPage.ts',
newsfeedPage: './pages/newsfeedPage.ts',
registerPage: './pages/registerPage.ts',
rewardsMarketingPage: './pages/rewardsMarketingPage.ts',
searchPage: './pages/searchPage.ts',
settingsPage: './pages/settingsPage.ts',
singleEntityPage: './pages/singleEntityPage.ts',
supermindConsolePage: './pages/supermindConsolePage.ts',
supermindSettingsPage: './pages/supermindSettingsPage.ts',
tokenMarketingPage: './pages/tokenMarketingPage.ts',
// fragments
composerModalComponent: './fragments/composerModalComponent.ts',
activityComponent: './fragments/activityComponent.ts',
activityModalComponent: './fragments/activityModalComponent.ts',
boostRotatorComponent: './fragments/boostRotatorComponent.ts',
confirmationModalComponent: './fragments/confirmationModalComponent.ts',
notificationsComponent: './fragments/notificationsComponent.ts',
sidebarComponent: './fragments/sidebarComponent.ts',
supermindOnboardingModalComponent:
'./fragments/supermindOnboardingModalComponent.ts',
topbarComponent: './fragments/topbarComponent.ts',
feedNoticeComponent: './fragments/feedNoticeComponent.ts',
},
name: 'Minds Codecept E2E tests',
gherkin: {
features: './features/*.feature',
steps: './steps/*-steps.ts',
},
plugins: {
pauseOnFail: {},
retryFailedStep: {
enabled: true,
},
tryTo: {
enabled: true,
},
screenshotOnFail: {
enabled: true,
},
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
require('ts-node/register');
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

require('dotenv').config();

type CustomMainConfig = Omit<CodeceptJS.MainConfig, 'gherkin'> & {
gherkin: {
features: string | Array<string>;
steps: string | Array<string>;
};
};

const cp = require('child_process');
const clientPlaywrightVersion = cp
.execSync('npx playwright --version')
Expand Down Expand Up @@ -44,18 +58,16 @@ const webkitCaps = {
'client.playwrightVersion': clientPlaywrightVersion,
};

exports.config = {
output: '../error-screenshots',
export const config: CustomMainConfig = {
tests: './steps/*-steps.ts',
output: './error-screenshots',
helpers: {
Playwright: {
url: process.env.E2E_DOMAIN || 'https://minds.com',
show: true,
video: true,
browser: [],
retries: 2,
browser: process.env.profile || 'chromium',
restart: 'session',
reporter: 'html',

chromium: {
browserWSEndpoint: {
wsEndpoint: `wss://cdp.browserstack.com/playwright?caps=${encodeURIComponent(
Expand All @@ -78,22 +90,53 @@ exports.config = {
},
},
},
CookieHelper: {
require: './helpers/cookie-helper.ts',
},
CommonHelper: {
require: './helpers/common-helper.ts',
},
},
multiple: {
browserStackCombo: {
browsers: ['firefox', 'chromium', 'webkit'],
},
},
include: {
I: '../step_definitions/steps_file.ts',
loginPage: '../pages/loginPage.ts',
// pages
activityFeedPage: './pages/activityFeedPage.ts',
boostMarketingPage: './pages/boostMarketingPage.ts',
boostPage: './pages/boostPage.ts',
channelPage: './pages/channelPage.ts',
commonPage: './pages/commonPage.ts',
devtoolsPage: './pages/devtoolsPage.ts',
loginPage: './pages/loginPage.ts',
newsfeedPage: './pages/newsfeedPage.ts',
registerPage: './pages/registerPage.ts',
rewardsMarketingPage: './pages/rewardsMarketingPage.ts',
searchPage: './pages/searchPage.ts',
settingsPage: './pages/settingsPage.ts',
singleEntityPage: './pages/singleEntityPage.ts',
supermindConsolePage: './pages/supermindConsolePage.ts',
supermindSettingsPage: './pages/supermindSettingsPage.ts',
tokenMarketingPage: './pages/tokenMarketingPage.ts',
// fragments
composerModalComponent: './fragments/composerModalComponent.ts',
activityComponent: './fragments/activityComponent.ts',
activityModalComponent: './fragments/activityModalComponent.ts',
boostRotatorComponent: './fragments/boostRotatorComponent.ts',
confirmationModalComponent: './fragments/confirmationModalComponent.ts',
notificationsComponent: './fragments/notificationsComponent.ts',
sidebarComponent: './fragments/sidebarComponent.ts',
supermindOnboardingModalComponent:
'./fragments/supermindOnboardingModalComponent.ts',
topbarComponent: './fragments/topbarComponent.ts',
feedNoticeComponent: './fragments/feedNoticeComponent.ts',
},
mocha: {},
bootstrap: null,
teardown: null,
name: 'Minds Codecept E2E tests',
gherkin: {
features: '../features/*.feature',
steps: ['../steps/login-steps.ts'],
features: './features/*.feature',
steps: './steps/*-steps.ts',
},
plugins: {
pauseOnFail: {},
Expand All @@ -107,5 +150,4 @@ exports.config = {
enabled: true,
},
},
name: 'minds-real-testing-project',
};
Loading

0 comments on commit e4cff30

Please sign in to comment.