Skip to content

Commit

Permalink
feat: lab4
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaRduTP committed Mar 21, 2024
1 parent 178c0e0 commit 026e2de
Show file tree
Hide file tree
Showing 8 changed files with 1,284 additions and 10 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/lab-autograding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
const pr = await github.rest.pulls.get({ owner, repo, pull_number: issue_number });
const labels = pr.data.labels;
const lab = labels.find((label) => label.name.startsWith('lab'));
if (!lab) {
if (!lab) {
core.setFailed('No lab label found on the PR.');
return { number: 0 };
}
Expand All @@ -44,12 +44,10 @@ jobs:
const files = await github.rest.pulls.listFiles({ owner, repo, pull_number: issue_number });
const changedFiles = files.data.map((file) => file.filename);
const allowedFiles = [
`lab${labNumber}/main_test.js`,
];
// if (!changedFiles.every((file) => allowedFiles.includes(file))) {
// core.setFailed('The PR contains changes to files other than the allowed files.');
// }
const allowedFileRegex = /^lab\d+\/main_test.js$/;
if (!changedFiles.every((file) => allowedFileRegex.test(file))) {
core.setFailed('The PR contains changes to files other than the allowed files.');
}
return labNumber;
- name: Grading
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
29 changes: 29 additions & 0 deletions lab4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Lab4

## Introduction

In this lab, you will write tests in `main_test.js`. You can learn how to use [Puppeteer](https://pptr.dev/) to tests a web UI.

## Preparation (Important!!!)

1. Sync fork your branch (e.g., `SQLab:311XXXXXX`)
2. `git checkout -b lab4` (**NOT** your student ID !!!)

## Requirement

1. (100%) Goto https://pptr.dev/, type `chipi chipi chapa chapa` into the search box, click on **1st** result in the **Docs** section, and print the title.

For the detailed steps and hints, please check the slide of this lab.

You can run `validate.sh` in your local to test if you satisfy the requirements.

Please note that you must not alter files other than `main_test.js`. You will get 0 points if

1. you modify other files to achieve requirements.
2. you can't pass all CI on your PR.

## Submission

You need to open a pull request to your branch (e.g. 311XXXXXX, your student number) and contain the code that satisfies the abovementioned requirements.

Moreover, please submit the URL of your PR to E3. Your submission will only be accepted when you present at both places.
22 changes: 22 additions & 0 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const puppeteer = require('puppeteer');

(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch();
const page = await browser.newPage();

// Navigate the page to a URL
await page.goto('https://pptr.dev/');

// Hints:
// Click search button
// Type into search box
// Wait for search result
// Get the `Docs` result section
// Click on first result in `Docs` section
// Locate the title
// Print the title

// Close the browser
await browser.close();
})();
Loading

0 comments on commit 026e2de

Please sign in to comment.