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 ea0f517
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 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
@@ -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 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 Down
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 ea0f517

Please sign in to comment.