Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronPlave committed Mar 25, 2024
1 parent e87e505 commit 1675505
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
8 changes: 6 additions & 2 deletions e2e-tests/fixtures/Models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ export class Models {
this.updatePage(page);
}

async createModel() {
async createModel(modelName = '') {
await expect(this.tableRow).not.toBeVisible();
await this.fillInputName();
if (modelName) {
await this.fillInputName(modelName);
} else {
await this.fillInputName();
}
await this.fillInputVersion();
await this.fillInputFile();
await this.createButton.click();
Expand Down
30 changes: 30 additions & 0 deletions e2e-tests/tests/models.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import test, { expect, type BrowserContext, type Page } from '@playwright/test';
import { Constraints } from '../fixtures/Constraints.js';
import { Models } from '../fixtures/Models.js';
let context: BrowserContext;
let models: Models;
let constraints: Constraints;
let page: Page;

test.beforeAll(async ({ browser }) => {
context = await browser.newContext();
page = await context.newPage();
models = new Models(page);
constraints = new Constraints(page, models);
await models.goto();
});

Expand Down Expand Up @@ -71,5 +74,32 @@ test.describe.serial('Models', () => {
await expect(models.inputFile).toBeEmpty();
await expect(models.inputVersion).toBeEmpty();
await expect(models.inputName).toBeEmpty();

// Cleanup
await models.deleteModel();
});

test('Model creation errors should clear on page destroy', async () => {
// Create model
await models.createModel(models.modelName);

// Create model again with the same name
await models.fillInputName(models.modelName);
await models.fillInputVersion();
await models.fillInputFile();
await models.createButton.click();

// Expect an error to be present
await expect(models.alertError).toBeVisible();

// Navigate away and back
await constraints.goto();
await models.goto();

// Expect no error
await expect(models.alertError).not.toBeVisible();

// Cleanup
await models.deleteModel();
});
});

0 comments on commit 1675505

Please sign in to comment.