-
Notifications
You must be signed in to change notification settings - Fork 223
Expand file tree
/
Copy pathgithub-discovery.spec.ts
More file actions
60 lines (54 loc) · 1.91 KB
/
github-discovery.spec.ts
File metadata and controls
60 lines (54 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { test as base, expect } from "@playwright/test";
import GithubApi from "../support/api/github";
import { CATALOG_FILE, JANUS_QE_ORG } from "../utils/constants";
import { Common } from "../utils/common";
import { Catalog } from "../support/pages/catalog";
type GithubDiscoveryFixture = {
catalogPage: Catalog;
githubApi: GithubApi;
testOrganization: string;
};
const test = base.extend<GithubDiscoveryFixture>({
catalogPage: async ({ page }, use) => {
await new Common(page).loginAsGuest();
const catalog = new Catalog(page);
await catalog.go();
await use(catalog);
},
githubApi: new GithubApi(),
testOrganization: JANUS_QE_ORG,
});
test.describe("Github Discovery Catalog", () => {
test(`Discover Organization's Catalog`, async ({
catalogPage,
githubApi,
testOrganization,
}) => {
const organizationRepos = await githubApi.getReposFromOrg(testOrganization);
expect(organizationRepos.length).toBeGreaterThan(0);
const reposNames: string[] = (organizationRepos as Array<{ name?: string }>)
.map((repo) => repo.name)
.filter((name): name is string => typeof name === "string")
// filter for subset of organization repositories where the repository name matches the entity name
.filter((name) => name.startsWith("test-annotator"))
.slice(0, 5);
const reposWithCatalogInfo: string[] = (
await Promise.all(
reposNames.map(async (repo) =>
(await githubApi.fileExistsOnRepo(
`${testOrganization}/${repo}`,
CATALOG_FILE,
))
? repo
: null,
),
)
).filter((repo): repo is string => typeof repo === "string");
expect(reposWithCatalogInfo.length).toBeGreaterThan(0);
for (const repo of reposWithCatalogInfo) {
await catalogPage.search(repo);
const row = await catalogPage.tableRow(repo);
await expect(row).toBeVisible();
}
});
});