Skip to content

Commit

Permalink
save work
Browse files Browse the repository at this point in the history
  • Loading branch information
lhf552004 committed Aug 10, 2024
1 parent 9db0286 commit 0450007
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Testing-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ npm run test:integration
```
npm run test:e2e
```

Run single test file

```
npx cross-env NODE_ENV=test npx playwright test "./test/e2e/create-quizitem.test.js"
```
31 changes: 29 additions & 2 deletions test/e2e/create-quizitem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,35 @@ test.describe("Admin user create quiz item", () => {
`a[href="http://localhost:3000/quizitem/quiz/GK/add-quiz-item"]`
);
await createQuizItemELement.click();
const quizTitle = await page.locator(`h3.page-title`);
const createQuizItemTitle = await page.locator(`h3.page-title`);
// Here, the text should be `Quiz ${quizname}`
await expect(quizTitle).toHaveText("Add Question to Your Quiz");
await expect(createQuizItemTitle).toHaveText("Add Question to Your Quiz");

const questionInput = await page.locator(`#question`);
questionInput.fill("Which is city is the captial of Germany");

const option1Input = await page.locator(`#answer-1`);
const option2Input = await page.locator(`#answer-2`);
const option3Input = await page.locator(`#answer-3`);
const option4Input = await page.locator(`#answer-4`);

const check1Input = await page.locator(`#check-answer-1`);
const createButton = await page.locator(
`button.btn.btn-primary.create-quiz-item-btn`
);

option1Input.fill("Berlin");
option2Input.fill("London");
option3Input.fill("Vienna");
option4Input.fill("Zurich");

check1Input.check();

createButton.click();

await page.waitForURL("http://localhost:3000/quiz/GK");
const quizTitle = await page.locator(`h1.text-center`);
// Here, the text should be `Quiz ${quizname}`
await expect(quizTitle).toHaveText("Quiz GK");
});
});

0 comments on commit 0450007

Please sign in to comment.