Skip to content

Commit

Permalink
Outlining more of the internet tests, slight refactor and updating .N…
Browse files Browse the repository at this point in the history
…ET tests/assertions
  • Loading branch information
KungRaseri committed Nov 4, 2024
1 parent aff6c83 commit 757bfe9
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 32 deletions.
8 changes: 4 additions & 4 deletions dotnet/Playwright.Tests/swapi/GetPlanetsResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace Playwright.Tests.swapi
{
public class GetPlanetsResult
{
public int count;
public string? next;
public string? previous;
public Planet[] results;
public required int count;
public required string? next;
public required string? previous;
public required Planet[] results;

}
}
28 changes: 14 additions & 14 deletions dotnet/Playwright.Tests/swapi/Planet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ namespace Playwright.Tests.swapi
{
public class Planet
{
public string name;
public string diameter;
public string rotationPeriod;
public string orbitalPeriod;
public string gravity;
public string population;
public string climate;
public string terrain;
public string surface_water;
public string[] residents;
public string[] films;
public string url;
public DateTime created;
public DateTime edited;
public required string name;
public required string diameter;
public required string rotationPeriod;
public required string orbitalPeriod;
public required string gravity;
public required string population;
public required string climate;
public required string terrain;
public required string surface_water;
public required string[] residents;
public required string[] films;
public required string url;
public required DateTime created;
public required DateTime edited;
}
}
22 changes: 13 additions & 9 deletions dotnet/Playwright.Tests/swapi/StarWarsAPITests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

using System.Text.Json;
using Newtonsoft.Json;
using Playwright.Tests.swapi;

Expand All @@ -8,7 +7,7 @@ namespace Playwright.Tests;
[TestFixture]
public class StarWarsAPITests : PlaywrightTest
{
private IAPIRequestContext Request = null;
public required IAPIRequestContext Request;

[SetUp]
public async Task Setup()
Expand All @@ -32,10 +31,12 @@ public async Task GetPlanets_ShouldReturnGetPlanetsResult()

var planets = JsonConvert.DeserializeObject<GetPlanetsResult>(planetsResult);

Assert.That(planets?.count, Is.EqualTo(60));
Assert.That(planets?.results.Length, Is.EqualTo(10));

Assert.True(response.Ok);
Assert.Multiple(() =>
{
Assert.That(planets?.count, Is.EqualTo(60));
Assert.That(planets?.results.Length, Is.EqualTo(10));
Assert.That(response.Ok, Is.True);
});
}

[Test]
Expand All @@ -48,10 +49,13 @@ public async Task GetPlanet_ShouldReturnPlanet()
var planet = JsonConvert.DeserializeObject<Planet>(planetResult);

Assert.That(planet, Is.Not.Null);
Assert.That(planet.name, Is.EqualTo("Tatooine"));
Assert.That(planet.population, Is.EqualTo("200000"));

Assert.True(response.Ok);
Assert.Multiple(() =>
{
Assert.That(planet.name, Is.EqualTo("Tatooine"));
Assert.That(planet.population, Is.EqualTo("200000"));
Assert.That(response.Ok, Is.True);
});
}

private async Task CreateAPIRequestContext()
Expand Down
13 changes: 13 additions & 0 deletions dotnet/Playwright.Tests/the-internet/TheInternetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,17 @@ public async Task BrokenImages()
{
await Page.GetByRole(AriaRole.Link, new() { Name = "Broken Images" }).ClickAsync();
}

[Test]
public async Task ChallengingDOM()
{
await Page.GetByRole(AriaRole.Link, new() { Name = "Challenging DOM" }).ClickAsync();
}

[Test]
public async Task Checkboxes()
{
await Page.GetByRole(AriaRole.Link, new() { Name = "Checkboxes" }).ClickAsync();

}
}
1 change: 1 addition & 0 deletions typescript/tests/swapi/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { test, expect } from '@playwright/test';

test('has title', async ({ page }) => {
Expand Down
17 changes: 12 additions & 5 deletions typescript/tests/the-internet/theInternet-suite.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';

test.describe("The Internet", () => {
test.beforeEach(async ({ page }) => {
test.beforeEach(async ({ page, browser }) => {
await page.goto('http://the-internet.herokuapp.com/');
});

Expand All @@ -27,11 +27,18 @@ test.describe("The Internet", () => {

test('Basic Authentication', async ({ page }) => {
await page.getByRole('link', { name: 'Basic Auth' }).click();

});

test('Broken Images', async ({page}) => {
await page.getByRole('link', {name: 'Broken Images'}).click();

test('Broken Images', async ({ page }) => {
await page.getByRole('link', { name: 'Broken Images' }).click();
})

test('Challenging DOM', async ({ page }) => {
await page.getByRole('link', { name: 'Challenging DOM' }).click();
})

test('Checkboxes', async ({ page }) => {
await page.getByRole('link', { name: 'Checkboxes' }).click();

})
})

0 comments on commit 757bfe9

Please sign in to comment.