test: refactor create flow test cases with test.step (#1228)

This commit is contained in:
QAComet
2023-08-21 16:27:10 -06:00
committed by GitHub
parent 8e0a28d238
commit cede96f018

View File

@@ -1,77 +1,75 @@
// @ts-check // @ts-check
const { FlowEditorPage } = require('../../fixtures/flow-editor-page');
const { LoginPage } = require('../../fixtures/login-page');
const { test, expect } = require('../../fixtures/index'); const { test, expect } = require('../../fixtures/index');
test.describe.configure({ mode: 'serial' }); test('Ensure creating a new flow works', async ({ page }) => {
await page.getByTestId('create-flow-button').click();
let flowEditorPage; await expect(page).toHaveURL(/\/editor\/create/);
await expect(page).toHaveURL(
test.beforeAll(async ({ browser }) => {
const page = await browser.newPage();
await new LoginPage(page).login();
flowEditorPage = new FlowEditorPage(page);
});
test('create flow', async () => {
await flowEditorPage.page.getByTestId('create-flow-button').click();
await expect(flowEditorPage.page).toHaveURL(/\/editor\/create/);
await expect(flowEditorPage.page).toHaveURL(
/\/editor\/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/ /\/editor\/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/
); );
})
await expect(flowEditorPage.stepCircularLoader).not.toBeVisible(); test(
'Create a new flow with a Scheduler step then an Ntfy step',
async ({ flowEditorPage, page }) => {
await test.step('create flow', async () => {
await test.step('navigate to new flow page', async () => {
await page.getByTestId('create-flow-button').click();
await page.waitForURL(
/\/editor\/[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}/
);
}); });
test('has two steps by default', async () => { await test.step('has two steps by default', async () => {
await expect(flowEditorPage.page.getByTestId('flow-step')).toHaveCount(2); await expect(page.getByTestId('flow-step')).toHaveCount(2);
});
}); });
test.describe('arrange Scheduler trigger', () => { await test.step('setup Scheduler trigger', async () => {
test.describe('choose app and event substep', () => { await test.step('choose app and event substep', async () => {
test('choose application', async () => { await test.step('choose application', async () => {
await flowEditorPage.appAutocomplete.click(); await flowEditorPage.appAutocomplete.click();
await flowEditorPage.page await page
.getByRole('option', { name: 'Scheduler' }) .getByRole('option', { name: 'Scheduler' })
.click(); .click();
}); });
test('choose an event', async () => { await test.step('choose and event', async () => {
await expect(flowEditorPage.eventAutocomplete).toBeVisible(); await expect(flowEditorPage.eventAutocomplete).toBeVisible();
await flowEditorPage.eventAutocomplete.click(); await flowEditorPage.eventAutocomplete.click();
await flowEditorPage.page await page
.getByRole('option', { name: 'Every hour' }) .getByRole('option', { name: 'Every hour' })
.click(); .click();
}); });
test('continue to next step', async () => { await test.step('continue to next step', async () => {
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
}); });
test('collapses the substep', async () => { await test.step('collapses the substep', async () => {
await expect(flowEditorPage.appAutocomplete).not.toBeVisible(); await expect(flowEditorPage.appAutocomplete).not.toBeVisible();
await expect(flowEditorPage.eventAutocomplete).not.toBeVisible(); await expect(flowEditorPage.eventAutocomplete).not.toBeVisible();
}); });
}); });
test.describe('set up a trigger', () => { await test.step('set up a trigger', async () => {
test('choose "yes" in "trigger on weekends?"', async () => { await test.step('choose "yes" in "trigger on weekends?"', async () => {
await expect(flowEditorPage.trigger).toBeVisible(); await expect(flowEditorPage.trigger).toBeVisible();
await flowEditorPage.trigger.click(); await flowEditorPage.trigger.click();
await flowEditorPage.page.getByRole('option', { name: 'Yes' }).click(); await page.getByRole('option', { name: 'Yes' }).click();
}); });
test('continue to next step', async () => { await test.step('continue to next step', async () => {
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
}); });
test('collapses the substep', async () => { await test.step('collapses the substep', async () => {
await expect(flowEditorPage.trigger).not.toBeVisible(); await expect(flowEditorPage.trigger).not.toBeVisible();
}); });
}); });
test.describe('test trigger', () => { await test.step('test trigger', async () => {
test('show sample output', async () => { await test.step('show sample output', async () => {
await expect(flowEditorPage.testOuput).not.toBeVisible(); await expect(flowEditorPage.testOuput).not.toBeVisible();
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
await expect(flowEditorPage.testOuput).toBeVisible(); await expect(flowEditorPage.testOuput).toBeVisible();
@@ -83,71 +81,71 @@ test.describe('arrange Scheduler trigger', () => {
}); });
}); });
test.describe('arrange Ntfy action', () => { await test.step('arrange Ntfy action', async () => {
test.describe('choose app and event substep', () => { await test.step('choose app and event substep', async () => {
test('choose application', async () => { await test.step('choose application', async () => {
await flowEditorPage.appAutocomplete.click(); await flowEditorPage.appAutocomplete.click();
await flowEditorPage.page.getByRole('option', { name: 'Ntfy' }).click(); await page.getByRole('option', { name: 'Ntfy' }).click();
}); });
test('choose an event', async () => { await test.step('choose an event', async () => {
await expect(flowEditorPage.eventAutocomplete).toBeVisible(); await expect(flowEditorPage.eventAutocomplete).toBeVisible();
await flowEditorPage.eventAutocomplete.click(); await flowEditorPage.eventAutocomplete.click();
await flowEditorPage.page await page
.getByRole('option', { name: 'Send message' }) .getByRole('option', { name: 'Send message' })
.click(); .click();
}); });
test('continue to next step', async () => { await test.step('continue to next step', async () => {
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
}); });
test('collapses the substep', async () => { await test.step('collapses the substep', async () => {
await expect(flowEditorPage.appAutocomplete).not.toBeVisible(); await expect(flowEditorPage.appAutocomplete).not.toBeVisible();
await expect(flowEditorPage.eventAutocomplete).not.toBeVisible(); await expect(flowEditorPage.eventAutocomplete).not.toBeVisible();
}); });
}); });
test.describe('choose connection', () => { await test.step('choose connection substep', async () => {
test('choose connection list item', async () => { await test.step('choose connection list item', async () => {
await flowEditorPage.connectionAutocomplete.click(); await flowEditorPage.connectionAutocomplete.click();
await flowEditorPage.page.getByRole('option').first().click(); await page.getByRole('option').first().click();
}); });
test('continue to next step', async () => { await test.step('continue to next step', async () => {
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
}); });
test('collapses the substep', async () => { await test.step('collapses the substep', async () => {
await expect(flowEditorPage.connectionAutocomplete).not.toBeVisible(); await expect(flowEditorPage.connectionAutocomplete).not.toBeVisible();
}); });
}); });
test.describe('set up action', () => { await test.step('set up action substep', async () => {
test('fill topic and message body', async () => { await test.step('fill topic and message body', async () => {
await flowEditorPage.page await page
.getByTestId('parameters.topic-power-input') .getByTestId('parameters.topic-power-input')
.locator('[contenteditable]') .locator('[contenteditable]')
.fill('Topic'); .fill('Topic');
await flowEditorPage.page await page
.getByTestId('parameters.message-power-input') .getByTestId('parameters.message-power-input')
.locator('[contenteditable]') .locator('[contenteditable]')
.fill('Message body'); .fill('Message body');
}); });
test('continue to next step', async () => { await test.step('continue to next step', async () => {
await flowEditorPage.continueButton.click(); await flowEditorPage.continueButton.click();
}); });
test('collapses the substep', async () => { await test.step('collapses the substep', async () => {
await expect(flowEditorPage.connectionAutocomplete).not.toBeVisible(); await expect(flowEditorPage.connectionAutocomplete).not.toBeVisible();
}); });
}); });
test.describe('test trigger', () => { await test.step('test trigger substep', async () => {
test('show sample output', async () => { await test.step('show sample output', async () => {
await expect(flowEditorPage.testOuput).not.toBeVisible(); await expect(flowEditorPage.testOuput).not.toBeVisible();
await flowEditorPage.page await page
.getByTestId('flow-substep-continue-button') .getByTestId('flow-substep-continue-button')
.first() .first()
.click(); .click();
@@ -160,35 +158,35 @@ test.describe('arrange Ntfy action', () => {
}); });
}); });
test.describe('publish and unpublish', () => { await test.step('publish and unpublish', async () => {
test('publish flow', async () => { await test.step('publish flow', async () => {
await expect(flowEditorPage.unpublishFlowButton).not.toBeVisible(); await expect(flowEditorPage.unpublishFlowButton).not.toBeVisible();
await expect(flowEditorPage.publishFlowButton).toBeVisible(); await expect(flowEditorPage.publishFlowButton).toBeVisible();
await flowEditorPage.publishFlowButton.click(); await flowEditorPage.publishFlowButton.click();
await expect(flowEditorPage.publishFlowButton).not.toBeVisible(); await expect(flowEditorPage.publishFlowButton).not.toBeVisible();
}); });
test('shows read-only sticky snackbar', async () => { await test.step('shows read-only sticky snackbar', async () => {
await expect(flowEditorPage.infoSnackbar).toBeVisible(); await expect(flowEditorPage.infoSnackbar).toBeVisible();
await flowEditorPage.screenshot({ await flowEditorPage.screenshot({
path: 'Published flow.png', path: 'Published flow.png',
}); });
}); });
test('unpublish from snackbar', async () => { await test.step('unpublish from snackbar', async () => {
await flowEditorPage.page await page
.getByTestId('unpublish-flow-from-snackbar') .getByTestId('unpublish-flow-from-snackbar')
.click(); .click();
await expect(flowEditorPage.infoSnackbar).not.toBeVisible(); await expect(flowEditorPage.infoSnackbar).not.toBeVisible();
}); });
test('publish once again', async () => { await test.step('publish once again', async () => {
await expect(flowEditorPage.publishFlowButton).toBeVisible(); await expect(flowEditorPage.publishFlowButton).toBeVisible();
await flowEditorPage.publishFlowButton.click(); await flowEditorPage.publishFlowButton.click();
await expect(flowEditorPage.publishFlowButton).not.toBeVisible(); await expect(flowEditorPage.publishFlowButton).not.toBeVisible();
}); });
test('unpublish from layout top bar', async () => { await test.step('unpublish from layout top bar', async () => {
await expect(flowEditorPage.unpublishFlowButton).toBeVisible(); await expect(flowEditorPage.unpublishFlowButton).toBeVisible();
await flowEditorPage.unpublishFlowButton.click(); await flowEditorPage.unpublishFlowButton.click();
await expect(flowEditorPage.unpublishFlowButton).not.toBeVisible(); await expect(flowEditorPage.unpublishFlowButton).not.toBeVisible();
@@ -198,9 +196,11 @@ test.describe('publish and unpublish', () => {
}); });
}); });
test.describe('in layout', () => { await test.step('in layout', async () => {
test('can go back to flows page', async () => { await test.step('can go back to flows page', async () => {
await flowEditorPage.page.getByTestId('editor-go-back-button').click(); await page.getByTestId('editor-go-back-button').click();
await expect(flowEditorPage.page).toHaveURL('/flows'); await expect(page).toHaveURL('/flows');
}); });
}); });
}
);