Skip to content

Commit

Permalink
feat: added new paste button, changed design of the links on the View…
Browse files Browse the repository at this point in the history
… Paste page to align with the other buttons
  • Loading branch information
nekhvoya authored and supakeen committed Mar 9, 2024
1 parent 0965564 commit b08e58e
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 16 deletions.
46 changes: 45 additions & 1 deletion src/asset/pinnwand.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ section.file-part div.file-meta {
margin-bottom: .0625rem;
}

section.paste-submit {
section.paste-submit, div.paste-actions {
background-color: var(--color1);
padding: .5rem;
margin-bottom: .5rem;
Expand Down Expand Up @@ -246,6 +246,50 @@ button.cancel:hover {
border: .0625rem solid var(--color3);
}

div.paste-actions {
background-color: var(--color1);
padding: .5rem;
margin-bottom: .5rem;

.handle-paste {
box-sizing: border-box;
border: .0625rem solid var(--color3);
padding: .4rem 1.4rem;
margin: 0 .2rem;
background: var(--color1);
color: var(--color3);
cursor: pointer;
font-size: 1.1rem;
text-align: center;
text-decoration: none;
}
.handle-paste:hover {
color: var(--color1);
background: var(--color3);
border: .0625rem solid var(--color3);
}
.handle-paste.remove-now {
float: right;
}
.new-paste {
box-sizing: border-box;
border: .0625rem solid var(--color3);
padding: .4rem 1.4rem;
margin: 0 .2rem;
background: var(--color3);
color: var(--color1);
cursor: pointer;
font-size: 1.1rem;
text-align: center;
text-decoration: none;
}
.new-paste:hover {
color: var(--color3);
background: var(--color1);
border: .0625rem solid var(--color3);
}
}

article, div.paste-meta {
background-color: var(--color1);
padding: .5rem;
Expand Down
Binary file modified src/pinnwand/static/pinnwand.css
Binary file not shown.
32 changes: 18 additions & 14 deletions src/pinnwand/template/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

{% block body %}
<main class="paste-show{% if len(paste.files) > 1 %} multiple{% end %}">
<div class="paste-meta">
{% if paste.exp_date %}
<p>This paste expires on <span>{{ paste.exp_date }}</span>.
{% else %}
<p>This paste <span>never</span> expires.
{% end %}
{% if can_delete %}
<a href="/remove/{{ paste.removal }}">Remove now</a>.
{% end %}
<div class="paste-actions">
<a class="new-paste" href="/">New paste</a>

<a href="/repaste/{{ paste.slug }}">Repaste</a>, or
<a href="/download-archive/{{ paste.slug }}">download</a> this paste.
<a class="handle-paste" href="/repaste/{{ paste.slug }}">Repaste</a>
<a class="handle-paste" href="/download-archive/{{ paste.slug }}">Download</a>

<button class="btn-link" id="toggle-word-wrap">Toggle word wrap</button>.
<button class="handle-paste" class="btn-link" id="toggle-word-wrap">Toggle word wrap</button>

Pasted through <em>{{ paste.src }}</em>.
</p>
{% if can_delete %}
<a class="handle-paste remove-now" href="/remove/{{ paste.removal }}">Remove now</a>
{% end %}
</div>
<div class="file-container">
<div class="files">
Expand Down Expand Up @@ -51,5 +45,15 @@
{% end %}
-->
</div>
<div class="paste-meta">
{% if paste.exp_date %}
<p>This paste expires on <span>{{ paste.exp_date }}</span>.
{% else %}
<p>This paste <span>never</span> expires.
{% end %}

Pasted through <em>{{ paste.src }}</em>.
</p>
</div>
</main>
{% end %}
7 changes: 6 additions & 1 deletion test/e2e/pageobjects/view_paste_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, page: Page) -> None:
"link", name="download"
)
self.download_archive_button = self.page.locator(
".paste-meta"
".paste-actions"
).get_by_role("link", name="download")
self.repaste_button = page.get_by_role("link", name="Repaste")
self.remove_now_button = page.get_by_role("link", name="Remove now")
Expand All @@ -27,6 +27,7 @@ def __init__(self, page: Page) -> None:
paste_number
).locator(".sourcetable td.code code")
self.toggle_word_wrap_button = page.locator("#toggle-word-wrap")
self.new_paste_button = page.locator(".new-paste")

def click_remove_now_button(self):
log.info("Clicking Remove Now Button")
Expand Down Expand Up @@ -72,6 +73,10 @@ def click_toggle_word_wrap_button(self):
log.info("Clicking Toggle Word Wrap Button")
self.toggle_word_wrap_button.click()

def click_new_paste_button(self):
log.info("Clicking New Paste Button")
self.new_paste_button.click()

def get_paste_slug(self):
log.info("Getting slug from paste url")
return self.page.url.split("/").pop()
Expand Down
32 changes: 32 additions & 0 deletions test/e2e/testscenarios/test_new_paste.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from test.e2e.conftest import create_paste_page
from test.e2e.pageobjects.create_paste_page import CreatePastePage
from test.e2e.pageobjects.view_paste_page import ViewPastePage

import pytest
from playwright.sync_api import Page, Playwright


@pytest.mark.e2e
def test_create_single_paste(
page: Page, playwright: Playwright, create_paste_page: CreatePastePage
):
first_pasted_text = create_paste_page.paste_random_text()
create_paste_page.click_submit()

view_paste_page = ViewPastePage(page)
view_paste_page.should_be_opened()
first_paste_url = view_paste_page.current_url()

view_paste_page.click_new_paste_button()
create_paste_page.should_be_opened()

second_pasted_text = create_paste_page.paste_random_text()
create_paste_page.click_submit()
second_paste_url = view_paste_page.current_url()
assert first_paste_url != second_paste_url

view_paste_page.open(first_paste_url)
view_paste_page.should_have_pasted_text(first_pasted_text)

view_paste_page.open(second_paste_url)
view_paste_page.should_have_pasted_text(second_pasted_text)

0 comments on commit b08e58e

Please sign in to comment.