Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Feat / update e2e test with queries #45

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f260bc1
feat(project): add codeceptjs with first test
demmyhonore Mar 2, 2021
83ce807
feat(project): add see visual difference testing
demmyhonore Mar 2, 2021
f1571d6
feat(project): add 5 test scenarios
demmyhonore Mar 2, 2021
5dc13e6
feat(project): add all test scenarios for person modal
demmyhonore Mar 3, 2021
5816a33
refactor(project): refactor end to end folders
demmyhonore Mar 3, 2021
0aa6369
feat(project): add all test scenarios for media modal
demmyhonore Mar 3, 2021
3b104ca
feat(project): add all scenarios for composition modal
demmyhonore Mar 3, 2021
f5541f6
feat(project): add all scenarios for score modal
demmyhonore Mar 4, 2021
40b2ae2
feat(project): add tests to validate more data sources
demmyhonore Mar 4, 2021
5c6de4b
feat(project): pass all local test on all browsers
demmyhonore Mar 8, 2021
6272a41
feat(project): add last screenshots
demmyhonore Mar 8, 2021
bc81e84
feat(project): add codeceptjs worklow
VincentCouzij Mar 8, 2021
1238060
chore(project): set fail-fast to false
VincentCouzij Mar 8, 2021
6f5915d
feat(project): add language switcher tests
demmyhonore Mar 8, 2021
604c827
Merge branch 'master' of https://github.com/trompamusic/trompa-multim…
RCVZ Mar 12, 2021
43768a6
feat(project): implement allure and new structure
demmyhonore Mar 17, 2021
3152e1a
feat(project): add screenshot differences to allure
demmyhonore Mar 17, 2021
5b8e1ce
fix(project): restore test-ids lost through merge
demmyhonore Mar 17, 2021
4ba7427
feat(project): add screenshots baseline
demmyhonore Mar 17, 2021
a9f81dc
feat(project): add allure reporting
VincentCouzij Mar 18, 2021
7a2e07f
chore(project): change path line for export
VincentCouzij Mar 18, 2021
4590bb7
chore(project): replace always with expression
VincentCouzij Mar 18, 2021
b55d064
Merge branch 'master' into feat/end-to-end-reporting
VincentCouzij Mar 18, 2021
28b57d1
chore(project): updated base url
RCVZ Mar 19, 2021
e0e3bd0
feat(e2e): add byRole and getUrlHostName functions
RCVZ Mar 19, 2021
2dfbbeb
chore(e2e): add e2e to commitlint
RCVZ Mar 19, 2021
b0c8f15
feat(e2e): add graphql queries to e2e tests
RCVZ Mar 19, 2021
b0ecf81
feat(example): add listitem role prop to results
RCVZ Mar 19, 2021
86e28ba
chore(e2e): updated screenshots
RCVZ Mar 19, 2021
b2c2969
chore(e2e): removed filter tests
RCVZ Mar 21, 2021
1d781f9
chore(e2e): fixed screenshot timing issues
RCVZ Mar 21, 2021
4b6d05e
chore(e2e): fixed timing issues on safari
RCVZ Mar 21, 2021
73cce80
chore(e2e): updated screenshots
RCVZ Mar 21, 2021
0bba782
chore(e2e): increased timings
RCVZ Mar 22, 2021
bbf52fc
chore(e2e): increased tolerance
RCVZ Mar 22, 2021
870fafd
chore(e2e): show tests steps
RCVZ Mar 22, 2021
f98943e
chore(e2e): fix failing tests
RCVZ Mar 23, 2021
6cacec6
chore(e2e): update base screenshots
RCVZ Mar 23, 2021
96050e5
chore(e2e): increased tolerance
RCVZ Mar 24, 2021
d6e91a4
chore(e2e): updated screenshots
RCVZ Mar 24, 2021
fdecb50
chore(e2e): enabled prepareBaseImage
RCVZ Mar 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {
rules : {
'scope-enum': [
2, 'always', [
'e2e',
'example',
'project',
'navbar',
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "react-app",
"extends": ["react-app", "plugin:codeceptjs/recommended"],
"plugins": [
"varspacing",
"import"
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/codeceptjs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
on:
pull_request:
branches:
- master
jobs:
e2e-tests:
strategy:
fail-fast: false
matrix:
os:
- macos-10.15
- windows-2019
browser:
- chrome
- firefox
- safari
exclude:
- os: windows-2019
browser: safari
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- uses: microsoft/playwright-github-action@v1

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install dependencies
run: yarn --prefer-offline

- name: Run tests
run: yarn test:local:${{matrix.browser}}

- name: Run Allure
if: ${{ always() }}
run: yarn test:${{matrix.browser}}:report:generate

- name: Export Allure report
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: allure-report-${{matrix.os}}-${{matrix.browser}}
retention-days: 30
path: automatic-tests/output/allure/${{matrix.browser}}/report
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ dist
npm-debug.log*
yarn-debug.log*
yarn-error.log*

*.failed.png
!.gitkeep

# allure
automatic-tests/output/allure/*/report
automatic-tests/output/*/allure-results/
4 changes: 2 additions & 2 deletions .graphqlconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"extensions": {
"endpoints": {
"Default Introspection Endpoint": {
"url": "http://api-test.trompamusic.eu",
"url": "https://api-test.trompamusic.eu",
"introspect": true,
"headers": {
"user-agent": "JS GraphQL"
}
},
"Default": {
"url": "http://api-test.trompamusic.eu",
"url": "https://api-test.trompamusic.eu",
"headers": {
"user-agent": "JS GraphQL"
}
Expand Down
132 changes: 132 additions & 0 deletions automatic-tests/composition-modal_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
const { secondsToWait, visualDiffOptions, compositionModalLocators: locators, byRole, getUrlHostName } = require('./config/globals');

Feature('Composition modal');

let currentBrowser;

Scenario('Opens composition modal with expected content', async ({ I }) => {
const screenshotPath = "composition_modal_loaded.png";

I.usePlaywrightTo('Detect current browser', async ({ browser }) => {
const browserObject = await browser;

currentBrowser = browserObject._initializer.name;
console.log('Current browser is:', currentBrowser);
});

const response = await I.sendQuery(searchQuery);
const { title, name, __typename, creator, source } = response.data.data.results[0];

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.waitForElement(locators.headerInitialResults, secondsToWait);
I.saveScreenshot(screenshotPath);
I.seeVisualDiff(screenshotPath, visualDiffOptions);
I.see('50 results');

within(byRole('listitem'), () => {
I.see(title);
I.see(name);
I.see(__typename);
I.see(creator);
I.seeElementInDOM(locate('a')
.withAttr({ href: source }));
});
});

Scenario('Language switcher initially loads English', ({ I }) => {
const screenshotPath = "composition_modal_language_switcher_loaded.png";

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.see('English');
I.saveScreenshot(screenshotPath);
I.seeVisualDiff(screenshotPath, visualDiffOptions);
});

Scenario('Language switcher can select Dutch language', ({ I }) => {
const screenshotPath = "composition_modal_language_switcher_dutch_selected.png";

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.click('English', { xpath: '//header//li[1]' });
I.click('Dutch', { xpath: '//ul//li[2]' });
I.wait(2);
I.see('Nederlands');

I.saveScreenshot(screenshotPath);
I.seeVisualDiff(screenshotPath, visualDiffOptions);
});

Scenario('Selects composition from modal', async ({ I }) => {
const screenshotPath = "composition_modal_selected_.png";

const response = await I.sendQuery(searchQuery);
const { title, name } = response.data.data.results[0];

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.waitForElement(locators.headerInitialResults, secondsToWait);
I.click(locate({ css: '[role=listitem]' }).withText(title));
I.wait(2);
I.saveScreenshot(screenshotPath);
I.seeVisualDiff(screenshotPath, visualDiffOptions);
I.see(name);
});

Scenario('Opens composition source link from modal', async ({ I }) => {
const response = await I.sendQuery(searchQuery);
const { source } = response.data.data.results[0];

I.closeOtherTabs();
I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.waitForElement(locators.headerInitialResults, secondsToWait);
I.click(getUrlHostName(source));
I.wait(2);
I.switchToNextTab();
I.grabCurrentUrl();
I.seeInCurrentUrl(source);
});

Scenario('Gives results that match query within modal', async ({ I }) => {
const screenshotPath = "composition_modal_with_composition_searched.png";

const response = await I.sendQuery(searchQuery);
const { title, name } = response.data.data.results[0];

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.waitForElement(locators.headerInitialResults, secondsToWait);
I.fillField('search', name.replace(/-/g, ""));

I.waitForElement(locate({ css: '[role=listitem]' }).withText(title), secondsToWait);
I.see(title);
I.saveScreenshot(screenshotPath);
I.seeVisualDiff(screenshotPath, visualDiffOptions);
});

Scenario('All relevant source links display in modal', async ({ I }) => {
const response = await I.sendQuery(searchQuery);
const { source } = response.data.data.results[0];

I.amOnPage('/');
I.click('Select', locators.selectCompositionModal);
I.waitForElement(locators.headerInitialResults, secondsToWait);
I.see(getUrlHostName(source));
});

const searchQuery = `
query($filter: _MusicCompositionFilter) {
results: MusicComposition(filter: $filter, first: 50) {
__typename
... on MusicComposition {
identifier
name
title
creator
source
}
}
}
`;
34 changes: 34 additions & 0 deletions automatic-tests/config/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
secondsToWait : 30,
visualDiffOptions: { tolerance: 15, prepareBaseImage: true },
byRole : role => ({ css: `[role=${role}] ` }),
getUrlHostName : url => {
const match = url.match(/:\/\/(www[0-9]?\.)?(.[^/:]+)/i);

if (match != null && match.length > 2 && typeof match[2] === 'string' && match[2].length > 0) {
return match[2];
}

return null;
},
compositionModalLocators: {
selectCompositionModal: 'button[data-test-id=select-composition-modal]',
headerInitialResults : '//h6[contains(text(), "50 results")]',
firstSearchResult : 'div[data-test-id=first-search-result]',
},
mediaModalLocators: {
selectMediaModal : 'button[data-test-id=select-media-modal]',
headerInitialResults: '//h6[contains(text(), "18 results")]',
firstSearchResult : 'div[data-test-id=first-search-result]',
},
personModalLocators: {
selectPersonModal : 'button[data-test-id=select-person-modal]',
firstSearchResult : 'div[data-test-id=first-search-result]',
headerInitialResults: '//h6[contains(text(), "50 results")]',
},
scoreModalLocators: {
selectScoreModal : 'button[data-test-id=select-score-modal]',
headerInitialResults: '//h6[contains(text(), "50 results")]',
firstSearchResult : 'div[data-test-id=first-search-result]',
},
};
Loading