mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
add e2e test using playwright (#44)
This commit is contained in:
committed by
GitHub
parent
0fceaf6918
commit
dc68d511bd
34
tests/home.spec.js
Normal file
34
tests/home.spec.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
const { HomePage } = require('../tests/pages/home.page');
|
||||
|
||||
test.describe('bruno e2e test', () => {
|
||||
let homePage;
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
homePage = new HomePage(page);
|
||||
|
||||
await homePage.open();
|
||||
await expect(page).toHaveURL('/');
|
||||
await expect(page).toHaveTitle(/bruno/);
|
||||
});
|
||||
|
||||
test('user should be able to load & use sample collection', async () => {
|
||||
await homePage.loadSampleCollection();
|
||||
|
||||
await homePage.getUsers();
|
||||
await expect(homePage.statusRequestSuccess).toBeVisible();
|
||||
|
||||
await homePage.getSingleUser();
|
||||
await expect(homePage.statusRequestSuccess).toBeVisible();
|
||||
|
||||
await homePage.getUserNotFound();
|
||||
await expect(homePage.statusRequestNotFound).toBeVisible();
|
||||
|
||||
await homePage.createUser();
|
||||
await expect(homePage.statusRequestCreated).toBeVisible();
|
||||
|
||||
await homePage.updateUser();
|
||||
await expect(homePage.statusRequestSuccess).toBeVisible();
|
||||
});
|
||||
|
||||
});
|
||||
50
tests/pages/home.page.js
Normal file
50
tests/pages/home.page.js
Normal file
@@ -0,0 +1,50 @@
|
||||
exports.HomePage = class HomePage {
|
||||
constructor(page) {
|
||||
this.page = page;
|
||||
this.loadSampleCollectionSelector = page.getByText('Load Sample Collection');
|
||||
this.sampeCollectionSelector = page.getByText('sample-collection');
|
||||
this.getUsersSelector = page.getByText('Users');
|
||||
this.getSingleUserSelector = page.getByText('Single User');
|
||||
this.getUserNotFoundSelector = page.getByText('User Not Found');
|
||||
this.postCreateSelector = page.getByText('Create');
|
||||
this.putUpdateSelector = page.getByText('Update');
|
||||
this.sendRequestButton = page.locator('div:nth-child(2) > .flex > svg');
|
||||
this.statusRequestSuccess = page.getByText('200 OK');
|
||||
this.statusRequestNotFound = page.getByText('404 Not Found');
|
||||
this.statusRequestCreated = page.getByText('201 Created');
|
||||
}
|
||||
|
||||
async open() {
|
||||
await this.page.goto('/');
|
||||
}
|
||||
|
||||
async loadSampleCollection() {
|
||||
await this.loadSampleCollectionSelector.click();
|
||||
}
|
||||
|
||||
async getUsers() {
|
||||
await this.sampeCollectionSelector.click();
|
||||
await this.getUsersSelector.click();
|
||||
await this.sendRequestButton.click();
|
||||
}
|
||||
|
||||
async getSingleUser() {
|
||||
await this.getSingleUserSelector.click();
|
||||
await this.sendRequestButton.click();
|
||||
}
|
||||
|
||||
async getUserNotFound() {
|
||||
await this.getUserNotFoundSelector.click();
|
||||
await this.sendRequestButton.click();
|
||||
}
|
||||
|
||||
async createUser() {
|
||||
await this.postCreateSelector.click();
|
||||
await this.sendRequestButton.click();
|
||||
}
|
||||
|
||||
async updateUser() {
|
||||
await this.putUpdateSelector.click();
|
||||
await this.sendRequestButton.click();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user