summaryrefslogtreecommitdiffstats
path: root/tests/e2e/right-settings-button.test.e2e.js
blob: 4f2b09b4c1cc6cda7924f951a15fa5a65ace386f (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// @ts-check
import {expect} from '@playwright/test';
import {test, login_user, load_logged_in_context} from './utils_e2e.js';

test.beforeAll(async ({browser}, workerInfo) => {
  await login_user(browser, workerInfo, 'user2');
});

test.describe('desktop viewport', () => {
  test.use({viewport: {width: 1920, height: 300}});

  test('Settings button on right of repo header', async ({browser}, workerInfo) => {
    const context = await load_logged_in_context(browser, workerInfo, 'user2');
    const page = await context.newPage();

    await page.goto('/user2/repo1');

    const settingsBtn = page.locator('.overflow-menu-items>#settings-btn');
    await expect(settingsBtn).toBeVisible();
    await expect(settingsBtn).toHaveClass(/right/);

    await expect(page.locator('.overflow-menu-button')).toHaveCount(0);
  });

  test('Settings button on right of repo header also when add more button is shown', async ({browser}, workerInfo) => {
    await login_user(browser, workerInfo, 'user12');
    const context = await load_logged_in_context(browser, workerInfo, 'user12');
    const page = await context.newPage();

    await page.goto('/user12/repo10');

    const settingsBtn = page.locator('.overflow-menu-items>#settings-btn');
    await expect(settingsBtn).toBeVisible();
    await expect(settingsBtn).toHaveClass(/right/);

    await expect(page.locator('.overflow-menu-button')).toHaveCount(0);
  });

  test('Settings button on right of org header', async ({browser}, workerInfo) => {
    const context = await load_logged_in_context(browser, workerInfo, 'user2');
    const page = await context.newPage();

    await page.goto('/org3');

    const settingsBtn = page.locator('.overflow-menu-items>#settings-btn');
    await expect(settingsBtn).toBeVisible();
    await expect(settingsBtn).toHaveClass(/right/);

    await expect(page.locator('.overflow-menu-button')).toHaveCount(0);
  });

  test('User overview overflow menu should not be influenced', async ({page}) => {
    await page.goto('/user2');

    await expect(page.locator('.overflow-menu-items>#settings-btn')).toHaveCount(0);

    await expect(page.locator('.overflow-menu-button')).toHaveCount(0);
  });
});

test.describe('small viewport', () => {
  test.use({viewport: {width: 800, height: 300}});

  test('Settings button in overflow menu of repo header', async ({browser}, workerInfo) => {
    const context = await load_logged_in_context(browser, workerInfo, 'user2');
    const page = await context.newPage();

    await page.goto('/user2/repo1');

    await expect(page.locator('.overflow-menu-items>#settings-btn')).toHaveCount(0);

    await expect(page.locator('.overflow-menu-button')).toBeVisible();

    await page.click('.overflow-menu-button');
    await expect(page.locator('.tippy-target>#settings-btn')).toBeVisible();

    // Verify that we have no duplicated items
    const shownItems = await page.locator('.overflow-menu-items>a').all();
    expect(shownItems).not.toHaveLength(0);
    const overflowItems = await page.locator('.tippy-target>a').all();
    expect(overflowItems).not.toHaveLength(0);

    const items = shownItems.concat(overflowItems);
    expect(Array.from(new Set(items))).toHaveLength(items.length);
  });

  test('Settings button in overflow menu of org header', async ({browser}, workerInfo) => {
    const context = await load_logged_in_context(browser, workerInfo, 'user2');
    const page = await context.newPage();

    await page.goto('/org3');

    await expect(page.locator('.overflow-menu-items>#settings-btn')).toHaveCount(0);

    await expect(page.locator('.overflow-menu-button')).toBeVisible();

    await page.click('.overflow-menu-button');
    await expect(page.locator('.tippy-target>#settings-btn')).toBeVisible();

    // Verify that we have no duplicated items
    const shownItems = await page.locator('.overflow-menu-items>a').all();
    expect(shownItems).not.toHaveLength(0);
    const overflowItems = await page.locator('.tippy-target>a').all();
    expect(overflowItems).not.toHaveLength(0);

    const items = shownItems.concat(overflowItems);
    expect(Array.from(new Set(items))).toHaveLength(items.length);
  });

  test('User overview overflow menu should not be influenced', async ({page}) => {
    await page.goto('/user2');

    await expect(page.locator('.overflow-menu-items>#settings-btn')).toHaveCount(0);

    await expect(page.locator('.overflow-menu-button')).toBeVisible();
    await page.click('.overflow-menu-button');
    await expect(page.locator('.tippy-target>#settings-btn')).toHaveCount(0);

    // Verify that we have no duplicated items
    const shownItems = await page.locator('.overflow-menu-items>a').all();
    expect(shownItems).not.toHaveLength(0);
    const overflowItems = await page.locator('.tippy-target>a').all();
    expect(overflowItems).not.toHaveLength(0);

    const items = shownItems.concat(overflowItems);
    expect(Array.from(new Set(items))).toHaveLength(items.length);
  });
});