Skip to content

Commit

Permalink
consolidated typescript tests in to describe block, added rest of cur…
Browse files Browse the repository at this point in the history
…rent tests to dotnet implementation
  • Loading branch information
KungRaseri committed Dec 11, 2023
1 parent 7754e57 commit 3a25cdb
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 38 deletions.
4 changes: 3 additions & 1 deletion dotnet/Playwright.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
global using NUnit.Framework;
global using NUnit.Framework;
global using Microsoft.Playwright;
global using Microsoft.Playwright.NUnit;
38 changes: 34 additions & 4 deletions dotnet/Playwright.Tests/the-internet/TheInternetTests.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
using NUnit.Framework.Constraints;

namespace Playwright.Tests;

public class TheInternetTests
[Parallelizable(ParallelScope.Self)]
[TestFixture]
public class TheInternetTests : PageTest
{
[SetUp]
public void Setup()
public async Task Setup()
{
await Page.GotoAsync("http://the-internet.herokuapp.com/");
}

[Test]
public async Task ABTesting()
{
await Page.GetByRole(AriaRole.Link, new() { Name = "A/B Testing" }).ClickAsync();

await Expect(Page.GetByRole(AriaRole.Heading)).ToContainTextAsync("A/B Test");
await Expect(Page.GetByRole(AriaRole.Paragraph)).ToContainTextAsync("Also known as split testing. This is a way in which businesses are able to simultaneously test and learn different versions of a page to see which text and/or functionality works best towards a desired outcome (e.g. a user action such as a click-through).");
}

[Test]
public async Task AddAndRemoveElements()
{
await Page.GetByRole(AriaRole.Link, new() {Name = "Add/Remove Elements"}).ClickAsync();

await Page.GetByRole(AriaRole.Button, new() {Name = "Add Element"}).ClickAsync();
await Page.GetByRole(AriaRole.Button, new() {Name = "Add Element"}).ClickAsync();
await Page.GetByRole(AriaRole.Button, new() {Name = "Add Element"}).ClickAsync();

await Expect(Page.GetByRole(AriaRole.Button, new() {Name = "Delete"})).ToHaveCountAsync(3);

await Page.GetByRole(AriaRole.Button, new() {Name = "delete"}).Nth(1).ClickAsync();

await Expect(Page.GetByRole(AriaRole.Button, new() {Name = "Delete"})).ToHaveCountAsync(2);
}

[Test]
public void Test1()
public async Task BasicAuthentication()
{
Assert.Pass();
await Page.GetByRole(AriaRole.Link, new() {Name = "Basic Auth"}).ClickAsync();
}
}
9 changes: 0 additions & 9 deletions typescript/tests/the-internet/abtesting-codegen.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions typescript/tests/the-internet/addremoveelements-codegen.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions typescript/tests/the-internet/basicauth-codegen.spec.ts

This file was deleted.

30 changes: 30 additions & 0 deletions typescript/tests/the-internet/theInternet-suite.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { test, expect } from '@playwright/test';

test.describe("The Internet", () => {
test.beforeEach(async ({ page }) => {
await page.goto('http://the-internet.herokuapp.com/');
})
test('A/B Testing - with `codegen`', async ({ page }) => {
await page.getByRole('link', { name: 'A/B Testing' }).click();

await expect(page.getByRole('heading')).toContainText("A/B Test");
await expect(page.getByRole('paragraph')).toContainText('Also known as split testing. This is a way in which businesses are able to simultaneously test and learn different versions of a page to see which text and/or functionality works best towards a desired outcome (e.g. a user action such as a click-through).');
});

test('Add/Remove Elements', async ({ page }) => {
await page.getByRole('link', { name: 'Add/Remove Elements' }).click();
await page.getByRole('button', { name: 'Add Element' }).click();
await page.getByRole('button', { name: 'Add Element' }).click();
await page.getByRole('button', { name: 'Add Element' }).click();

expect(page.getByRole('button', { name: 'Delete' })).toHaveCount(3);

await page.getByRole('button', { name: 'Delete' }).nth(1).click();

expect(page.getByRole('button', { name: 'Delete' })).toHaveCount(2);
});

test('Basic Authentication', async ({ page }) => {

});
})

0 comments on commit 3a25cdb

Please sign in to comment.