Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the broken and flaky playwright tests #12360

Merged
2 commits merged into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion frontend/testing/playwright/pages/DataModelPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,25 @@ export class DataModelPage extends BasePage {

public async selectFileToUpload(fileName: string): Promise<void> {
await this.page
.getByRole('toolbar')
.getByTestId(DataTestId.FileSelectorInput)
.first()
.setInputFiles(path.join(__dirname, fileName));
}

public async waitForDataModelToBeUploaded(): Promise<void> {
const spinner = this.page.getByText(this.textMock('app_data_modelling.uploading_xsd'));
await expect(spinner).toBeHidden();
}

public async getDataModelOptionValue(option: string): Promise<string> {
return await this.page.getByRole('option', { name: option }).getAttribute('value');
}

public async waitForDataModelToAppear(dataModelName: string): Promise<void> {
const dataModelButton = this.page.getByRole('button', { name: dataModelName, exact: true });
await expect(dataModelButton).toBeVisible();
}

public async waitForSuccessAlertToDisappear(): Promise<void> {
const successAlert = this.page.getByRole('alert', {
name: this.textMock('schema_editor.datamodel_generation_success_message'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ test('Allows to add a datamodel, include an object with custom name and fields i

// Add datamodel
await dataModelPage.clickOnCreateNewDataModelButton();
const dataModelName: string = 'datamodel';
const dataModelName: string = 'testdatamodel';
await dataModelPage.typeDataModelName(dataModelName);
await dataModelPage.clickOnCreateModelButton();
await dataModelPage.waitForDataModelToAppear(dataModelName);

// Add object
await dataModelPage.clickOnAddPropertyButton();
Expand Down Expand Up @@ -116,6 +117,8 @@ test('Allows to upload and then delete an XSD file', async ({ page, testAppName
const dataModelName: string = 'testdatamodel';
const dataModelFileName: string = `${dataModelName}.xsd`;
await dataModelPage.selectFileToUpload(dataModelFileName);
await dataModelPage.waitForDataModelToBeUploaded();
await dataModelPage.waitForDataModelToAppear(dataModelName);
const dataModelComboboxValue = await dataModelPage.getDataModelOptionValue(dataModelName);
expect(dataModelComboboxValue).toMatch(/\/testdatamodel.schema.json$/);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { GiteaPage } from '../../pages/GiteaPage';

const getAppTestName = (app: string) => `bindings-${app}`;

// const WAIT_ONE_SECOND = 2000;

// Before the tests starts, we need to create the data model app
test.beforeAll(async ({ testAppName, request, storageState }) => {
// Create a new app
Expand Down Expand Up @@ -80,6 +78,7 @@ test('That it is possible to add a data model binding, and that the files are up
const dataModelName: string = 'testdatamodel';
await dataModelPage.typeDataModelName(dataModelName);
await dataModelPage.clickOnCreateModelButton();
await dataModelPage.waitForDataModelToAppear(dataModelName);
await dataModelPage.clickOnGenerateDataModelButton();
await dataModelPage.checkThatSuccessAlertIsVisibleOnScreen();
await dataModelPage.waitForSuccessAlertToDisappear();
Expand Down
Loading