Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Role constructor and t.useRole (closes #243) #1315

Merged
merged 20 commits into from
Mar 20, 2017

Conversation

inikulin
Copy link
Contributor

Copy link
Contributor

@AlexanderMoskovkin AlexanderMoskovkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a remark in tests. lgtm in general

@@ -4,6 +4,6 @@
<title>Cross-domain iframe page</title>
</head>
<body>
<iframe id="iframe" src=http://localhost:3001/legacy-fixtures/native-dialogs-handling/pages/index.html></iframe>
<iframe id="iframe" src=http://localhost:3001/legacy-fixtures/api/es-next/native-dialogs-handling/pages/index.html></iframe>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a legacy-api functional tests file. I suppose it was changes by a mistake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good catch



describe('Native dialogs handling', function () {
it('Should remove dialog handler if `null` specified', function () {
Copy link
Contributor

@AlexanderMoskovkin AlexanderMoskovkin Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add info about this in the documentation topic about setNativeDialogHandler.
It's possible now to pass null as an argument (see https://github.com/DevExpress/testcafe/pull/1315/files#diff-bc2ca31d9db34de5fa61db548150e9aaR192) /cc @VasilyStrelyaev

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will do this

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit ddb507d have passed. See details:

this.initErr = err;
}

if (!this.initErr) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's can be just after this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it can and will make code more compact, but it will ambiguous which code we expect will throw. It's a bad practice to put everything in the try/catch

this.loginPage = loginPage;
this.initFn = initFn;

this.stateSnapshot = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I saw it first time I decided that stateSnapshot is some state of role, may be in role context it should call testRunStateSnapshot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it's a state of role which can be applied to test run.

async restore (callsite) {
var prevPhase = this.testRun.phase;

this.testRun.phase = TEST_RUN_PHASE.inBookmarkRestore;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it better set in testRun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not. How do you imagine that? One-line function that does exactly the same? And it's fine to modify test run phase outside of test run - it's a public property. Moreover, it's already done in fixture-hook-tracker.

it('Should fail if there error occurred while restoring configuration', function () {
return runTests('./testcafe-fixtures/errors-test.js', 'Error restoring configuration', { shouldFail: true })
.catch(function (errs) {
expect(errs[0]).contains('- Error while restoring configuration after Role switch - The specified selector does not match any element in the DOM tree.');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a special error for cases when iframe does not exist anymore.
May be we should raise it in this case, wht do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it can be used? Note that I don't want to introduce any ad-hoc solutions here and just use basic commands machinery.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can make it better)

@@ -411,3 +417,11 @@ export class WindowDimensionsOverflowError extends TestRunErrorBase {
this.callsite = callsite;
}
}

export class RoleSwitchInRoleInitializerError extends TestRunErrorBase {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better to move this error (and WindowDimensionsOverflowError too) above this line because another way the located in group of // Native dialog errors

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit cbbdba6 have passed. See details:

@inikulin
Copy link
Contributor Author

FPR

Copy link
Collaborator

@helen-dikareva helen-dikareva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oook then

@@ -43,7 +45,12 @@ class TestRunBookmark {
new SwitchToIframeCommand({ selector: this.iframeSelector }) :
new SwitchToMainWindowCommand();

await this.testRun.executeCommand(switchWorkingFrameCommand);
try {
await this.testRun.executeCommand(switchWorkingFrameCommand);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a few types of errors can be raised during execution of switching command

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit c1bf35c have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit c1bf35c have passed. See details:

@AlexanderMoskovkin
Copy link
Contributor

rebase required

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit f478241 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 00a1a31 have failed. See details:

@inikulin inikulin changed the title Implement Role constructor and t.useRole (#243 part1) Implement Role constructor and t.useRole (closes #243) Mar 17, 2017
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 00a1a31 have failed. See details:

1 similar comment
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 00a1a31 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 00a1a31 have passed. See details:

@inikulin
Copy link
Contributor Author

FPR

@inikulin
Copy link
Contributor Author

Copy link
Collaborator

@helen-dikareva helen-dikareva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@AlexanderMoskovkin AlexanderMoskovkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@inikulin inikulin merged commit c7af417 into DevExpress:master Mar 20, 2017
@inikulin inikulin deleted the gh-243 branch March 20, 2017 08:27
kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
…evExpress#1315)

* Implement Role API, refactor server tests

* Add Role id

* Rename testRun.state to testRun.phase

* Allow removal of native dialog handler. Save current iframe selector.

* Introduce marker symbol for TestRun. Store current test run speed.

* Implement test run bookmark

* useRoleMachinery implemented

* Implement UseRoleCommand

* Implement t.useRole

* Functionality implemented. Add basic test.

* Test basic functionality

* Add error tests

* Move body-parser to dev deps

* Fix tests

* Run particular tests only on desktop browsers

* Revert legacy api test-related page

* Moved error definitions to the appropriate place

* Throw appropriate message on iframe restore

* iframe errors

* Fix rebase issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants