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

Trying to fix the two broken playwright tests #12255

Merged
5 commits merged into from
Feb 6, 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
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
Loading