Skip to content

Commit

Permalink
test signing in for playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
vilnor committed May 24, 2024
1 parent 993ad8a commit 43346db
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions integration_tests/frontend/test_full_e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import re
from ..base import BaseCase
from playwright.sync_api import sync_playwright, expect


class HomePage(BaseCase):
def setUp(self):
self.p = sync_playwright().start()
self.browser = self.p.chromium.launch()
self.context = self.browser.new_context()
self.page = self.context.new_page()
self.page.goto("http://frontend:3000")

def tearDown(self):
self.page.close()
self.context.close()
self.browser.close()
self.p.stop()


def test_e2e(self):
# Sign in as admin user
self.page.get_by_role("link", name="Sign in").click()
self.page.get_by_label("Email address*").click()
self.page.get_by_label("Email address*").fill("[email protected]")
self.page.get_by_label("Password*").click()
self.page.get_by_label("Password*").fill("Admin_Password")
self.page.get_by_role("button", name="Continue", exact=True).click()

# Check that the user is redirected to the home page which shows a greeting
# <greeting>, admin
expect(self.page.locator("body")).to_contain_text(", admin")

# Go to courses
self.page.get_by_role("link", name="Courses").click()

# Expect to see the add courses button as admin
expect(self.page.get_by_role("link", name="Add Course")).to_be_visible()

# Add a course
self.page.get_by_role("link", name="Add Course").click()
expect(self.page.url).to_equal("http://frontend:3000/courses/add")
expect(self.page.get_by_text("Add Course")).to_be_visible()

# Fill in form
self.page.locator("input[name=\"courseCode\"]").click()
self.page.locator("input[name=\"courseCode\"]").fill("CSSE6400")
self.page.locator("input[name=\"courseName\"]").click()
self.page.locator("input[name=\"courseName\"]").fill("Software Architectures")
self.page.locator("textarea[name=\"courseDescription\"]").click()
self.page.locator("textarea[name=\"courseDescription\"]").fill("My favourite course :)")
self.page.get_by_role("button", name="Submit").click()

# Expect to be redirected to the courses page on submit
expect(self.page.url).to_equal("http://frontend:3000/courses")

0 comments on commit 43346db

Please sign in to comment.