Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyBelym committed Jan 22, 2019
1 parent 68be7a0 commit 3953af3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/utils/correct-file-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function (filePath, expectedExtention) {

const correctedPath = filePath
.split(path.posix.sep)
.filter(fragment => !!fragment)
.filter((fragment, index) => index === 0 || !!fragment)
.map(str => sanitizeFilename(str))
.join(path.sep);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('Native dialogs handling in iframe', function () {
DEFAULT_FAILED_RUN_IN_IFRAME_OPTIONS)
.catch(function (errs) {
errorInEachBrowserContains(errs, getNativeDialogNotHandledErrorText('alert', pageLoadingUrl), 0);
errorInEachBrowserContains(errs, '> 28 | await t.click(\'body\'); ', 0);
errorInEachBrowserContains(errs, '> 30 | await t.click(\'body\'); ', 0);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { expect } from 'chai';

fixture `Page load`
.page `http://localhost:3000/fixtures/api/es-next/native-dialogs-handling/iframe/pages/page-load.html`;
fixture `Page load`;


const pageUrl = 'http://localhost:3000/fixtures/api/es-next/native-dialogs-handling/iframe/pages/page-load.html';
Expand All @@ -10,7 +9,8 @@ const iframeUrl = 'http://localhost:3000/fixtures/api/es-next/native-dialogs-han

test('Expected dialogs after page load', async t => {
await t
.setNativeDialogHandler(() => null);
.setNativeDialogHandler(() => null)
.navigateTo(pageUrl);

// NOTE: waiting for iframe loading
await t.switchToIframe('#iframe');
Expand All @@ -24,6 +24,8 @@ test('Expected dialogs after page load', async t => {
]);
});

test('Unexpected alert after page load', async t => {
await t.click('body');
});
test
.page(pageUrl)
('Unexpected alert after page load', async t => {
await t.click('body');
});
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('Native dialogs handling', function () {
{ shouldFail: true })
.catch(function (errs) {
errorInEachBrowserContains(errs, getNativeDialogNotHandledErrorText('alert', pageLoadingUrl), 0);
errorInEachBrowserContains(errs, '> 40 | await t.click(\'body\');', 0);
errorInEachBrowserContains(errs, '> 42 | await t.click(\'body\');', 0);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ClientFunction } from 'testcafe';
import { expect } from 'chai';

fixture `Page load`
.page `http://localhost:3000/fixtures/api/es-next/native-dialogs-handling/pages/page-load.html`;
fixture `Page load`;


const getResult = ClientFunction(() => document.getElementById('result').textContent);
Expand All @@ -16,7 +15,8 @@ test('Expected dialogs after page load', async t => {
return true;

return null;
});
})
.navigateTo(pageUrl);

expect(await getResult()).equals('true');

Expand All @@ -36,6 +36,8 @@ test('Expected dialogs after page load', async t => {
]);
});

test('Unexpected alert after page load', async t => {
await t.click('body');
});
test
.page(pageUrl)
('Unexpected alert after page load', async t => {
await t.click('body');
});
9 changes: 8 additions & 1 deletion test/functional/site/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ const CONTENT_TYPES = {
'.png': 'image/png'
};

const NON_CACHEABLE_PAGES = [
'/fixtures/api/es-next/roles/pages',
'/fixtures/api/es-next/request-hooks/pages',
'/fixtures/regression/gh-2015/pages',
'/fixtures/regression/gh-2282/pages'
];

const UPLOAD_SUCCESS_PAGE_TEMPLATE = readSync('./views/upload-success.html.mustache');


Expand Down Expand Up @@ -66,7 +73,7 @@ Server.prototype._setupRoutes = function () {
.then(function (content) {
res.setHeader('content-type', CONTENT_TYPES[path.extname(resourcePath)]);

if (!reqPath.startsWith('/fixtures/api/es-next/roles/pages') && !reqPath.startsWith('/fixtures/api/es-next/request-hooks/pages'))
if (NON_CACHEABLE_PAGES.every(pagePrefix => !reqPath.startsWith(pagePrefix)))
res.setHeader('cache-control', 'max-age=3600');

setTimeout(function () {
Expand Down

0 comments on commit 3953af3

Please sign in to comment.