0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-03-14 18:35:08 +01:00

Docs collaboration - WIP

This commit is contained in:
Danilo Ješić 2023-06-15 16:43:26 +02:00
parent 49f0d7d815
commit 7e556304d4
4 changed files with 151 additions and 0 deletions

View file

@ -0,0 +1,34 @@
from playwright.sync_api import Playwright, sync_playwright
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
page.goto("http://nc/")
page.get_by_label("Account name or email").click()
page.get_by_label("Account name or email").fill("Crash")
page.get_by_label("Account name or email").press("Tab")
page.get_by_label("Password", exact=True).fill("Override")
page.get_by_label("Password", exact=True).press("Enter")
page.get_by_role("link", name="Files").click()
page.get_by_role("link", name="New file/folder menu").click()
page.get_by_role("link", name="New text file").click()
page.locator("#view9-input-file").fill("colab_meeting.md")
page.get_by_role("button", name="Submit").click()
page.get_by_role("listitem").filter(has_text="Meeting notes").locator("img").click()
page.get_by_role("button", name="Create a new file with the selected template").click()
page.get_by_text("# Meeting notes📅 15 January 2021, via Nextcloud Talk 👥 Julius, Vanessa, Jan, …").press("Escape")
page.get_by_role("link", name="Not favorited colab_meeting .md Share Actions").get_by_role("link", name="Share").click()
page.get_by_placeholder("Name, email, or Federated Cloud ID …").click()
page.get_by_placeholder("Name, email, or Federated Cloud ID …").fill("docs")
page.get_by_text("docs_dude").first.click()
page.close()
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)

34
nextcloud_create_user.py Normal file
View file

@ -0,0 +1,34 @@
import contextlib
from playwright.sync_api import Playwright, sync_playwright
def create_user(playwright: Playwright, username: str, password: str) -> None:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
page.goto("http://nc/")
page.get_by_label("Account name or email").click()
page.get_by_label("Account name or email").fill("Crash")
page.get_by_label("Account name or email").press("Tab")
page.get_by_label("Password", exact=True).fill("Override")
page.get_by_label("Password", exact=True).press("Enter")
with contextlib.suppress(Exception):
page.get_by_role("button", name="Close modal").click(timeout=15_000)
page.get_by_role("link", name="Open settings menu").click()
page.get_by_role("link", name="Users").click()
page.get_by_role("button", name="New user").click()
page.get_by_placeholder("Username").click()
page.get_by_placeholder("Username").fill(username)
page.get_by_placeholder("Username").press("Tab")
page.get_by_placeholder("Display name").press("Tab")
page.get_by_placeholder("Password", exact=True).fill(password)
page.get_by_role("button", name="Add a new user").click()
# ---------------------
page.close()
context.close()
browser.close()
with sync_playwright() as playwright:
create_user(playwright, username="docs_dude", password="docsrule!12")

View file

@ -0,0 +1,26 @@
from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=True)
context = browser.new_context()
page = context.new_page()
page.goto("http://nc/login")
page.get_by_label("Account name or email").click()
page.get_by_label("Account name or email").fill("docs_dude")
page.get_by_label("Account name or email").press("Tab")
page.get_by_label("Password", exact=True).fill("docsrule!12")
page.get_by_label("Password", exact=True).press("Enter")
page.get_by_role("button", name="Close modal").click(timeout=15_000)
page.get_by_role("link", name="Files").click()
page.get_by_role("link", name="Shares").click()
page.get_by_role("link", name="colab_meeting .md Shared by Crash Shared by Crash Actions").click()
page.close()
# ---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)

57
usage_scenario-docs.yml Normal file
View file

@ -0,0 +1,57 @@
---
name: Nextcloud - Docs
author: Danilo Jesic <danilo@green-coding.berlin>
version: 1
description: Installs the official Nextcloud image and collaborates on a document
compose-file: !include compose.yml
services:
gcb-playwright:
image: greencoding/gcb_playwright
setup-commands:
- cp /tmp/repo/nextcloud_install.py /tmp/nextcloud_install.py
- cp /tmp/repo/nextcloud_create_user.py /tmp/nextcloud_create_user.py
- cp /tmp/repo/nextcloud_create_doc_and_share.py /tmp/nextcloud_create_doc_and_share.py
- cp /tmp/repo/nextcloud_docs_collaboration.py /tmp/nextcloud_docs_collaboration.py
networks:
- nextcloud-setup-network
# volumes:
# - /tmp/.X11-unix:/tmp/.X11-unix
# environment:
# DISPLAY: ":0"
# We don't need the volumes are we don't want to persist any data
db:
volumes: []
networks:
- nextcloud-setup-network
nc:
volumes: []
networks:
- nextcloud-setup-network
networks:
nextcloud-setup-network:
flow:
- name: Install Nextcloud and collaborate on document
container: gcb-playwright
commands:
- type: console
command: python3 /tmp/nextcloud_install.py
note: Installing Nextcloud
read-notes-stdout: true
- type: console
command: python3 /tmp/nextcloud_create_user.py
note: Create user
read-notes-stdout: true
- type: console
command: python3 /tmp/nextcloud_create_doc_and_share.py
note: Create document and share
read-notes-stdout: true
- type: console
command: python3 /tmp/nextcloud_docs_collaboration.py
note: dev
read-notes-stdout: true