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

chore: tauri asset url integration and tests #1136

Merged
merged 15 commits into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 10 additions & 3 deletions .github/workflows/playwright-chromium-integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: [ main ]
jobs:
test:
timeout-minutes: 60
timeout-minutes: 90
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -16,14 +16,21 @@ jobs:
run: npx playwright install --with-deps

- name: Run Playwright integration tests in Chromium Attempt 1
timeout-minutes: 30
id: attemptC1
timeout-minutes: 20
continue-on-error: true
run: npm run testIntegChromium

- name: Run Playwright integration tests in Chromium Attempt 2
if: steps.attemptC1.outcome == 'failure'
id: attemptC2
if: steps.attemptC1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testIntegChromium

- name: Run Playwright integration tests in Chromium Attempt 3
id: attemptC3
if: steps.attemptC2.outcome == 'failure'
run: npm run testIntegChromium

- uses: actions/upload-artifact@v3
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/playwright-chromium.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,25 @@ jobs:
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests in chromium

- name: Run Playwright unit tests in Chromium Attempt 1
id: attemptC1
timeout-minutes: 20
continue-on-error: true
run: npm run testChromium

- name: Run Playwright unit tests in Chromium Attempt 2
id: attemptC2
if: steps.attemptC1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testChromium

- name: Run Playwright unit tests in Chromium Attempt 3
id: attemptC3
if: steps.attemptC2.outcome == 'failure'
run: npm run testChromium

- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/playwright-firefox-integ.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
branches: [ main ]
jobs:
test:
timeout-minutes: 60
timeout-minutes: 90
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -14,15 +14,23 @@ jobs:
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright integration tests in firefox Attempt 1
timeout-minutes: 30
id: attempt1
timeout-minutes: 20
continue-on-error: true
run: npm run testIntegFirefox

- name: Run Playwright integration tests in firefox Attempt 2
if: steps.attempt1.outcome == 'failure'
id: attempt2
if: steps.attempt1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testIntegFirefox

- name: Run Playwright integration tests in firefox Attempt 3
id: attempt3
if: steps.attempt2.outcome == 'failure'
run: npm run testIntegFirefox

- uses: actions/upload-artifact@v3
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/playwright-firefox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,25 @@ jobs:
run: npm run build
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests in firefox

- name: Run Playwright unit tests in firefox Attempt 1
id: attempt1
timeout-minutes: 20
continue-on-error: true
run: npm run testFirefox

- name: Run Playwright unit tests in firefox Attempt 2
id: attempt2
if: steps.attempt1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testFirefox

- name: Run Playwright unit tests in firefox Attempt 3
id: attempt3
if: steps.attempt2.outcome == 'failure'
run: npm run testFirefox

- uses: actions/upload-artifact@v3
if: always()
with:
Expand Down
52 changes: 48 additions & 4 deletions .github/workflows/playwright-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,26 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright unit tests in Firefox
- name: Run Playwright unit tests in firefox Attempt 1
id: attempt1
timeout-minutes: 20
continue-on-error: true
run: npm run testFirefox

- name: Run Playwright unit tests in firefox Attempt 2
id: attempt2
if: steps.attempt1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testFirefox

- name: Run Playwright unit tests in firefox Attempt 3
id: attempt3
if: steps.attempt2.outcome == 'failure'
run: npm run testFirefox

testFirefoxInteg:
timeout-minutes: 60
timeout-minutes: 90
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -50,9 +65,16 @@ jobs:

- name: Run Playwright integration tests in firefox Attempt 2
if: steps.attempt1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
id: attempt2
run: npm run testIntegFirefox

- name: Run Playwright integration tests in firefox Attempt 3
if: steps.attempt2.outcome == 'failure'
id: attempt3
run: npm run testIntegFirefox

testChromiumUnit:
timeout-minutes: 60
runs-on: ubuntu-latest
Expand All @@ -68,11 +90,26 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright unit tests in Chromium
- name: Run Playwright unit tests in Chromium Attempt 1
id: attemptC1
timeout-minutes: 20
continue-on-error: true
run: npm run testChromium

- name: Run Playwright unit tests in Chromium Attempt 2
id: attemptC2
if: steps.attemptC1.outcome == 'failure'
timeout-minutes: 30
continue-on-error: true
run: npm run testChromium

- name: Run Playwright unit tests in Chromium Attempt 3
id: attemptC3
if: steps.attemptC2.outcome == 'failure'
run: npm run testChromium

testChromiumInteg:
timeout-minutes: 60
timeout-minutes: 90
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -93,10 +130,17 @@ jobs:
run: npm run testIntegChromium

- name: Run Playwright integration tests in Chromium Attempt 2
timeout-minutes: 30
continue-on-error: true
if: steps.attemptC1.outcome == 'failure'
id: attemptC2
run: npm run testIntegChromium

- name: Run Playwright integration tests in Chromium Attempt 3
if: steps.attemptC2.outcome == 'failure'
id: attemptC3
run: npm run testIntegChromium

raiseIssue:
needs: [ testFirefoxUnit, testFirefoxInteg, testChromiumUnit, testChromiumInteg]
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions src-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"homepage": "https://github.com/phcode-dev/phoenix",
"license": "GNU-AGPL3.0",
"scripts": {
"_watch_src-node": "cd .. && npm run _watch_src-node"
},
"engines": {
"node": "18"
Expand Down
6 changes: 2 additions & 4 deletions src/assets/new-project/assets/js/code-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ function getDisplayLocation(projectPath) {
return Strings.PROJECT_FROM_BROWSER;
}

const DEFAULT_PROJECT_PATH = '/fs/local/default project';

function _updateProjectCards() {
let recentProjectList = $(document.getElementById('recentProjectList'));
recentProjectList.empty();
let recentProjects = recentProjectExtension.getRecentProjects();
let tabIndex = 1;
let defaultProjects = [DEFAULT_PROJECT_PATH, '/fs/local/explore'],
omitProjectsInListing = ['/fs/local/explore'],
let defaultProjects = [newProjectExtension.getWelcomeProjectPath(), newProjectExtension.getExploreProjectPath()],
omitProjectsInListing = [newProjectExtension.getExploreProjectPath()],
showRecentProjects = false;
for(let recentProject of recentProjects){
if(!defaultProjects.includes(recentProject)){
Expand Down
3 changes: 2 additions & 1 deletion src/assets/new-project/assets/js/new-project-more.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function _getIconURL(iconURL) {
return 'images/Bootstrap_logo.svg';
} else if(iconURL === 'appLogo'){
return 'images/logo.png';
} else if(iconURL && (iconURL.startsWith("https://") || iconURL.startsWith("http://") || iconURL.startsWith("tauri://"))){
} else if(iconURL && (iconURL.startsWith("https://") || iconURL.startsWith("http://")
|| iconURL.startsWith("tauri://") || iconURL.startsWith("asset://"))){
return iconURL;
}
return 'images/tab-img2.png'; // HTML icon
Expand Down
7 changes: 4 additions & 3 deletions src/extensibility/Package.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ define(function (require, exports, module) {
ExtensionLoader.loadExtension(result.name, {
// On Windows, it looks like Node converts Unix-y paths to backslashy paths.
// We need to convert them back.
baseUrl: window.fsServerUrl.slice(0, -1) + result.installedTo
baseUrl: window.Phoenix.VFS.getVirtualServingURLForPath(result.installedTo)
}, "main").then(function () {
d.resolve(result);
}, function () {
Expand Down Expand Up @@ -241,11 +241,12 @@ define(function (require, exports, module) {
d.reject(Errors.MALFORMED_URL);
return d.promise();
}
if (!(parsed.protocol === "http:" || parsed.protocol === "https:" || parsed.protocol === "tauri:")) {
if (!(parsed.protocol === "http:" || parsed.protocol === "https:"
|| parsed.protocol === "tauri:" || parsed.protocol === "asset:")) {
d.reject(Errors.UNSUPPORTED_PROTOCOL);
return d.promise();
}

parsed.filename = FileUtils.convertWindowsPathToUnixPath(parsed.filename);
const urlInfo = { url: url, parsed: parsed, filenameHint: parsed.filename, destinationDirectory };
githubURLFilter(urlInfo);

Expand Down
15 changes: 13 additions & 2 deletions src/extensions/default/DebugCommands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,11 @@ define(function (require, exports, module) {
}

function _openVirtualServer() {
Phoenix.app.openURLInPhoenixWindow(window.fsServerUrl, {
const virtualServingURL = Phoenix.VFS.getVirtualServingURLForPath("/");
if(!virtualServingURL) {
throw new Error("Unable to find virtual server!");
}
Phoenix.app.openURLInPhoenixWindow(virtualServingURL, {
preferTabs: true
});
}
Expand Down Expand Up @@ -775,13 +779,20 @@ define(function (require, exports, module) {
menu.addMenuItem(DEBUG_LIVE_PREVIEW_LOGGING);
menu.addMenuDivider();
menu.addMenuItem(DEBUG_OPEN_VFS);
menu.addMenuItem(DEBUG_OPEN_VIRTUAL_SERVER);
menu.addMenuItem(DEBUG_OPEN_VIRTUAL_SERVER, undefined, undefined, undefined, {
hideWhenCommandDisabled: true
});
menu.addMenuDivider();
menu.addMenuItem(DEBUG_OPEN_PREFERENCES_IN_SPLIT_VIEW); // this command will enable defaultPreferences and brackets preferences to be open side by side in split view.
menu.addMenuItem(Commands.FILE_OPEN_KEYMAP); // this command is defined in core, but exposed only in Debug menu for now

CommandManager.get(DEBUG_UNLOAD_CURRENT_EXTENSION)
.setEnabled(extensionDevelopment.isProjectLoadedAsExtension());
if(window.__TAURI__) {
// in tauri, virtual server doesnt exist, extensions are served by tauri asset urls.
CommandManager.get(DEBUG_OPEN_VIRTUAL_SERVER)
.setEnabled(false);
}
_updateLogToConsoleMenuItemChecked();
// exposed for convenience, but not official API
exports._runUnitTests = _runUnitTests;
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/default/HTMLCodeHints/HTMLJumpToDef.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ define(function (require, exports, module) {
};

function _openFile(fileRelativePath, mainDocPath) {
if(fileRelativePath.startsWith("http://") || fileRelativePath.startsWith("https://")){
if(fileRelativePath.startsWith("http://") || fileRelativePath.startsWith("https://")
|| fileRelativePath.startsWith("tauri://") || fileRelativePath.startsWith("asset://")){
return FileViewController.openAndSelectDocument(fileRelativePath, FileViewController.PROJECT_MANAGER);
}
const targetPath = path.resolve(mainDocPath, fileRelativePath);
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/Phoenix-live-preview/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ define(function (require, exports, module) {
<iframe id="panel-live-preview-frame" title="Live Preview" style="border: none"
width="100%" height="100%" seamless="true"
src='about:blank'
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-pointer-lock allow-presentation">
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-pointer-lock">
</iframe>
`;

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/default/Phoenix-live-preview/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div style="width: 3px;"></div>
<iframe id="panel-live-preview-frame" title="Live Preview" style="border: none"
width="100%" height="100%" seamless="true" srcdoc='<img width="50px" src="styles/images/Spinner-1s-200px.svg">'
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-pointer-lock allow-presentation">
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-modals allow-pointer-lock">
</iframe>
</div>
</div>
6 changes: 4 additions & 2 deletions src/extensions/default/Phoenix/newly-added-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ define(function (require, exports, module) {
if(!Phoenix.firstBoot && !window.testEnvironment){
_showNewUpdatesIfPresent();
}
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "cache", "doRefresh");
window.refreshServiceWorkerCache(_cacheUpdatedCB);
if(!Phoenix.browser.isTauri) {
Metrics.countEvent(Metrics.EVENT_TYPE.PLATFORM, "cache", "doRefresh");
window.refreshServiceWorkerCache(_cacheUpdatedCB);
}
};
});
2 changes: 1 addition & 1 deletion src/extensions/default/QuickView/ImagePreviewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ define(function (require, exports, module) {
extensionlessImagePreview; // Whether to try and preview extensionless URLs

// List of protocols which we will support for image preview urls
let validProtocols = ["data:", "http:", "https:", "tauri:", "ftp:", "file:"];
let validProtocols = ["data:", "http:", "https:", "tauri:", "asset:", "ftp:", "file:"];

prefs = PreferencesManager.getExtensionPrefs("quickview");

Expand Down
Loading
Loading