25
.github/workflows/test.yml
vendored
25
.github/workflows/test.yml
vendored
@@ -198,3 +198,28 @@ jobs:
|
|||||||
run: pip install tox
|
run: pip install tox
|
||||||
- name: Lint
|
- name: Lint
|
||||||
run: tox -c pyproject.toml -e flake8,mypy,isort
|
run: tox -c pyproject.toml -e flake8,mypy,isort
|
||||||
|
|
||||||
|
integ-test:
|
||||||
|
timeout-minutes: 60
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: test-ubuntu-python-newest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
- name: Install uv
|
||||||
|
run: pip install uv
|
||||||
|
- name: Install Playwright Browsers
|
||||||
|
run: uv run --extra integ_test playwright install --with-deps
|
||||||
|
- name: Run Integration Tests
|
||||||
|
run: uv run --extra integ_test pytest --junitxml=pytest-results.xml integ_tests
|
||||||
|
- uses: mikepenz/action-junit-report@v6
|
||||||
|
if: ${{ failure() && (github.event.pull_request.head.repo.full_name != github.repository) }}
|
||||||
|
with:
|
||||||
|
report_paths: 'pytest-results.xml'
|
||||||
|
annotate_only: true # forked repo cannot write to checks so just do annotations
|
||||||
|
- uses: mikepenz/action-junit-report@v6
|
||||||
|
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
|
||||||
|
with:
|
||||||
|
report_paths: 'pytest-results.xml'
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -23,6 +23,6 @@ coverage.xml
|
|||||||
.vscode
|
.vscode
|
||||||
.sass-cache
|
.sass-cache
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
|
pytest-results.xml
|
||||||
pytestdebug.log
|
pytestdebug.log
|
||||||
uv.lock
|
uv.lock
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
|
|||||||
expect(
|
expect(
|
||||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RO']")
|
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RO']")
|
||||||
).to_be_visible()
|
).to_be_visible()
|
||||||
|
page.once("dialog", lambda dialog: dialog.accept())
|
||||||
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
|
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
|
||||||
expect(
|
expect(
|
||||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
||||||
@@ -40,6 +41,7 @@ def test_create_and_delete_share_by_key(page: Page, radicale_server: str) -> Non
|
|||||||
expect(
|
expect(
|
||||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RW']")
|
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden) img[alt='RW']")
|
||||||
).to_be_visible()
|
).to_be_visible()
|
||||||
|
page.once("dialog", lambda dialog: dialog.accept())
|
||||||
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
|
page.click('tr:not(.hidden) button[data-name="delete"]', strict=True)
|
||||||
expect(
|
expect(
|
||||||
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
page.locator("tr[data-name='sharetokenrowtemplate']:not(.hidden)")
|
||||||
|
|||||||
@@ -25,97 +25,98 @@ import { LoadingScene } from "./LoadingScene.js";
|
|||||||
import { delete_collection } from "./api.js";
|
import { delete_collection } from "./api.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
|
||||||
* @implements {Scene}
|
* @implements {Scene}
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @param {Collection} collection
|
* @param {Collection} collection
|
||||||
*/
|
*/
|
||||||
export function DeleteCollectionScene(user, password, collection) {
|
export class DeleteCollectionScene {
|
||||||
/** @type {HTMLElement} */ let html_scene = document.getElementById("deletecollectionscene");
|
constructor(user, password, collection) {
|
||||||
/** @type {HTMLElement} */ let title_form = html_scene.querySelector("[data-name=title]");
|
/** @type {HTMLElement} */ let html_scene = document.getElementById("deletecollectionscene");
|
||||||
/** @type {HTMLElement} */ let error_form = html_scene.querySelector("[data-name=error]");
|
/** @type {HTMLElement} */ let title_form = html_scene.querySelector("[data-name=title]");
|
||||||
/** @type {HTMLInputElement} */ let confirmation_txt = html_scene.querySelector("[data-name=confirmationtxt]");
|
/** @type {HTMLElement} */ let error_form = html_scene.querySelector("[data-name=error]");
|
||||||
/** @type {HTMLElement} */ let delete_confirmation_lbl = html_scene.querySelector("[data-name=deleteconfirmationtext]");
|
/** @type {HTMLInputElement} */ let confirmation_txt = html_scene.querySelector("[data-name=confirmationtxt]");
|
||||||
/** @type {HTMLElement} */ let delete_btn = html_scene.querySelector("[data-name=delete]");
|
/** @type {HTMLElement} */ let delete_confirmation_lbl = html_scene.querySelector("[data-name=deleteconfirmationtext]");
|
||||||
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
|
/** @type {HTMLElement} */ let delete_btn = html_scene.querySelector("[data-name=delete]");
|
||||||
|
/** @type {HTMLElement} */ let cancel_btn = html_scene.querySelector("[data-name=cancel]");
|
||||||
|
|
||||||
delete_confirmation_lbl.innerHTML = DELETE_CONFIRMATION_TEXT;
|
delete_confirmation_lbl.innerHTML = DELETE_CONFIRMATION_TEXT;
|
||||||
confirmation_txt.value = "";
|
confirmation_txt.value = "";
|
||||||
confirmation_txt.addEventListener("keydown", onkeydown);
|
confirmation_txt.addEventListener("keydown", onkeydown);
|
||||||
|
|
||||||
/** @type {?number} */ let scene_index = null;
|
/** @type {?number} */ let scene_index = null;
|
||||||
/** @type {?XMLHttpRequest} */ let delete_req = null;
|
/** @type {?XMLHttpRequest} */ let delete_req = null;
|
||||||
let error = "";
|
let error = "";
|
||||||
|
|
||||||
function ondelete() {
|
function ondelete() {
|
||||||
let confirmation_text_value = confirmation_txt.value;
|
let confirmation_text_value = confirmation_txt.value;
|
||||||
if(confirmation_text_value != DELETE_CONFIRMATION_TEXT){
|
if (confirmation_text_value != DELETE_CONFIRMATION_TEXT) {
|
||||||
alert("Please type the confirmation text to delete this collection.");
|
alert("Please type the confirmation text to delete this collection.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
let loading_scene = new LoadingScene();
|
||||||
|
push_scene(loading_scene, false);
|
||||||
|
delete_req = delete_collection(user, password, collection, function (error1) {
|
||||||
|
if (scene_index === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete_req = null;
|
||||||
|
if (error1) {
|
||||||
|
error = error1;
|
||||||
|
pop_scene(scene_index);
|
||||||
|
} else {
|
||||||
|
pop_scene(scene_index - 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
let loading_scene = new LoadingScene();
|
function oncancel() {
|
||||||
push_scene(loading_scene, false);
|
try {
|
||||||
delete_req = delete_collection(user, password, collection, function(error1) {
|
pop_scene(scene_index - 1);
|
||||||
if (scene_index === null) {
|
} catch (err) {
|
||||||
return;
|
console.error(err);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onkeydown(event) {
|
||||||
|
if (event.keyCode !== 13) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ondelete();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.show = function () {
|
||||||
|
this.release();
|
||||||
|
scene_index = scene_stack.length - 1;
|
||||||
|
html_scene.classList.remove("hidden");
|
||||||
|
title_form.textContent = collection.displayname || collection.href;
|
||||||
|
delete_btn.onclick = ondelete;
|
||||||
|
cancel_btn.onclick = oncancel;
|
||||||
|
if (error) {
|
||||||
|
error_form.textContent = "Error: " + error;
|
||||||
|
error_form.classList.remove("hidden");
|
||||||
|
} else {
|
||||||
|
error_form.classList.add("hidden");
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
this.hide = function () {
|
||||||
|
html_scene.classList.add("hidden");
|
||||||
|
cancel_btn.onclick = null;
|
||||||
|
delete_btn.onclick = null;
|
||||||
|
};
|
||||||
|
this.release = function () {
|
||||||
|
scene_index = null;
|
||||||
|
if (delete_req !== null) {
|
||||||
|
delete_req.abort();
|
||||||
delete_req = null;
|
delete_req = null;
|
||||||
if (error1) {
|
}
|
||||||
error = error1;
|
};
|
||||||
pop_scene(scene_index);
|
|
||||||
} else {
|
|
||||||
pop_scene(scene_index - 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch(err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function oncancel() {
|
|
||||||
try {
|
|
||||||
pop_scene(scene_index - 1);
|
|
||||||
} catch(err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onkeydown(event){
|
|
||||||
if (event.keyCode !== 13) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ondelete();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.show = function() {
|
|
||||||
this.release();
|
|
||||||
scene_index = scene_stack.length - 1;
|
|
||||||
html_scene.classList.remove("hidden");
|
|
||||||
title_form.textContent = collection.displayname || collection.href;
|
|
||||||
delete_btn.onclick = ondelete;
|
|
||||||
cancel_btn.onclick = oncancel;
|
|
||||||
if(error){
|
|
||||||
error_form.textContent = "Error: " + error;
|
|
||||||
error_form.classList.remove("hidden");
|
|
||||||
}else{
|
|
||||||
error_form.classList.add("hidden");
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
this.hide = function() {
|
|
||||||
html_scene.classList.add("hidden");
|
|
||||||
cancel_btn.onclick = null;
|
|
||||||
delete_btn.onclick = null;
|
|
||||||
};
|
|
||||||
this.release = function() {
|
|
||||||
scene_index = null;
|
|
||||||
if (delete_req !== null) {
|
|
||||||
delete_req.abort();
|
|
||||||
delete_req = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
@@ -28,14 +28,6 @@ import { Collection } from "./models.js";
|
|||||||
import { Scene, pop_scene, scene_stack } from "./scene_manager.js";
|
import { Scene, pop_scene, scene_stack } from "./scene_manager.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
|
||||||
* @implements {Scene}
|
|
||||||
* @param {string} user
|
|
||||||
* @param {string} password
|
|
||||||
* @param {Collection} collection The collection on which to edit sharing setting. Must exist.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @implements {Scene}
|
* @implements {Scene}
|
||||||
* @param {string} user
|
* @param {string} user
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
@@ -125,10 +117,10 @@ function add_share_rows(user, password, collection, shares) {
|
|||||||
shares.forEach(function (share) {
|
shares.forEach(function (share) {
|
||||||
let pathortoken = share["PathOrToken"] || "";
|
let pathortoken = share["PathOrToken"] || "";
|
||||||
let pathmapped = share["PathMapped"] || "";
|
let pathmapped = share["PathMapped"] || "";
|
||||||
if (
|
if ((
|
||||||
collection.href.includes(pathmapped) ||
|
collection.href.includes(pathmapped) ||
|
||||||
collection.href.includes(pathortoken)
|
collection.href.includes(pathortoken)
|
||||||
) {
|
) && (share["ShareType"] === "token")) {
|
||||||
let node = /** @type {HTMLElement} */ (template.cloneNode(true));
|
let node = /** @type {HTMLElement} */ (template.cloneNode(true));
|
||||||
node.classList.remove("hidden");
|
node.classList.remove("hidden");
|
||||||
/** @type {HTMLInputElement} */ let pathortoken_form = node.querySelector("[data-name=pathortoken]");
|
/** @type {HTMLInputElement} */ let pathortoken_form = node.querySelector("[data-name=pathortoken]");
|
||||||
@@ -147,10 +139,13 @@ function add_share_rows(user, password, collection, shares) {
|
|||||||
}
|
}
|
||||||
/** @type {HTMLElement} */ let delete_btn = node.querySelector("[data-name=delete]");
|
/** @type {HTMLElement} */ let delete_btn = node.querySelector("[data-name=delete]");
|
||||||
delete_btn.onclick = function () {
|
delete_btn.onclick = function () {
|
||||||
|
if (!confirm("Are you sure you want to delete share " + pathortoken + "?")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
delete_share_by_token(
|
delete_share_by_token(
|
||||||
user,
|
user,
|
||||||
password,
|
password,
|
||||||
share["PathOrToken"],
|
pathortoken,
|
||||||
function () {
|
function () {
|
||||||
update_share_list(user, password, collection);
|
update_share_list(user, password, collection);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user