-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |