Skip to content

Commit

Permalink
Trying to fix the two broken playwright tests (#12255)
Browse files Browse the repository at this point in the history
* Implementing changes to fix 2 broken Playwright tests

* Fixing the two broken tests in Playwright

* Removing timeout

* fixing delete ttd test
  • Loading branch information
WilliamThorenfeldt authored Feb 6, 2024
1 parent 598b8f6 commit f73ce31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions frontend/testing/playwright/helpers/BasePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,12 @@ export class BasePage extends RouterRoute {

return text;
}

public async waitForXAmountOfMilliseconds(milliseconds: number): Promise<void> {
await new Promise((resolve) =>
setTimeout(() => {
return resolve('');
}, milliseconds),
);
}
}
1 change: 0 additions & 1 deletion frontend/testing/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default defineConfig<ExtendedTestOptions>({
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL,
},
fullyParallel: true,
timeout: 3 * 60 * 1000,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: 1, // Github actions always use only 1, so we set to 1 locally as well
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { DeployPage } from '../../pages/DeployPage';
import { Header } from '../../components/Header';
import { Gitea } from '../../helpers/Gitea';

const getTtdApp = (appName: string) => `ttd-app-${appName}`;

// Before the tests starts, we need to create the dashboard app
test.beforeAll(async ({ testAppName, request, storageState }) => {
// Create a new app
Expand All @@ -28,7 +30,7 @@ test.afterAll(async ({ request, testAppName }) => {
expect(response.ok()).toBeTruthy();

const responseTTD = await request.delete(
gitea.getDeleteAppEndpoint({ org: 'ttd', app: testAppName }),
gitea.getDeleteAppEndpoint({ org: 'ttd', app: getTtdApp(testAppName) }),
);
expect(responseTTD.ok()).toBeTruthy();
});
Expand Down Expand Up @@ -138,19 +140,20 @@ test('That it is possible to navigate from overview to the deploy page and back
storageState,
}) => {
const testDepartmentOrg: string = 'ttd';
const appName: string = getTtdApp(testAppName); // Need a different app name than the one generated by the user in beforeAll()

const designerApi = new DesignerApi({ app: testAppName });
const designerApi = new DesignerApi({ app: appName });
const response = await designerApi.createApp(
request,
storageState as StorageState,
testDepartmentOrg,
);
expect(response.ok()).toBeTruthy();

const dashboardPage = new DashboardPage(page, { app: testAppName });
const overviewPage = new OverviewPage(page, { app: testAppName });
const deployPage = new DeployPage(page, { app: testAppName });
const header = new Header(page, { app: testAppName });
const dashboardPage = new DashboardPage(page, { app: appName });
const overviewPage = new OverviewPage(page, { app: appName });
const deployPage = new DeployPage(page, { app: appName });
const header = new Header(page, { app: appName });

await dashboardPage.loadDashboardPage();
await dashboardPage.verifyDashboardPage();
Expand All @@ -161,13 +164,18 @@ test('That it is possible to navigate from overview to the deploy page and back
await dashboardPage.checkThatTTDApplicationsHeaderIsVisible();

expect(dashboardPage.org).toEqual('ttd');
await dashboardPage.clickOnTestAppEditButton(testAppName);

await dashboardPage.typeInSearchField(appName);
await dashboardPage.checkThatAppIsVisible(appName);
await dashboardPage.clickOnTestAppEditButton(appName);

// As we have changed env.org to 'ttd', we need to update the org of the new classes to make sure it works.
overviewPage.updateOrgNameEnv(testDepartmentOrg);
deployPage.updateOrgNameEnv(testDepartmentOrg);
header.updateOrgNameEnv(testDepartmentOrg);

// overviewPage.waitForXAmountOfMilliseconds(3000);

await overviewPage.verifyOverviewPage();

// Check Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ test('That it is possible to edit security level on "Policy editor" tab, and tha
const securityValueAfterChange = await policyEditor.getSelectedSecurityLevel();
expect(securityValueAfterChange).toBe(securityLevel3Text);

// In dev, the API call to save the policy takes some time, and therefore we add functionality to wait for a while to wait for the save to happen
await settingsModal.waitForXAmountOfMilliseconds(4000);

await settingsModal.navigateToTab('about');
await settingsModal.verifyThatTabIsVisible('about');
await settingsModal.verifyThatTabIsHidden('policy');
Expand Down

0 comments on commit f73ce31

Please sign in to comment.