Skip to content

O3 - 2199 : Add BDD steps on tests #40

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 0 additions & 20 deletions e2e/pages/ocl-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,7 @@ import { type Page, expect } from '@playwright/test';
export class OpenConceptLabPage {
constructor(readonly page: Page) {}

readonly subscriptionTab = () => this.page.getByRole('tab', { name: 'Subscription' });
readonly importTab = () => this.page.getByRole('tab', { name: 'Import', exact: true });
readonly previousImportsTab = () => this.page.getByRole('tab', { name: 'Previous Imports' });
readonly previousImportsTable = () => this.page.getByRole('table');

async goto() {
await this.page.goto('ocl');
}

async addOclSubscription() {
await expect(this.page.getByRole('heading', { name: /ocl subscription module/i })).toBeVisible();
await this.page.getByLabel('Subscription URL').fill(process.env.E2E_OCL_SUBSCRIPTION_URL);
await this.page.getByLabel('Token').fill(process.env.E2E_OCL_TOKEN);
await this.page.getByRole('button', { name: 'Save Changes' }).click();
}

async startImport() {
await this.page.getByRole('button', { name: 'Import from Subscription' }).click();
}

async unsubscribe() {
await this.page.getByRole('button', { name: 'Unsubscribe' }).click();
}
}
57 changes: 43 additions & 14 deletions e2e/specs/open-concept-lab.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import { getSavedSubscription, removeOclSubscription } from '../commands';
import { test } from '../core';
Expand All @@ -10,25 +11,53 @@ test.beforeEach(async ({ api }) => {
}
});

test('should be able to setup a subscription and import concepts', async ({ page }) => {
test('Setup a subscription and import concepts', async ({ page }) => {
const openConceptLabPage = new OpenConceptLabPage(page);

// Setup the subscription
await openConceptLabPage.goto();
await openConceptLabPage.addOclSubscription();
await test.step('When I go to the "OCL module page"', async () => {
await openConceptLabPage.goto();
});

// Start an Import
await openConceptLabPage.importTab().click();
await openConceptLabPage.startImport();
await test.step('And I enter the subscription URL', async () => {
await openConceptLabPage.page.getByLabel('Subscription URL').fill(process.env.E2E_OCL_SUBSCRIPTION_URL);
});

// Check results of the import
await openConceptLabPage.goto();
await openConceptLabPage.previousImportsTab().click();
await expect(openConceptLabPage.previousImportsTable()).toHaveText(/\d+ items fetched/);
await test.step('And I enter the token', async () => {
await openConceptLabPage.page.getByLabel('Token').fill(process.env.E2E_OCL_TOKEN || '');
});

// Unsubscribe
await openConceptLabPage.subscriptionTab().click();
await openConceptLabPage.unsubscribe();
await test.step('And I click the save button', async () => {
await openConceptLabPage.page.getByRole('button', { name: 'Save Changes' }).click();
});

await test.step('And I click the Import tab', async () => {
await openConceptLabPage.page.getByRole('tab', { name: 'Import', exact: true }).click();
});

await test.step('And I click the Import from Subscription button', async () => {
await openConceptLabPage.page.getByRole('button', { name: 'Import from Subscription' }).click();
});

await test.step('And I refresh the page and go to the previous imports tab', async () => {
await openConceptLabPage.goto();
await openConceptLabPage.page.getByRole('tab', { name: 'Previous Imports' }).click();
});

await test.step('Then I should see the previous imports', async () => {
await expect(openConceptLabPage.page.getByRole('table')).toHaveText(/\d+ items fetched/);
});

await test.step('And I click the Subscription Tab', async () => {
await openConceptLabPage.page.getByRole('tab', { name: 'Subscription' }).click();
});

await test.step('And I unsubscribe', async () => {
await openConceptLabPage.page.getByRole('button', { name: 'Unsubscribe' }).click();
});

await test.step('Then I should see the unsubscribe message', async () => {
await openConceptLabPage.page.getByText('Subscription created successfully');
});
});

test.afterEach(async ({ api }) => {
Expand Down