Skip to content

Commit

Permalink
test: fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowusr committed Sep 28, 2023
1 parent be91742 commit 2f3984e
Show file tree
Hide file tree
Showing 29 changed files with 51 additions and 32 deletions.
3 changes: 2 additions & 1 deletion lib/gui/tool-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const {getShortMD5} = require('../../common-utils');
const {formatId, mkFullTitle, mergeDatabasesForReuse, filterByEqualDiffSizes} = require('./utils');
const {getTestsTreeFromDatabase} = require('../../db-utils/server');
const {formatTestResult} = require('../../server-utils');
const {ToolName} = require('../../constants');

module.exports = class ToolRunner {
static create(paths, hermione, configs) {
Expand Down Expand Up @@ -280,7 +281,7 @@ module.exports = class ToolRunner {
const dbPath = path.resolve(this._reportPath, LOCAL_DATABASE_NAME);

if (await fs.pathExists(dbPath)) {
return getTestsTreeFromDatabase(dbPath);
return getTestsTreeFromDatabase(ToolName.Hermione, dbPath);
}

logger.warn(chalk.yellow(`Nothing to reuse in ${this._reportPath}: can not load data from ${DATABASE_URLS_JSON_NAME}`));
Expand Down
3 changes: 2 additions & 1 deletion lib/report-builder/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {IDLE, RUNNING, SKIPPED, FAIL, SUCCESS, UPDATED} = require('../constants/t
const {isSkippedStatus, isUpdatedStatus, hasNoRefImageErrors, hasResultFails} = require('../common-utils');
const {getConfigForStaticFile, deleteFile} = require('../server-utils');
const {DB_COLUMNS} = require('../constants/database');
const {ToolName} = require('../constants');

module.exports = class GuiReportBuilder extends StaticReportBuilder {
static create(...args) {
Expand All @@ -18,7 +19,7 @@ module.exports = class GuiReportBuilder extends StaticReportBuilder {
constructor(...args) {
super(...args);

this._testsTree = GuiTestsTreeBuilder.create();
this._testsTree = GuiTestsTreeBuilder.create({toolName: ToolName.Hermione});
this._skips = [];
this._apiValues = {};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/static/components/section/body/meta-info/content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class MetaInfoContent extends Component {
...extraMetaInfo
};
if (result.suiteUrl) {
formattedMetaInfo.url = mkLinkToUrl(buildUrl(result.suiteUrl, parsedHost), result.metaInfo.url);
formattedMetaInfo.url = mkLinkToUrl(getUrlWithBase(result.suiteUrl, baseHost), result.metaInfo.url);
}

return metaToElements(formattedMetaInfo, metaInfoBaseUrls);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/func/fixtures/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig({
['html-reporter-tester/playwright', {
path: path.resolve(__dirname, 'report'),
saveFormat: 'sqlite',
defaultView: 'failed',
defaultView: 'all',
saveErrorDetails: true
}]
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion test/func/tests/.hermione.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,31 @@ if (!projectUnderTest) {
throw 'Project under test was not specified';
}

const config = _.merge(getCommonConfig(__dirname), {
const commonConfig = getCommonConfig(__dirname);

const config = _.merge(commonConfig, {
baseUrl: `http://${serverHost}:${serverPort}/fixtures/${projectUnderTest}/report/index.html`,

browsers: {
// TODO: this is a hack to be able to have 2 sets of screenshots, for hermione-based report and pwt-based report
// currently, those have weird tiny diffs. Would be nice to figure out the cause and have common screenshots.
'chrome-pwt': {...commonConfig.browsers.chrome}
},

sets: {
common: {
files: 'common/**/*.hermione.js'
},
'common-gui': {
browsers: ['chrome'],
files: 'common-gui/**/*.hermione.js'
},
eye: {
browsers: ['chrome'],
files: 'eye/**/*.hermione.js',
},
plugins: {
browsers: ['chrome'],
files: 'plugins/**/*.hermione.js'
}
},
Expand Down
2 changes: 0 additions & 2 deletions test/func/tests/common-gui/index.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const {getTestSectionByNameSelector, getSpoilerByNameSelector, getElementWithTex

const serverHost = process.env.SERVER_HOST ?? 'host.docker.internal';

const serverHost = process.env.SERVER_HOST ?? 'host.docker.internal';

const projectName = process.env.PROJECT_UNDER_TEST;
const projectDir = path.resolve(__dirname, '../../fixtures', projectName);
const guiUrl = `http://${serverHost}:${PORTS[projectName].gui}`;
Expand Down
3 changes: 0 additions & 3 deletions test/func/tests/common/error-group.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ describe('Error grouping', function() {

const groupedTestsContainer = await browser.$('.grouped-tests');

const errorGroups = await browser.$$('.grouped-tests > div');
assert(errorGroups.length >= 2 && errorGroups.length <= 3);

const longErrorMessageGroup = await groupedTestsContainer.$('span*=long_error_message').$('..');

await expect(longErrorMessageGroup).toBeDisplayed();
Expand Down
3 changes: 3 additions & 0 deletions test/func/tests/common/test-results-appearance.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ describe('Test results appearance', () => {
);

await hideHeader(browser);
await browser.execute(() =>{
window.scrollTo(0, 10000);
});

await retrySelectorButton.assertView('retry-selector');
});
Expand Down
3 changes: 1 addition & 2 deletions test/func/tests/common/tests-details.hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe('Test details', function() {
await expect(await fileMetaInfo.$('span*=file')).toBeDisplayed();
});

// TODO: figure out why this test is flaky between different runs, hermione vs playwright fixtures
it.skip('should prevent details summary overflow', async ({browser}) => {
it('should prevent details summary overflow', async ({browser}) => {
const selector =
getTestSectionByNameSelector('test with long error message') +
`//summary[.${getElementWithTextSelector('span', 'message')}/..]`;
Expand Down
8 changes: 4 additions & 4 deletions test/func/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"version": "0.0.0",
"private": true,
"scripts": {
"gui:hermione-common": "PROJECT_UNDER_TEST=hermione npx hermione --set common gui",
"gui:hermione-common": "PROJECT_UNDER_TEST=hermione npx hermione --set common -b chrome gui",
"gui:hermione-eye": "PROJECT_UNDER_TEST=hermione-eye npx hermione --no --set eye gui",
"gui:hermione-gui": "PROJECT_UNDER_TEST=hermione-gui npx hermione --no --set common-gui gui",
"gui:playwright": "PROJECT_UNDER_TEST=playwright npx hermione --set common gui",
"gui:playwright": "PROJECT_UNDER_TEST=playwright npx hermione --set common -b chrome-pwt gui",
"gui:plugins": "PROJECT_UNDER_TEST=plugins SERVER_PORT=8084 npx hermione --set plugins gui",
"hermione:hermione-common": "PROJECT_UNDER_TEST=hermione SERVER_PORT=8061 npx hermione --set common",
"hermione:hermione-common": "PROJECT_UNDER_TEST=hermione SERVER_PORT=8061 npx hermione --set common -b chrome",
"hermione:hermione-eye": "PROJECT_UNDER_TEST=hermione-eye SERVER_PORT=8062 npx hermione --set eye",
"hermione:hermione-gui": "PROJECT_UNDER_TEST=hermione-gui SERVER_PORT=8063 npx hermione --no --set common-gui",
"hermione:playwright": "PROJECT_UNDER_TEST=playwright SERVER_PORT=8065 npx hermione --set common",
"hermione:playwright": "PROJECT_UNDER_TEST=playwright SERVER_PORT=8065 npx hermione --set common -b chrome-pwt",
"hermione:plugins": "PROJECT_UNDER_TEST=plugins SERVER_PORT=8064 npx hermione --set plugins",
"test": "run-s hermione:*"
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/5c90021/chrome/basic plugins.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/be4ff5b/chrome/basic plugins clicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/c0db305/chrome/details summary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/func/tests/screens/d8c5b8a/chrome/redux plugin clicked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion test/unit/lib/static/modules/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import actionNames from 'lib/static/modules/action-names';
import {StaticTestsTreeBuilder} from 'lib/tests-tree-builder/static';
import {LOCAL_DATABASE_NAME} from 'lib/constants/database';
import {DiffModes} from 'lib/constants/diff-modes';
import {ToolName} from 'lib/constants';

// eslint-disable-next-line
globalThis.performance = globalThis.performance; // node v14 stub
Expand Down Expand Up @@ -177,6 +178,9 @@ describe('lib/static/modules/actions', () => {
mergeDatabasesStub = sandbox.stub().resolves();

global.window = {
data: {
apiValues: {toolName: ToolName.Hermione}
},
location: {
href: 'http://localhost/random/path.html'
}
Expand Down Expand Up @@ -272,7 +276,7 @@ describe('lib/static/modules/actions', () => {

it('should init plugins with the config from data.js', async () => {
const config = {pluginsEnabled: true, plugins: []};
global.window.data = {config};
global.window.data.config = config;

await actions.initStaticReport()(dispatch);

Expand Down
4 changes: 2 additions & 2 deletions test/unit/lib/test-adapter/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('PlaywrightTestAdapter', () => {
it('should return fullName', () => {
const adapter = new PlaywrightTestAdapter(mkTestCase(), mkTestResult(), mkAdapterOptions());

assert.strictEqual(adapter.fullName, 'describe test');
assert.strictEqual(adapter.fullName, 'describe test');
});
});

Expand Down Expand Up @@ -219,7 +219,7 @@ describe('PlaywrightTestAdapter', () => {
it('should return imageDir', () => {
const adapter = new PlaywrightTestAdapter(mkTestCase(), mkTestResult(), mkAdapterOptions());

assert.strictEqual(adapter.imageDir, '75bcb6c');
assert.strictEqual(adapter.imageDir, '4050de5');
});
});

Expand Down
3 changes: 2 additions & 1 deletion test/unit/lib/tests-tree-builder/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const _ = require('lodash');
const proxyquire = require('proxyquire');
const {FAIL, ERROR, SUCCESS} = require('lib/constants/test-statuses');
const {BrowserVersions} = require('lib/constants/browser');
const {ToolName} = require('lib/constants');

describe('ResultsTreeBuilder', () => {
const sandbox = sinon.sandbox.create();
Expand All @@ -27,7 +28,7 @@ describe('ResultsTreeBuilder', () => {
'../common-utils': {determineStatus}
}).BaseTestsTreeBuilder;

builder = ResultsTreeBuilder.create();
builder = ResultsTreeBuilder.create({toolName: ToolName.Hermione});
});

afterEach(() => sandbox.restore());
Expand Down
25 changes: 14 additions & 11 deletions test/unit/lib/tests-tree-builder/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const _ = require('lodash');
const GuiResultsTreeBuilder = require('lib/tests-tree-builder/gui');
const {FAIL, SUCCESS, IDLE, UPDATED} = require('lib/constants/test-statuses');
const {ToolName} = require('lib/constants');

describe('GuiResultsTreeBuilder', () => {
let builder;
Expand All @@ -19,8 +20,10 @@ describe('GuiResultsTreeBuilder', () => {
});
};

const mkGuiTreeBuilder = () => GuiResultsTreeBuilder.create({toolName: ToolName.Hermione});

beforeEach(() => {
builder = GuiResultsTreeBuilder.create();
builder = mkGuiTreeBuilder();
});

describe('"getLastResult" method', () => {
Expand Down Expand Up @@ -72,7 +75,7 @@ describe('GuiResultsTreeBuilder', () => {
describe('"reuseTestsTree" method', () => {
describe('reuse browsers', () => {
it('should not reuse browser result if browser ids are not matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_(),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -90,7 +93,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should reuse browser result from the passed tree if browser ids matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_(),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -109,7 +112,7 @@ describe('GuiResultsTreeBuilder', () => {

describe('reuse test results', () => {
it('should not reuse result if browser ids does not matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({status: FAIL}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -127,7 +130,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should reuse all results from the passed tree if browser ids matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({status: FAIL}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -149,7 +152,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should register reused result ids', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_(),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 1})
Expand All @@ -168,7 +171,7 @@ describe('GuiResultsTreeBuilder', () => {

describe('reuse images', () => {
it('should not reuse images if browser ids does not matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({imagesInfo: [{stateName: 'img1'}]}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -186,7 +189,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should reuse all images from the passed tree if browser ids matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({imagesInfo: [{stateName: 'img1'}, {stateName: 'img2'}]}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -204,7 +207,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should register reused images ids', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({imagesInfo: [{stateName: 'img1'}, {stateName: 'img2'}]}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -223,7 +226,7 @@ describe('GuiResultsTreeBuilder', () => {

describe('reuse suite status', () => {
it('should not reuse suite status if browser ids does not matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({status: FAIL}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand All @@ -240,7 +243,7 @@ describe('GuiResultsTreeBuilder', () => {
});

it('should reuse suite status from passed tree with if browser ids matched', () => {
const srcBuilder = GuiResultsTreeBuilder.create();
const srcBuilder = mkGuiTreeBuilder();
srcBuilder.addTestResult(
mkTestResult_({status: FAIL}),
mkFormattedResult_({testPath: ['s1'], browserId: 'b1', attempt: 0})
Expand Down
3 changes: 2 additions & 1 deletion test/unit/lib/tests-tree-builder/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const _ = require('lodash');
const {StaticTestsTreeBuilder} = require('lib/tests-tree-builder/static');
const {SUCCESS} = require('lib/constants/test-statuses');
const {BrowserVersions} = require('lib/constants/browser');
const {ToolName} = require('lib/constants');

describe('StaticResultsTreeBuilder', () => {
const sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -68,7 +69,7 @@ describe('StaticResultsTreeBuilder', () => {
sandbox.stub(StaticTestsTreeBuilder.prototype, 'addTestResult');
sandbox.stub(StaticTestsTreeBuilder.prototype, 'sortTree');

builder = StaticTestsTreeBuilder.create();
builder = StaticTestsTreeBuilder.create({toolName: ToolName.Hermione});
});

afterEach(() => sandbox.restore());
Expand Down

0 comments on commit 2f3984e

Please sign in to comment.